summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS0
-rw-r--r--COPYING680
-rw-r--r--ChangeLog2
-rw-r--r--INSTALL0
-rw-r--r--Makefile.am8
-rw-r--r--NEWS0
-rw-r--r--README0
-rwxr-xr-xautogen.sh73
-rw-r--r--configure.ac60
-rw-r--r--m4/ac_check_class.m4107
-rw-r--r--m4/ac_check_classpath.m423
-rw-r--r--m4/ac_check_junit.m454
-rw-r--r--m4/ac_check_rqrd_class.m426
-rw-r--r--m4/ac_expand.m48
-rw-r--r--m4/ac_java_options.m432
-rw-r--r--m4/ac_prog_jar.m436
-rw-r--r--m4/ac_prog_java.m479
-rw-r--r--m4/ac_prog_java_works.m497
-rw-r--r--m4/ac_prog_javac.m443
-rw-r--r--m4/ac_prog_javac_works.m435
-rw-r--r--m4/ac_prog_javadoc.m437
-rw-r--r--m4/ac_prog_javah.m426
-rw-r--r--m4/ac_try_compile_java.m439
-rw-r--r--m4/ac_try_run_javac.m440
-rw-r--r--src/Makefile.am7
-rw-r--r--src/com/Makefile.am1
-rw-r--r--src/com/sun/Makefile.am1
-rw-r--r--src/com/sun/apoc/Makefile.am1
-rw-r--r--src/com/sun/apoc/tools/Makefile.am1
-rw-r--r--src/com/sun/apoc/tools/profileeditor/ComponentFactory.java266
-rw-r--r--src/com/sun/apoc/tools/profileeditor/LocaleManager.java200
-rw-r--r--src/com/sun/apoc/tools/profileeditor/LocaleNotifier.java50
-rw-r--r--src/com/sun/apoc/tools/profileeditor/LocalizedDefaultMutableTreeNode.java143
-rw-r--r--src/com/sun/apoc/tools/profileeditor/Makefile.am7
-rw-r--r--src/com/sun/apoc/tools/profileeditor/PanelFactory.java218
-rw-r--r--src/com/sun/apoc/tools/profileeditor/PreferenceNotifier.java50
-rw-r--r--src/com/sun/apoc/tools/profileeditor/PreferenceSubscriber.java46
-rw-r--r--src/com/sun/apoc/tools/profileeditor/ProfileEditor.java763
-rw-r--r--src/com/sun/apoc/tools/profileeditor/ProfileEditorPreferences.java124
-rw-r--r--src/com/sun/apoc/tools/profileeditor/PropertyComponentDummy.java295
-rw-r--r--src/com/sun/apoc/tools/profileeditor/Subscriber.java54
-rw-r--r--src/com/sun/apoc/tools/profileeditor/SwingWorker.java165
-rw-r--r--src/com/sun/apoc/tools/profileeditor/XMLFileFilter.java76
-rw-r--r--src/com/sun/apoc/tools/profileeditor/build.xml.in63
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/AboutFrame.java104
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/ColourButton.java100
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/ComboBoxElement.java132
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/ComponentListener.java111
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/ErrorPanel.java97
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/GeneralPropertiesPanel.java366
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/GradientJButton.java83
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/GradientJPanel.java107
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/GradientTabPaneUI.java195
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/ImageButton.java79
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/ImageButtonMouseListener.java98
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/InfoPanel.java96
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/LocalizedTitledBorder.java85
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/OnlineHelpFrame.java103
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PreferencesJPanel.java244
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/ProfileEditorJMenuBar.java129
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyChooser.java474
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyColorChooser.java423
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyColorSelector.java310
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyComponent.java141
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJComboBox.java280
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJLabel.java129
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJList.java199
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJListModel.java194
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJListPanel.java172
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJPasswordField.java268
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJRadioButtonGroupPanel.java403
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJRadioButtonListener.java76
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyJTextField.java311
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/PropertyStringList.java419
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/SectionPanel.java185
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/SetPanel.java366
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/SetSubPanel.java177
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/SummaryJPanel.java349
-rw-r--r--src/com/sun/apoc/tools/profileeditor/gui/TitledSectionJPanel.java215
-rw-r--r--src/com/sun/apoc/tools/profileeditor/packages/Package.java162
-rw-r--r--src/com/sun/apoc/tools/profileeditor/packages/PackageManager.java385
-rw-r--r--src/com/sun/apoc/tools/profileeditor/packages/PackageNode.java67
-rw-r--r--src/com/sun/apoc/tools/profileeditor/packages/Template.java191
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/StandalonePolicyManager.java274
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/StandalonePolicyManagerHelper.java424
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfile.java633
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileComparator.java87
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileManager.java392
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileProviderImpl.java329
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileProviderImplTest.java89
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileRepositoryImpl.java347
-rw-r--r--src/com/sun/apoc/tools/profileeditor/spi/ZipProfileReadWrite.java287
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/LocalizedElement.java44
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/NarratedElement.java42
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplateActionHandler.java79
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplateCategory.java148
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplateElement.java124
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplatePage.java188
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplateParser.java650
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplateProperty.java270
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplatePropertyConstraint.java56
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplateSection.java104
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplateSet.java73
-rw-r--r--src/com/sun/apoc/tools/profileeditor/templates/TemplateXMLHandler.java136
-rwxr-xr-xsrc/profile-editor.in5
105 files changed, 16842 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/AUTHORS
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..b8a9e57
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,680 @@
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+1. Definitions.
+
+1.1. Contributor means each individual or entity that creates or
+contributes to the creation of Modifications.
+
+1.2. Contributor Version means the combination of the Original
+Software, prior Modifications used by a Contributor (if any),
+and the Modifications made by that particular Contributor.
+
+1.3. Covered Software means (a) the Original Software, or (b)
+Modifications, or (c) the combination of files containing
+Original Software with files containing Modifications, in each
+case including portions thereof.
+
+1.4. Executable means the Covered Software in any form other
+than Source Code.
+
+1.5. Initial Developer means the individual or entity that first
+makes Original Software available under this License.
+
+1.6. Larger Workmeans a work which combines Covered Software or
+portions thereof with code not governed by the terms of this
+License.
+
+1.7. License means this document.
+
+1.8. Licensable means having the right to grant, to the maximum
+extent possible, whether at the time of the initial grant or
+subsequently acquired, any and all of the rights conveyed herein.
+
+1.9. Modifications means the Source Code and Executable form of
+any of the following: A. Any file that results from an addition
+to, deletion from or modification of the contents of a file
+containing Original Software or previous Modifications; B. Any
+new file that contains any part of the Original Software or
+previous Modification; or C. Any new file that is contributed or
+otherwise made available under the terms of this License.
+
+1.10. Original Software means the Source Code and Executable
+form of computer software code that is originally released under
+this License.
+
+1.11. Patent Claims means any patent claim(s), now owned or
+hereafter acquired, including without limitation, method,
+process, and apparatus claims, in any patent Licensable by
+grantor.
+
+1.12. Source Code means (a) the common form of computer software
+code in which modifications are made and (b) associated
+documentation included in or with such code.
+
+1.13. You (or Your) means an individual or a legal entity
+exercising rights under, and complying with all of the terms of,
+this License. For legal entities, You includes any entity which
+controls, is controlled by, or is under common control with You.
+For purposes of this definition, control means (a) the power,
+direct or indirect, to cause the direction or management of such
+entity, whether by contract or otherwise, or (b) ownership of
+more than fifty percent (50%) of the outstanding shares or
+beneficial ownership of such entity.
+
+2. License Grants.
+
+2.1. The Initial Developer Grant. Conditioned upon Your
+compliance with Section 3.1 below and subject to third party
+intellectual property claims, the Initial Developer hereby
+grants You a world-wide, royalty-free, non-exclusive license:
+
+(a) under intellectual property rights (other than patent or
+trademark) Licensable by Initial Developer, to use, reproduce,
+modify, display, perform, sublicense and distribute the Original
+Software (or portions thereof), with or without Modifications,
+and/or as part of a Larger Work; and
+
+(b) under Patent Claims infringed by the making, using or
+selling of Original Software, to make, have made, use, practice,
+sell, and offer for sale, and/or otherwise dispose of the
+Original Software (or portions thereof);
+
+(c) The licenses granted in Sections 2.1(a) and (b) are
+effective on the date Initial Developer first distributes or
+otherwise makes the Original Software available to a third party
+under the terms of this License;
+
+(d) Notwithstanding Section 2.1(b) above, no patent license is
+granted: (1) for code that You delete from the Original
+Software, or (2) for infringements caused by: (i) the
+modification of the Original Software, or (ii) the combination
+of the Original Software with other software or devices.
+
+2.2. Contributor Grant. Conditioned upon Your compliance with
+Section 3.1 below and subject to third party intellectual
+property claims, each Contributor hereby grants You a
+world-wide, royalty-free, non-exclusive license:
+
+(a) under intellectual property rights (other than patent or
+trademark) Licensable by Contributor to use, reproduce, modify,
+display, perform, sublicense and distribute the Modifications
+created by such Contributor (or portions thereof), either on an
+unmodified basis, with other Modifications, as Covered Software
+and/or as part of a Larger Work; and
+
+(b) under Patent Claims infringed by the making, using, or
+selling of Modifications made by that Contributor either alone
+and/or in combination with its Contributor Version (or portions
+of such combination), to make, use, sell, offer for sale, have
+made, and/or otherwise dispose of: (1) Modifications made by
+that Contributor (or portions thereof); and (2) the combination
+of Modifications made by that Contributor with its Contributor
+Version (or portions of such combination).
+
+(c) The licenses granted in Sections 2.2(a) and 2.2(b)
+areeffective on the date Contributor first distributes or
+otherwise makes the Modifications available to a third party.
+
+(d) Notwithstanding Section 2.2(b) above, no patent license is
+granted: (1) for any code that Contributor has deleted from the
+Contributor Version; (2) for infringements caused by: (i) third
+party modifications of Contributor Version, or (ii) the
+combination of Modifications made by that Contributor with other
+software (except as part of the Contributor Version) or other
+devices; or (3) under Patent Claims infringed by Covered
+Software in the absence of Modifications made by that
+Contributor.
+
+3. Distribution Obligations.
+
+3.1. Availability of Source Code. Any Covered Software that You
+distribute or otherwise make available in Executable form must
+also be made available in Source Code form and that Source Code
+form must be distributed only under the terms of this License.
+You must include a copy of this License with every copy of the
+Source Code form of the Covered Software You distribute or
+otherwise make available. You must inform recipients of any such
+Covered Software in Executable form as to how they can obtain
+such Covered Software in Source Code form in a reasonable manner
+on or through a medium customarily used for software exchange.
+
+3.2. Modifications. The Modifications that You create or to
+which You contribute are governed by the terms of this License.
+You represent that You believe Your Modifications are Your
+original creation(s) and/or You have sufficient rights to grant
+the rights conveyed by this License.
+
+3.3. Required Notices. You must include a notice in each of Your
+Modifications that identifies You as the Contributor of the
+Modification. You may not remove or alter any copyright, patent
+or trademark notices contained within the Covered Software, or
+any notices of licensing or any descriptive text giving
+attribution to any Contributor or the Initial Developer.
+
+3.4. Application of Additional Terms. You may not offer or
+impose any terms on any Covered Software in Source Code form
+that alters or restricts the applicable version of this License
+or the recipients rights hereunder. You may choose to offer, and
+to charge a fee for, warranty, support, indemnity or liability
+obligations to one or more recipients of Covered
+Software. However, you may do so only on Your own behalf, and
+not on behalf of the Initial Developer or any Contributor. You
+must make it absolutely clear that any such warranty, support,
+indemnity or liability obligation is offered by You alone, and
+You hereby agree to indemnify the Initial Developer and every
+Contributor for any liability incurred by the Initial Developer
+or such Contributor as a result of warranty, support, indemnity
+or liability terms You offer.
+
+3.5. Distribution of Executable Versions. You may distribute the
+Executable form of the Covered Software under the terms of this
+License or under the terms of a license of Your choice, which
+may contain terms different from this License, provided that You
+are in compliance with the terms of this License and that the
+license for the Executable form does not attempt to limit or
+alter the recipients rights in the Source Code form from the
+rights set forth in this License. If You distribute the Covered
+Software in Executable form under a different license, You must
+make it absolutely clear that any terms which differ from this
+License are offered by You alone, not by the Initial Developer
+or Contributor. You hereby agree to indemnify the Initial
+Developer and every Contributor for any liability incurred by
+the Initial Developer or such Contributor as a result of any
+such terms You offer.
+
+3.6. Larger Works. You may create a Larger Work by combining
+Covered Software with other code not governed by the terms of
+this License and distribute the Larger Work as a single product.
+In such a case, You must make sure the requirements of this
+License are fulfilled for the Covered Software.
+
+4. Versions of the License.
+
+4.1. New Versions. Sun Microsystems, Inc. is the initial license
+steward and may publish revised and/or new versions of this
+License from time to time. Each version will be given a
+distinguishing version number. Except as provided in Section
+4.3, no one other than the license steward has the right to
+modify this License.
+
+4.2. Effect of New Versions. You may always continue to use,
+distribute or otherwise make the Covered Software available
+under the terms of the version of the License under which You
+originally received the Covered Software. If the Initial
+Developer includes a notice in the Original Software prohibiting
+it from being distributed or otherwise made available under any
+subsequent version of the License, You must distribute and make
+the Covered Software available under the terms of the version of
+the License under which You originally received the Covered
+Software. Otherwise, You may also choose to use, distribute or
+otherwise make the Covered Software available under the terms of
+any subsequent version of the License published by the license
+steward.
+
+4.3. Modified Versions. When You are an Initial Developer and
+You want to create a new license for Your Original Software, You
+may create and use a modified version of this License if You:
+(a) rename the license and remove any references to the name of
+the license steward (except to note that the license differs
+from this License); and (b) otherwise make it clear that the
+license contains terms which differ from this License.
+
+5. DISCLAIMER OF WARRANTY. COVERED SOFTWARE IS PROVIDED UNDER
+THIS LICENSE ON AN AS IS BASIS, WITHOUT WARRANTY OF ANY KIND,
+EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION,
+WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS,
+MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
+SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE
+DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY
+OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING,
+REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN
+ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE
+IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+6. TERMINATION.
+
+6.1. This License and the rights granted hereunder will
+terminate automatically if You fail to comply with terms herein
+and fail to cure such breach within 30 days of becoming aware of
+the breach. Provisions which, by their nature, must remain in
+effect beyond the termination of this License shall survive.
+
+6.2. If You assert a patent infringement claim (excluding
+declaratory judgment actions) against Initial Developer or a
+Contributor (the Initial Developer or Contributor against whom
+You assert such claim is referred to as Participant) alleging
+that the Participant Software (meaning the Contributor Version
+where the Participant is a Contributor or the Original Software
+where the Participant is the Initial Developer) directly or
+indirectly infringes any patent, then any and all rights granted
+directly or indirectly to You by such Participant, the Initial
+Developer (if the Initial Developer is not the Participant) and
+all Contributors under Sections 2.1 and/or 2.2 of this License
+shall, upon 60 days notice from Participant terminate
+prospectively and automatically at the expiration of such 60 day
+notice period, unless if within such 60 day period You withdraw
+Your claim with respect to the Participant Software against such
+Participant either unilaterally or pursuant to a written
+agreement with Participant.
+
+6.3. In the event of termination under Sections 6.1 or 6.2
+above, all end user licenses that have been validly granted by
+You or any distributor hereunder prior to termination (excluding
+licenses granted to You by any distributor) shall survive
+termination.
+
+7. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO
+LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR
+OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER
+CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY
+SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY
+INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
+CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST
+PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR
+MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES,
+EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY
+OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO
+LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH
+PARTYS NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH
+LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR
+LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS
+EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+8. U.S. GOVERNMENT END USERS. The Covered Software is a
+commercial item, as that term is defined in 48 C.F.R. 2.101
+(Oct. 1995), consisting of commercial computer software (as that
+term is defined at 48 C.F.R. 252.227-7014(a)(1)) and commercial
+computer software documentation as such terms are used in 48
+C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and
+48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all
+U.S. Government End Users acquire Covered Software with only
+those rights set forth herein. This U.S. Government Rights
+clause is in lieu of, and supersedes, any other FAR, DFAR, or
+other clause or provision that addresses Government rights in
+computer software under this License.
+
+9. MISCELLANEOUS. This License represents the complete agreement
+concerning subject matter hereof. If any provision of this
+License is held to be unenforceable, such provision shall be
+reformed only to the extent necessary to make it enforceable.
+This License shall be governed by the law of the jurisdiction
+specified in a notice contained within the Original Software
+(except to the extent applicable law, if any, provides
+otherwise), excluding such jurisdictions conflict-of-law
+provisions. Any litigation relating to this License shall be
+subject to the jurisdiction of the courts located in the
+jurisdiction and venue specified in a notice contained within
+the Original Software, with the losing party responsible for
+costs, including, without limitation, court costs and reasonable
+attorneys fees and expenses. The application of the United
+Nations Convention on Contracts for the International Sale of
+Goods is expressly excluded. Any law or regulation which
+provides that the language of a contract shall be construed
+against the drafter shall not apply to this License. You agree
+that You alone are responsible for compliance with the United
+States export administration regulations (and the export control
+laws and regulation of any other countries) when You use,
+distribute or otherwise make available any Covered Software.
+
+10. RESPONSIBILITY FOR CLAIMS. As between Initial Developer and
+the Contributors, each party is responsible for claims and
+damages arising, directly or indirectly, out of its utilization
+of rights under this License and You agree to work with Initial
+Developer and Contributors to distribute such responsibility on
+an equitable basis. Nothing herein is intended or shall be
+deemed to constitute any admission of liability.
+
+----------------------------------------------------------------
+
+NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND
+DISTRIBUTION LICENSE (CDDL): This code is released under the
+CDDL and shall be governed by the laws of the State of
+California (excluding conflict-of-law provisions). Any
+litigation relating to this License shall be subject to the
+jurisdiction of the Federal Courts of the Northern District of
+California and the state courts of the State of California, with
+venue lying in Santa Clara County, California.
+
+----------------------------------------------------------------
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..7c0a25a
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,2 @@
+2007-30-10 Alberto Ruiz <alberto.ruiz@sun.com>
+ * Initial commit.
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/INSTALL
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..78b5d80
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,8 @@
+SUBDIRS = src
+
+profileeditordir=@APOCDIR@
+
+profileeditor_DATA=build/class/apoc_peditor.jar
+
+clean-local:
+ rm -rf build
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..462df9e
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+PROJECT=APOC
+TEST_TYPE=-f
+FILE=src/com/sun/apoc/tools/profileeditor/build.xml.in
+
+DIE=0
+
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have autoconf installed to compile $PROJECT."
+ echo "Install the appropriate package for your distribution,"
+ echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
+ DIE=1
+}
+
+
+AM1_10=`which automake-1.10.1`
+AM1_9=`which automake-1.9`
+
+if test -x "`which automake-1.9`"
+then
+ AUTOMAKE=`which automake-1.9`
+ ACLOCAL=`which aclocal-1.9`
+ ACLOCAL_FLAGS="-I m4/"
+elif test -x "`which automake-1.10`"
+then
+ AUTOMAKE=`which automake-1.10`
+ ACLOCAL=`which aclocal-1.10`
+ ACLOCAL_FLAGS="-I m4/"
+else
+ echo
+ echo "You must have automake 1.10.x or 1.9.x installed to compile $PROJECT."
+ echo "Install the appropriate package for your distribution,"
+ echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
+ DIE=1
+fi
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+test $TEST_TYPE $FILE || {
+ echo "You must run this script in the top-level $PROJECT directory"
+ exit 1
+}
+
+if test -z "$AUTOGEN_SUBDIR_MODE"; then
+ if test -z "$*"; then
+ echo "I am going to run ./configure with no arguments - if you wish "
+ echo "to pass any to it, please specify them on the $0 command line."
+ fi
+fi
+
+rm -rf autom4te.cache
+
+$ACLOCAL $ACLOCAL_FLAGS || exit $?
+$AUTOMAKE --add-missing || exit $?
+autoconf || exit $?
+cd $ORIGDIR || exit $?
+
+if test -z "$AUTOGEN_SUBDIR_MODE"; then
+ $srcdir/configure --enable-maintainer-mode $AUTOGEN_CONFIGURE_ARGS "$@" || exit $?
+
+ echo
+ echo "Now type 'make' to compile $PROJECT."
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..dd6a298
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,60 @@
+AC_INIT(apoc-desktop-agent, 1.0)
+
+AM_INIT_AUTOMAKE
+AC_JAVA_OPTIONS
+
+# Setting APOC Daemon dir
+AC_EXPAND(libdir,NONE,EXPANDED_LIBDIR)
+
+APOCD_DIR="$EXPANDED_LIBDIR/apoc"
+
+# Checking for# Setting APOC class path
+AC_EXPAND(datadir, NONE, EXPANDED_DATADIR)
+
+APOCDIR=$EXPANDED_DATADIR'/lib/apoc'
+
+AC_ARG_WITH(apoc-path,
+AC_HELP_STRING( [--with-apoc-path=DIR],
+ [specify a path to install the apoc libraries (DATADIR/lib/apoc)]),
+[
+ if test "$withval" != "no"
+ then
+ APOCDIR=$withval
+ fi
+])
+
+SPIJDK=$APOCDIR/spi.jar
+
+export CLASSPATH=$CLASPATH:$SPIJDK
+
+AC_PROG_JAVAC
+AC_PROG_JAVA
+AC_PROG_JAR
+
+AC_CHECK_CLASS(com.sun.apoc.spi.PolicyManager, [], [
+echo
+AC_MSG_ERROR(APOC SPI not found.
+If it is already installed please use --with-apoc-path=DIR to point to the path wher the spi.jar file is stored.)
+])
+
+AC_CHECK_PROG(ANT, ant, ant, no)
+if test $ANT == "no"
+then
+ AC_MSG_ERROR(Apache's Ant was not found in path.)
+fi
+
+AC_SUBST(APOCDIR)
+AC_SUBST(SPIJDK)
+AC_SUBST(LDAPJDK)
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+src/profile-editor
+src/com/Makefile
+src/com/sun/Makefile
+src/com/sun/apoc/Makefile
+src/com/sun/apoc/tools/Makefile
+src/com/sun/apoc/tools/profileeditor/Makefile
+src/com/sun/apoc/tools/profileeditor/build.xml
+])
diff --git a/m4/ac_check_class.m4 b/m4/ac_check_class.m4
new file mode 100644
index 0000000..b12e7f0
--- /dev/null
+++ b/m4/ac_check_class.m4
@@ -0,0 +1,107 @@
+dnl @synopsis AC_CHECK_CLASS
+dnl
+dnl AC_CHECK_CLASS tests the existence of a given Java class, either in
+dnl a jar or in a '.class' file.
+dnl
+dnl *Warning*: its success or failure can depend on a proper setting of the
+dnl CLASSPATH env. variable.
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
+dnl @version $Id: ac_check_class.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_CHECK_CLASS],[
+AC_REQUIRE([AC_PROG_JAVA])
+ac_var_name=`echo $1 | sed 's/\./_/g'`
+dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is
+dnl dynamic I need an extra level of extraction
+AC_MSG_CHECKING([for $1 class])
+AC_CACHE_VAL(ac_cv_class_$ac_var_name, [
+if test x$ac_cv_prog_uudecode_base64 = xyes; then
+dnl /**
+dnl * Test.java: used to test dynamicaly if a class exists.
+dnl */
+dnl public class Test
+dnl {
+dnl
+dnl public static void
+dnl main( String[] argv )
+dnl {
+dnl Class lib;
+dnl if (argv.length < 1)
+dnl {
+dnl System.err.println ("Missing argument");
+dnl System.exit (77);
+dnl }
+dnl try
+dnl {
+dnl lib = Class.forName (argv[0]);
+dnl }
+dnl catch (ClassNotFoundException e)
+dnl {
+dnl System.exit (1);
+dnl }
+dnl lib = null;
+dnl System.exit (0);
+dnl }
+dnl
+dnl }
+cat << \EOF > Test.uue
+begin-base64 644 Test.class
+yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
+bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
+bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ
+AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt
+ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV
+ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp
+VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM
+amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi
+AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B
+AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA
+AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN
+uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK
+AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA
+JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA
+JwAAAAIAKA==
+====
+EOF
+ if uudecode$EXEEXT Test.uue; then
+ :
+ else
+ echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
+ echo "configure: failed file was:" >&AC_FD_CC
+ cat Test.uue >&AC_FD_CC
+ ac_cv_prog_uudecode_base64=no
+ fi
+ rm -f Test.uue
+ if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then
+ eval "ac_cv_class_$ac_var_name=yes"
+ else
+ eval "ac_cv_class_$ac_var_name=no"
+ fi
+ rm -f Test.class
+else
+ AC_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"],
+ [eval "ac_cv_class_$ac_var_name=no"])
+fi
+eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
+eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`"
+HAVE_LAST_CLASS=$ac_var_val
+if test x$ac_var_val = xyes; then
+ ifelse([$2], , :, [$2])
+else
+ ifelse([$3], , :, [$3])
+fi
+])
+dnl for some reason the above statment didn't fall though here?
+dnl do scripts have variable scoping?
+eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
+AC_MSG_RESULT($ac_var_val)
+])
diff --git a/m4/ac_check_classpath.m4 b/m4/ac_check_classpath.m4
new file mode 100644
index 0000000..b18d479
--- /dev/null
+++ b/m4/ac_check_classpath.m4
@@ -0,0 +1,23 @@
+dnl @synopsis AC_CHECK_CLASSPATH
+dnl
+dnl AC_CHECK_CLASSPATH just displays the CLASSPATH, for the edification
+dnl of the user.
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
+dnl @version $Id: ac_check_classpath.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_CHECK_CLASSPATH],[
+if test "x$CLASSPATH" = x; then
+ echo "You have no CLASSPATH, I hope it is good"
+else
+ echo "You have CLASSPATH $CLASSPATH, hope it is correct"
+fi
+])
diff --git a/m4/ac_check_junit.m4 b/m4/ac_check_junit.m4
new file mode 100644
index 0000000..cc02e32
--- /dev/null
+++ b/m4/ac_check_junit.m4
@@ -0,0 +1,54 @@
+dnl @synopsis AC_CHECK_JUNIT
+dnl
+dnl AC_CHECK_JUNIT tests the availability of the Junit testing
+dnl framework, and set some variables for conditional compilation
+dnl of the test suite by automake.
+dnl
+dnl If available, JUNIT is set to a command launching the text
+dnl based user interface of Junit, @JAVA_JUNIT@ is set to $JAVA_JUNIT
+dnl and @TESTS_JUNIT@ is set to $TESTS_JUNIT, otherwise they are set
+dnl to empty values.
+dnl
+dnl You can use these variables in your Makefile.am file like this :
+dnl
+dnl # Some of the following classes are built only if junit is available
+dnl JAVA_JUNIT = Class1Test.java Class2Test.java AllJunitTests.java
+dnl
+dnl noinst_JAVA = Example1.java Example2.java @JAVA_JUNIT@
+dnl
+dnl EXTRA_JAVA = $(JAVA_JUNIT)
+dnl
+dnl TESTS_JUNIT = AllJunitTests
+dnl
+dnl TESTS = StandaloneTest1 StandaloneTest2 @TESTS_JUNIT@
+dnl
+dnl EXTRA_TESTS = $(TESTS_JUNIT)
+dnl
+dnl AllJunitTests :
+dnl echo "#! /bin/sh" > $@
+dnl echo "exec @JUNIT@ my.package.name.AllJunitTests" >> $@
+dnl chmod +x $@
+dnl
+dnl @author Luc Maisonobe
+dnl @version $Id: ac_check_junit.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_CHECK_JUNIT],[
+AC_CACHE_VAL(ac_cv_prog_JUNIT,[
+AC_CHECK_CLASS(junit.textui.TestRunner)
+if test x"`eval 'echo $ac_cv_class_junit_textui_TestRunner'`" != xno ; then
+ ac_cv_prog_JUNIT='$(CLASSPATH_ENV) $(JAVA) $(JAVAFLAGS) junit.textui.TestRunner'
+fi])
+AC_MSG_CHECKING([for junit])
+if test x"`eval 'echo $ac_cv_prog_JUNIT'`" != x ; then
+ JUNIT="$ac_cv_prog_JUNIT"
+ JAVA_JUNIT='$(JAVA_JUNIT)'
+ TESTS_JUNIT='$(TESTS_JUNIT)'
+else
+ JUNIT=
+ JAVA_JUNIT=
+ TESTS_JUNIT=
+fi
+AC_MSG_RESULT($JAVA_JUNIT)
+AC_SUBST(JUNIT)
+AC_SUBST(JAVA_JUNIT)
+AC_SUBST(TESTS_JUNIT)])
diff --git a/m4/ac_check_rqrd_class.m4 b/m4/ac_check_rqrd_class.m4
new file mode 100644
index 0000000..c7c26b8
--- /dev/null
+++ b/m4/ac_check_rqrd_class.m4
@@ -0,0 +1,26 @@
+dnl @synopsis AC_CHECK_RQRD_CLASS
+dnl
+dnl AC_CHECK_RQRD_CLASS tests the existence of a given Java class, either in
+dnl a jar or in a '.class' file and fails if it doesn't exist.
+dnl Its success or failure can depend on a proper setting of the
+dnl CLASSPATH env. variable.
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
+dnl @version $Id: ac_check_rqrd_class.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+
+AC_DEFUN([AC_CHECK_RQRD_CLASS],[
+CLASS=`echo $1|sed 's/\./_/g'`
+AC_CHECK_CLASS($1)
+if test "$HAVE_LAST_CLASS" = "no"; then
+ AC_MSG_ERROR([Required class $1 missing, exiting.])
+fi
+])
diff --git a/m4/ac_expand.m4 b/m4/ac_expand.m4
new file mode 100644
index 0000000..ae8188a
--- /dev/null
+++ b/m4/ac_expand.m4
@@ -0,0 +1,8 @@
+AC_DEFUN([AC_EXPAND], [
+ test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+ ac_expand=[$]$1
+ test "x$ac_expand" = xNONE && ac_expand="[$]$2"
+ ac_expand=`eval echo [$]ac_expand`
+ $3=`eval echo [$]ac_expand`
+])
diff --git a/m4/ac_java_options.m4 b/m4/ac_java_options.m4
new file mode 100644
index 0000000..e71adfe
--- /dev/null
+++ b/m4/ac_java_options.m4
@@ -0,0 +1,32 @@
+dnl @synopsis AC_JAVA_OPTIONS
+dnl
+dnl AC_JAVA_OPTIONS adds configure command line options used for Java m4
+dnl macros. This Macro is optional.
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Devin Weaver <ktohg@tritarget.com>
+dnl @version $Id: ac_java_options.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_JAVA_OPTIONS],[
+AC_ARG_WITH(java-prefix,
+ [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)])
+AC_ARG_WITH(javac-flags,
+ [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)])
+AC_ARG_WITH(java-flags,
+ [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)])
+JAVAPREFIX=$with_java_prefix
+JAVACFLAGS=$with_javac_flags
+JAVAFLAGS=$with_java_flags
+AC_SUBST(JAVAPREFIX)dnl
+AC_SUBST(JAVACFLAGS)dnl
+AC_SUBST(JAVAFLAGS)dnl
+AC_SUBST(JAVA)dnl
+AC_SUBST(JAVAC)dnl
+])
diff --git a/m4/ac_prog_jar.m4 b/m4/ac_prog_jar.m4
new file mode 100644
index 0000000..c60a79a
--- /dev/null
+++ b/m4/ac_prog_jar.m4
@@ -0,0 +1,36 @@
+dnl @synopsis AC_PROG_JAR
+dnl
+dnl AC_PROG_JAR tests for an existing jar program. It uses the environment
+dnl variable JAR then tests in sequence various common jar programs.
+dnl
+dnl If you want to force a specific compiler:
+dnl
+dnl - at the configure.in level, set JAR=yourcompiler before calling
+dnl AC_PROG_JAR
+dnl
+dnl - at the configure level, setenv JAR
+dnl
+dnl You can use the JAR variable in your Makefile.in, with @JAR@.
+dnl
+dnl Note: This macro depends on the autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download that whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl
+dnl The general documentation of those macros, as well as the sample
+dnl configure.in, is included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Egon Willighagen <egonw@sci.kun.nl>
+dnl @version $Id: ac_prog_jar.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_PROG_JAR],[
+AC_REQUIRE([AC_EXEEXT])dnl
+if test "x$JAVAPREFIX" = x; then
+ test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar$EXEEXT)
+else
+ test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar, $JAVAPREFIX)
+fi
+test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH])
+AC_PROVIDE([$0])dnl
+])
diff --git a/m4/ac_prog_java.m4 b/m4/ac_prog_java.m4
new file mode 100644
index 0000000..05c65e7
--- /dev/null
+++ b/m4/ac_prog_java.m4
@@ -0,0 +1,79 @@
+dnl @synopsis AC_PROG_JAVA
+dnl
+dnl Here is a summary of the main macros:
+dnl
+dnl AC_PROG_JAVAC: finds a Java compiler.
+dnl
+dnl AC_PROG_JAVA: finds a Java virtual machine.
+dnl
+dnl AC_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!).
+dnl
+dnl AC_CHECK_RQRD_CLASS: finds if we have the given class and stops otherwise.
+dnl
+dnl AC_TRY_COMPILE_JAVA: attempt to compile user given source.
+dnl
+dnl AC_TRY_RUN_JAVA: attempt to compile and run user given source.
+dnl
+dnl AC_JAVA_OPTIONS: adds Java configure options.
+dnl
+dnl AC_PROG_JAVA tests an existing Java virtual machine. It uses the
+dnl environment variable JAVA then tests in sequence various common Java
+dnl virtual machines. For political reasons, it starts with the free ones.
+dnl You *must* call [AC_PROG_JAVAC] before.
+dnl
+dnl If you want to force a specific VM:
+dnl
+dnl - at the configure.in level, set JAVA=yourvm before calling AC_PROG_JAVA
+dnl (but after AC_INIT)
+dnl
+dnl - at the configure level, setenv JAVA
+dnl
+dnl You can use the JAVA variable in your Makefile.in, with @JAVA@.
+dnl
+dnl *Warning*: its success or failure can depend on a proper setting of the
+dnl CLASSPATH env. variable.
+dnl
+dnl TODO: allow to exclude virtual machines (rationale: most Java programs
+dnl cannot run with some VM like kaffe).
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl
+dnl A Web page, with a link to the latest CVS snapshot is at
+dnl <http://www.internatif.org/bortzmeyer/autoconf-Java/>.
+dnl
+dnl This is a sample configure.in
+dnl Process this file with autoconf to produce a configure script.
+dnl
+dnl AC_INIT(UnTag.java)
+dnl
+dnl dnl Checks for programs.
+dnl AC_CHECK_CLASSPATH
+dnl AC_PROG_JAVAC
+dnl AC_PROG_JAVA
+dnl
+dnl dnl Checks for classes
+dnl AC_CHECK_RQRD_CLASS(org.xml.sax.Parser)
+dnl AC_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
+dnl
+dnl AC_OUTPUT(Makefile)
+dnl
+dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
+dnl @version $Id: ac_prog_java.ac,v 12.1 2006/08/24 14:45:36 bostic Exp $
+dnl
+dnl Note: Modified to prefer java over kaffe. [#8059]
+dnl
+AC_DEFUN([AC_PROG_JAVA],[
+AC_REQUIRE([AC_EXEEXT])dnl
+if test x$JAVAPREFIX = x; then
+ test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT kaffe$EXEEXT)
+else
+ test x$JAVA = x && AC_CHECK_PROGS(JAVA, java$EXEEXT kaffe$EXEEXT, $JAVAPREFIX)
+fi
+test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
+AC_PROG_JAVA_WORKS
+AC_PROVIDE([$0])dnl
+])
diff --git a/m4/ac_prog_java_works.m4 b/m4/ac_prog_java_works.m4
new file mode 100644
index 0000000..f0ff8c5
--- /dev/null
+++ b/m4/ac_prog_java_works.m4
@@ -0,0 +1,97 @@
+dnl @synopsis AC_PROG_JAVA_WORKS
+dnl
+dnl Internal use ONLY.
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
+dnl @version $Id: ac_prog_java_works.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_PROG_JAVA_WORKS], [
+AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
+if test x$uudecode = xyes; then
+AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
+dnl /**
+dnl * Test.java: used to test if java compiler works.
+dnl */
+dnl public class Test
+dnl {
+dnl
+dnl public static void
+dnl main( String[] argv )
+dnl {
+dnl System.exit (0);
+dnl }
+dnl
+dnl }
+cat << \EOF > Test.uue
+begin-base64 644 Test.class
+yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
+bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
+bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
+YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
+aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
+AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
+AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
+====
+EOF
+if uudecode$EXEEXT Test.uue; then
+ ac_cv_prog_uudecode_base64=yes
+else
+ echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
+ echo "configure: failed file was:" >&AC_FD_CC
+ cat Test.uue >&AC_FD_CC
+ ac_cv_prog_uudecode_base64=no
+fi
+rm -f Test.uue])
+fi
+if test x$ac_cv_prog_uudecode_base64 != xyes; then
+ rm -f Test.class
+ AC_MSG_WARN([I have to compile Test.class from scratch])
+ if test x$ac_cv_prog_javac_works = xno; then
+ AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
+ fi
+ if test x$ac_cv_prog_javac_works = x; then
+ AC_PROG_JAVAC
+ fi
+fi
+AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
+JAVA_TEST=Test.java
+CLASS_TEST=Test.class
+TEST=Test
+changequote(, )dnl
+cat << \EOF > $JAVA_TEST
+/* [#]line __oline__ "configure" */
+public class Test {
+public static void main (String args[]) {
+ System.exit (0);
+} }
+EOF
+changequote([, ])dnl
+if test x$ac_cv_prog_uudecode_base64 != xyes; then
+ if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
+ :
+ else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat $JAVA_TEST >&AC_FD_CC
+ AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
+ fi
+fi
+if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
+ ac_cv_prog_java_works=yes
+else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat $JAVA_TEST >&AC_FD_CC
+ AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
+fi
+rm -fr $JAVA_TEST $CLASS_TEST Test.uue
+])
+AC_PROVIDE([$0])dnl
+]
+)
diff --git a/m4/ac_prog_javac.m4 b/m4/ac_prog_javac.m4
new file mode 100644
index 0000000..b3607dc
--- /dev/null
+++ b/m4/ac_prog_javac.m4
@@ -0,0 +1,43 @@
+dnl @synopsis AC_PROG_JAVAC
+dnl
+dnl AC_PROG_JAVAC tests an existing Java compiler. It uses the environment
+dnl variable JAVAC then tests in sequence various common Java compilers. For
+dnl political reasons, it starts with the free ones.
+dnl
+dnl If you want to force a specific compiler:
+dnl
+dnl - at the configure.in level, set JAVAC=yourcompiler before calling
+dnl AC_PROG_JAVAC
+dnl
+dnl - at the configure level, setenv JAVAC
+dnl
+dnl You can use the JAVAC variable in your Makefile.in, with @JAVAC@.
+dnl
+dnl *Warning*: its success or failure can depend on a proper setting of the
+dnl CLASSPATH env. variable.
+dnl
+dnl TODO: allow to exclude compilers (rationale: most Java programs cannot compile
+dnl with some compilers like guavac).
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
+dnl @version $Id: ac_prog_javac.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_PROG_JAVAC],[
+AC_REQUIRE([AC_EXEEXT])dnl
+if test "x$JAVAPREFIX" = x; then
+ test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac$EXEEXT "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT)
+else
+ test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, javac$EXEEXT "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT, $JAVAPREFIX)
+fi
+test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
+AC_PROG_JAVAC_WORKS
+AC_PROVIDE([$0])dnl
+])
diff --git a/m4/ac_prog_javac_works.m4 b/m4/ac_prog_javac_works.m4
new file mode 100644
index 0000000..0cfd1f2
--- /dev/null
+++ b/m4/ac_prog_javac_works.m4
@@ -0,0 +1,35 @@
+dnl @synopsis AC_PROG_JAVAC_WORKS
+dnl
+dnl Internal use ONLY.
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
+dnl @version $Id: ac_prog_javac_works.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_PROG_JAVAC_WORKS],[
+AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
+JAVA_TEST=Test.java
+CLASS_TEST=Test.class
+cat << \EOF > $JAVA_TEST
+/* [#]line __oline__ "configure" */
+public class Test {
+}
+EOF
+if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
+ ac_cv_prog_javac_works=yes
+else
+ AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat $JAVA_TEST >&AC_FD_CC
+fi
+rm -f $JAVA_TEST $CLASS_TEST
+])
+AC_PROVIDE([$0])dnl
+])
diff --git a/m4/ac_prog_javadoc.m4 b/m4/ac_prog_javadoc.m4
new file mode 100644
index 0000000..36b95bd
--- /dev/null
+++ b/m4/ac_prog_javadoc.m4
@@ -0,0 +1,37 @@
+dnl @synopsis AC_PROG_JAVADOC
+dnl
+dnl AC_PROG_JAVADOC tests for an existing javadoc generator. It uses the environment
+dnl variable JAVADOC then tests in sequence various common javadoc generator.
+dnl
+dnl If you want to force a specific compiler:
+dnl
+dnl - at the configure.in level, set JAVADOC=yourgenerator before calling
+dnl AC_PROG_JAVADOC
+dnl
+dnl - at the configure level, setenv JAVADOC
+dnl
+dnl You can use the JAVADOC variable in your Makefile.in, with @JAVADOC@.
+dnl
+dnl Note: This macro depends on the autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download that whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl
+dnl The general documentation of those macros, as well as the sample
+dnl configure.in, is included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Egon Willighagen <egonw@sci.kun.nl>
+dnl @version $Id: ac_prog_javadoc.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_PROG_JAVADOC],[
+AC_REQUIRE([AC_EXEEXT])dnl
+if test "x$JAVAPREFIX" = x; then
+ test "x$JAVADOC" = x && AC_CHECK_PROGS(JAVADOC, javadoc$EXEEXT)
+else
+ test "x$JAVADOC" = x && AC_CHECK_PROGS(JAVADOC, javadoc, $JAVAPREFIX)
+fi
+test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH])
+AC_PROVIDE([$0])dnl
+])
+
diff --git a/m4/ac_prog_javah.m4 b/m4/ac_prog_javah.m4
new file mode 100644
index 0000000..7563036
--- /dev/null
+++ b/m4/ac_prog_javah.m4
@@ -0,0 +1,26 @@
+dnl @synopsis AC_PROG_JAVAH
+dnl
+dnl AC_PROG_JAVAH tests the availability of the javah header generator
+dnl and looks for the jni.h header file. If available, JAVAH is set to
+dnl the full path of javah and CPPFLAGS is updated accordingly.
+dnl
+dnl @author Luc Maisonobe
+dnl @version $Id: ac_prog_javah.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_PROG_JAVAH],[
+AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl
+AC_REQUIRE([AC_PROG_CPP])dnl
+AC_PATH_PROG(JAVAH,javah)
+if test x"`eval 'echo $ac_cv_path_JAVAH'`" != x ; then
+ AC_TRY_CPP([#include <jni.h>],,[
+ ac_save_CPPFLAGS="$CPPFLAGS"
+changequote(, )dnl
+ ac_dir=`echo $ac_cv_path_JAVAH | sed 's,\(.*\)/[^/]*/[^/]*$,\1/include,'`
+ ac_machdep=`echo $build_os | sed 's,[-0-9].*,,'`
+changequote([, ])dnl
+ CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep"
+ AC_TRY_CPP([#include <jni.h>],
+ ac_save_CPPFLAGS="$CPPFLAGS",
+ AC_MSG_WARN([unable to include <jni.h>]))
+ CPPFLAGS="$ac_save_CPPFLAGS"])
+fi])
diff --git a/m4/ac_try_compile_java.m4 b/m4/ac_try_compile_java.m4
new file mode 100644
index 0000000..d22aeab
--- /dev/null
+++ b/m4/ac_try_compile_java.m4
@@ -0,0 +1,39 @@
+dnl @synopsis AC_TRY_COMPILE_JAVA
+dnl
+dnl AC_TRY_COMPILE_JAVA attempt to compile user given source.
+dnl
+dnl *Warning*: its success or failure can depend on a proper setting of the
+dnl CLASSPATH env. variable.
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Devin Weaver <ktohg@tritarget.com>
+dnl @version $Id: ac_try_compile_java.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_TRY_COMPILE_JAVA],[
+AC_REQUIRE([AC_PROG_JAVAC])dnl
+cat << \EOF > Test.java
+/* [#]line __oline__ "configure" */
+ifelse([$1], , , [import $1;])
+public class Test {
+[$2]
+}
+EOF
+if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class
+then
+dnl Don't remove the temporary files here, so they can be examined.
+ ifelse([$3], , :, [$3])
+else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat Test.java >&AC_FD_CC
+ifelse([$4], , , [ rm -fr Test*
+ $4
+])dnl
+fi
+rm -fr Test*])
diff --git a/m4/ac_try_run_javac.m4 b/m4/ac_try_run_javac.m4
new file mode 100644
index 0000000..0124935
--- /dev/null
+++ b/m4/ac_try_run_javac.m4
@@ -0,0 +1,40 @@
+dnl @synopsis AC_TRY_RUN_JAVA
+dnl
+dnl AC_TRY_RUN_JAVA attempt to compile and run user given source.
+dnl
+dnl *Warning*: its success or failure can depend on a proper setting of the
+dnl CLASSPATH env. variable.
+dnl
+dnl Note: This is part of the set of autoconf M4 macros for Java programs.
+dnl It is VERY IMPORTANT that you download the whole set, some
+dnl macros depend on other. Unfortunately, the autoconf archive does not
+dnl support the concept of set of macros, so I had to break it for
+dnl submission.
+dnl The general documentation, as well as the sample configure.in, is
+dnl included in the AC_PROG_JAVA macro.
+dnl
+dnl @author Devin Weaver <ktohg@tritarget.com>
+dnl @version $Id: ac_try_run_javac.ac,v 12.0 2004/11/17 03:43:38 bostic Exp $
+dnl
+AC_DEFUN([AC_TRY_RUN_JAVA],[
+AC_REQUIRE([AC_PROG_JAVAC])dnl
+AC_REQUIRE([AC_PROG_JAVA])dnl
+cat << \EOF > Test.java
+/* [#]line __oline__ "configure" */
+ifelse([$1], , , [include $1;])
+public class Test {
+[$2]
+}
+EOF
+if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null
+then
+dnl Don't remove the temporary files here, so they can be examined.
+ ifelse([$3], , :, [$3])
+else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat Test.java >&AC_FD_CC
+ifelse([$4], , , [ rm -fr Test*
+ $4
+])dnl
+fi
+rm -fr Test*])
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..6e36d02
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,7 @@
+SUBDIRS = com
+
+bin_SCRIPTS = profile-editor
+
+all:
+ chmod 755 profile-editor
+
diff --git a/src/com/Makefile.am b/src/com/Makefile.am
new file mode 100644
index 0000000..1d06788
--- /dev/null
+++ b/src/com/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = sun
diff --git a/src/com/sun/Makefile.am b/src/com/sun/Makefile.am
new file mode 100644
index 0000000..b5d5f2c
--- /dev/null
+++ b/src/com/sun/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = apoc
diff --git a/src/com/sun/apoc/Makefile.am b/src/com/sun/apoc/Makefile.am
new file mode 100644
index 0000000..9f1025b
--- /dev/null
+++ b/src/com/sun/apoc/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = tools
diff --git a/src/com/sun/apoc/tools/Makefile.am b/src/com/sun/apoc/tools/Makefile.am
new file mode 100644
index 0000000..428432b
--- /dev/null
+++ b/src/com/sun/apoc/tools/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = profileeditor
diff --git a/src/com/sun/apoc/tools/profileeditor/ComponentFactory.java b/src/com/sun/apoc/tools/profileeditor/ComponentFactory.java
new file mode 100644
index 0000000..595dd97
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/ComponentFactory.java
@@ -0,0 +1,266 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+import com.sun.apoc.tools.profileeditor.gui.ComboBoxElement;
+import com.sun.apoc.tools.profileeditor.gui.PropertyChooser;
+import com.sun.apoc.tools.profileeditor.gui.PropertyColorChooser;
+import com.sun.apoc.tools.profileeditor.gui.PropertyColorSelector;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJPasswordField;
+import com.sun.apoc.tools.profileeditor.gui.PropertyStringList;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+import com.sun.apoc.tools.profileeditor.templates.TemplatePropertyConstraint;
+import com.sun.apoc.tools.profileeditor.gui.ComponentListener;
+import com.sun.apoc.tools.profileeditor.gui.PropertyComponent;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJComboBox;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJRadioButtonGroupPanel;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJTextField;
+import java.awt.Dimension;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+import javax.swing.JTextField;
+
+/**
+ *
+ * @author cs202741
+ */
+public class ComponentFactory {
+ private static final String NOT_SET = "-- Not Set --";
+
+
+ public static JComponent getComponent(TemplateProperty aProperty, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager, String packageName){
+ JComponent component = null;
+ String visualType = aProperty.getVisualType();
+
+ if( visualType.equals("comboBox") ){
+ component = getComboBox( aProperty, aLocaleManager, packageName );
+ }else if( visualType.equals("textField") ){
+ component = getTextField( aProperty, packageName );
+ }else if( visualType.equals("checkBox") ){
+ component = getCheckBox( aProperty, aLocaleManager, packageName );
+ }else if( visualType.equals("radioButtons") ){
+ component = getRadioButton( aProperty, aLocaleManager, packageName );
+ }else if( visualType.equals("password") ){
+ component = getPasswordField( aProperty, aLocaleManager, packageName );
+ }else if( visualType.equals("colorSelector") ){
+ component = getColorSelector( aProperty, aLocaleManager, packageName );
+ }else if( visualType.equals("stringList") ){
+ component = getStringList( aProperty, aLocaleManager, packageName );
+ }else if( visualType.equals("chooser") ){
+ component = getChooser( aProperty, aLocaleManager, packageName );
+ }else{
+
+ return component = new JLabel("IMPLEMENT: " + visualType);
+ }
+
+ ((PropertyComponent)component).setDataPath( aProperty.getDataPath() );
+ ((PropertyComponent)component).setDataType( aProperty.getDataType() );
+ ((PropertyComponent)component).setDefaultValue( aProperty.getDefaultValue() );
+ ((PropertyComponent)component).setVisualType( aProperty.getVisualType() );
+ ((PropertyComponent)component).setProfileModel(aProfileModel);
+
+ return component;
+ }
+
+ private static JComponent getComboBox(TemplateProperty aProperty, LocaleManager aLocaleManager, String packageName){
+ JComboBox comboBox = new PropertyJComboBox();
+
+ Object[] items = aProperty.getConstraints().toArray();
+
+ ComboBoxElement localItem = new ComboBoxElement();
+ localItem.setLabel(NOT_SET);
+ localItem.setValue(NOT_SET);
+ comboBox.addItem( localItem );
+ for(int i = 0; i < items.length;i++){
+
+ localItem = new ComboBoxElement();
+ localItem.setValue( ((TemplatePropertyConstraint)items[i]).getValue() );
+ localItem.setLocaleManager(aLocaleManager);
+ localItem.setPackageName( packageName );
+ localItem.setDefault( aProperty.getDefaultValue() );
+ localItem.setResourceId( ((TemplatePropertyConstraint)items[i]).getResourceId() );
+ localItem.setDefaultName( aProperty.getDefaultName() );
+ localItem.update();
+
+ comboBox.addItem( localItem );
+ }
+
+ comboBox.addActionListener( new ComponentListener() );
+
+ comboBox.setMaximumSize( getDimension( aProperty.getDataType() ));
+ return comboBox;
+ }
+
+ private static JComponent getTextField(TemplateProperty aProperty, String packageName){
+
+ JTextField textField = new PropertyJTextField();
+
+ textField.addActionListener( new ComponentListener() );
+ textField.setPreferredSize( getDimension( aProperty.getDataType() ) );
+ textField.setMaximumSize( getDimension( aProperty.getDataType() ));
+ textField.setMinimumSize( getDimension( aProperty.getDataType() ));
+ textField.setText( aProperty.getDefaultValue() );
+
+ textField.addKeyListener( new ComponentListener() );
+ textField.addFocusListener( new ComponentListener() );
+ return textField;
+ }
+
+ private static JComponent getPasswordField(TemplateProperty aProperty, LocaleManager aLocaleManager, String packageName){
+
+ JPasswordField textField = new PropertyJPasswordField(10);
+ textField.setEchoChar('*');
+
+ textField.addActionListener( new ComponentListener() );
+
+ textField.addFocusListener( new ComponentListener() );
+ return textField;
+ }
+
+ private static JComponent getCheckBox(TemplateProperty aProperty, LocaleManager aLocaleManager, String packageName){
+ ComboBoxElement notSet = new ComboBoxElement();
+ notSet.setLabel( NOT_SET );
+ notSet.setValue( NOT_SET );
+
+ ComboBoxElement enabled = new ComboBoxElement();
+ enabled.setValue("true");
+ enabled.setDefault( aProperty.getDefaultValue() );
+ enabled.setLocaleManager( aLocaleManager );
+ enabled.setPackageName( packageName );
+ enabled.setResourceId( aProperty.getResourceId() + ".checked" );
+ enabled.setDefaultName( "Enabled" );
+ enabled.update();
+
+ ComboBoxElement disabled = new ComboBoxElement();
+ disabled.setValue("false");
+ disabled.setDefault( aProperty.getDefaultValue() );
+ disabled.setLocaleManager( aLocaleManager );
+ disabled.setPackageName( packageName );
+ disabled.setResourceId( aProperty.getResourceId() + ".unchecked" );
+ disabled.setDefaultName( "Disabled" );
+ disabled.update();
+
+ JComboBox comboBox = new PropertyJComboBox();
+ comboBox.addItem(notSet);
+ comboBox.addItem(enabled);
+ comboBox.addItem(disabled);
+ comboBox.addActionListener( new ComponentListener() );
+
+ return comboBox;
+ }
+
+
+ private static JComponent getRadioButton(TemplateProperty aProperty, LocaleManager aLocaleManager, String packageName){
+ Object[] constraints = aProperty.getConstraints().toArray();
+
+ JPanel panel = new PropertyJRadioButtonGroupPanel( constraints.length );
+ ((PropertyJRadioButtonGroupPanel)panel).setLocaleManager( aLocaleManager );
+ ((PropertyJRadioButtonGroupPanel)panel).setPackageName( packageName );
+ ((PropertyJRadioButtonGroupPanel)panel).setResourceId( aProperty.getResourceId() );
+ ((PropertyJRadioButtonGroupPanel)panel).setDefaultName( aProperty.getDefaultName() );
+ ((PropertyJRadioButtonGroupPanel)panel).setDefaultValue( aProperty.getDefaultValue() );
+
+ for(int i = 0; i < constraints.length; i++){
+ String value = ((TemplatePropertyConstraint)constraints[i]).getValue();
+ ((PropertyJRadioButtonGroupPanel)panel).addRadioButton( value );
+ }
+
+ return panel;
+ }
+
+ private static JComponent getColorSelector(TemplateProperty aProperty, LocaleManager aLocaleManager, String packageName){
+
+ JPanel textField = new PropertyColorChooser();
+
+ //textField.addActionListener( new ComponentListener() );
+ textField.setPreferredSize( getDimension( aProperty.getDataType() ) );
+ textField.setMaximumSize( getDimension( aProperty.getDataType() ));
+ textField.setMinimumSize( getDimension( aProperty.getDataType() ));
+ ((PropertyColorChooser)textField).setDefaultValue( aProperty.getDefaultValue() );
+
+ textField.addKeyListener( new ComponentListener() );
+ textField.addFocusListener( new ComponentListener() );
+ return textField;
+ }
+
+ private static JComponent getStringList( TemplateProperty aProperty, LocaleManager aLocaleManager, String packageName ){
+
+ JPanel panel = new PropertyStringList();
+ ((PropertyStringList)panel).setSeperator( aProperty.getSeparator() );
+
+ return panel;
+ }
+
+ private static JComponent getChooser( TemplateProperty aProperty, LocaleManager aLocaleManager, String packageName ){
+
+ JPanel panel = new PropertyChooser(aProperty);
+
+ return panel;
+ }
+
+ private static Dimension getDimension(String aDataType){
+ int height;
+ int width;
+
+ if( aDataType.equals("xs:int") ){
+ width = 100;
+ height = 20;
+ }else if( aDataType.equals("xs:short") ){
+ width = 100;
+ height = 20;
+ }else if( aDataType.equals("xs:double") ){
+ width = 100;
+ height = 20;
+ }else if( aDataType.equals("xs:boolean") ){
+ width = 100;
+ height = 20;
+ }else if( aDataType.equals("xs:string") ){
+ width = 200;
+ height = 20;
+ }else{
+ width = 100;
+ height = 20;
+ }
+
+ return new Dimension(width, height);
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/LocaleManager.java b/src/com/sun/apoc/tools/profileeditor/LocaleManager.java
new file mode 100644
index 0000000..b65872b
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/LocaleManager.java
@@ -0,0 +1,200 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ *
+ * @author cs202741
+ */
+public class LocaleManager implements LocaleNotifier, PreferenceSubscriber {
+ private String mLocale = "en";
+ private HashMap mPackageLocalePaths = null;
+ private HashMap mPackageLocales = null;
+ private ProfileEditorPreferences mPreferences = null;
+ private ArrayList<Subscriber> mSubscribers = null;
+
+ private Properties mAllResources = null;
+
+ private boolean displayResourceId = false;
+
+ /** Creates a new instance of LocaleManager */
+ public LocaleManager() {
+ mPackageLocalePaths = new HashMap();
+ mPackageLocales = new HashMap();
+ mSubscribers = new ArrayList();
+ mAllResources = new Properties();
+ }
+
+ public String getLocalizedName(String resourceId, String defaultName){
+
+ if( resourceId == null ){
+ return defaultName;
+ }
+
+ String result = mAllResources.getProperty(resourceId);
+
+ if( result == null ){
+ if( displayResourceId || defaultName == null ){
+ return resourceId;
+ }else{
+ return defaultName;
+ }
+ }
+
+ return result;
+ }
+
+ public String getLocalizedName(String packageName, String resourceId, String defaultName){
+
+ if( packageName == null || resourceId == null ){
+ return null;
+ }
+
+ Properties props = (Properties)mPackageLocales.get(packageName);
+
+ String name = null;
+ if( props != null ){
+ name = props.getProperty( resourceId );
+ }
+
+ if( name == null ){
+ if( defaultName == null ){
+ return null;
+ }
+ if( displayResourceId ){
+ return resourceId;
+ }
+ else{
+ return defaultName;
+ }
+ }else
+ return name;
+ }
+
+
+
+ public void addPackageLocale(String packageName, String localePath){
+
+ mPackageLocalePaths.put( packageName, localePath );
+ mPackageLocales.put( packageName, getLocaleProperties( localePath, mLocale ) );
+
+ }
+
+
+ public void updateLocales(){
+ Set s = mPackageLocalePaths.keySet();
+ Iterator it = s.iterator();
+
+ while( it.hasNext() ){
+ String packageName = (String)it.next();
+ String localePath = (String)mPackageLocalePaths.get( packageName );
+ mPackageLocales.put( packageName, getLocaleProperties( localePath, mLocale ) );
+ }
+ notifySubscribers();
+ }
+
+ public void setLocale(String aLocale){
+ mLocale = aLocale;
+ updateLocales();
+ }
+
+ public String getCurrentLocale(){
+ return mLocale;
+ }
+
+ public void setPreferences(ProfileEditorPreferences prefs){
+ mPreferences = prefs;
+ mPreferences.attach( this );
+ update();
+ }
+
+ public Properties getLocaleProperties(String path, String locale){
+ Properties props = null;
+ if( path != null ){
+ try {
+ ZipFile zf = new ZipFile(path);
+ for (Enumeration entries = zf.entries(); entries.hasMoreElements();) {
+ ZipEntry entry = (ZipEntry)entries.nextElement();
+ String zipEntryName = entry.getName();
+
+ if( zipEntryName.endsWith("_" + locale + ".properties") ){
+ //System.out.println("Loading props for: " + locale);
+ props = new Properties();
+ props.load( zf.getInputStream(entry) );
+ mAllResources.load( zf.getInputStream(entry) );
+ break;
+ }
+ }
+ zf.close();
+ } catch (IOException ex) {
+ System.err.println("Cannot open: " + path);
+ ex.printStackTrace();
+ }
+ }
+ return props;
+ }
+
+ public void attach(Subscriber sub) {
+ mSubscribers.add(sub);
+ }
+
+ public void detach(Subscriber sub) {
+ mSubscribers.remove(sub);
+ }
+
+ public void notifySubscribers() {
+ Iterator it = mSubscribers.iterator();
+ while( it.hasNext() ){
+ ((Subscriber)it.next()).update();
+ }
+ }
+
+ public void update() {
+ displayResourceId = Boolean.valueOf( mPreferences.getProperty("displayResourceIds") );
+ notifySubscribers();
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/LocaleNotifier.java b/src/com/sun/apoc/tools/profileeditor/LocaleNotifier.java
new file mode 100644
index 0000000..09d8c58
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/LocaleNotifier.java
@@ -0,0 +1,50 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+/**
+ *
+ * @author cs202741
+ */
+public interface LocaleNotifier {
+
+ void attach(Subscriber sub);
+
+ void detach(Subscriber sub);
+
+ void notifySubscribers();
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/LocalizedDefaultMutableTreeNode.java b/src/com/sun/apoc/tools/profileeditor/LocalizedDefaultMutableTreeNode.java
new file mode 100644
index 0000000..5bb256a
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/LocalizedDefaultMutableTreeNode.java
@@ -0,0 +1,143 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+import com.sun.apoc.tools.profileeditor.packages.Template;
+import java.util.Collections;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.MutableTreeNode;
+
+/**
+ *
+ * @author cs202741
+ */
+public class LocalizedDefaultMutableTreeNode extends DefaultMutableTreeNode implements Subscriber, Comparable {
+
+ // Subscriber Interface Variables
+ private String mResourceID = null;
+ private String mPackageName = null;
+ private String mDefaultName = null;
+ private LocaleManager mLocaleManager = null;
+
+
+ private boolean mHasSet = false;
+
+
+ /** Creates a new instance of LocalizedDefaultMutableTreeNode */
+ public LocalizedDefaultMutableTreeNode(String name, String aPackageName, String aResourceID,
+ String aDefaultName, LocaleManager aLocaleManager) {
+ super(name);
+ mPackageName = aPackageName;
+ mResourceID = aResourceID;
+ mDefaultName = aDefaultName;
+ mLocaleManager = aLocaleManager;
+ mLocaleManager.attach( this );
+ update();
+ }
+
+ public LocalizedDefaultMutableTreeNode(){
+ super();
+ }
+
+
+ public void add(final MutableTreeNode newChild) {
+ if (newChild != null && newChild.getParent() == this) {
+ remove(newChild);
+ }
+ int index;
+ if (children == null) {
+ index = 0;
+ } else {
+ index = Collections.binarySearch(children, newChild);
+ }
+ if (index < 0) {
+ index = -index - 1;
+ }
+ insert(newChild, index);
+ }
+
+
+ public void update() {
+ if( this.getUserObject() instanceof Template ){
+ ((Template)this.getUserObject()).setName( mResourceID, mDefaultName );
+ }else{
+ String name = mLocaleManager.getLocalizedName(mPackageName, mResourceID, mDefaultName);
+ if( name == null ){
+ name = mResourceID;
+ }
+ super.setUserObject(name);
+ }
+ }
+
+ public void setResourceId(String aResourceID){
+ mResourceID = aResourceID;
+ }
+
+ public String getResourceId(){
+ return mResourceID;
+ }
+
+ public void setContainsSet(boolean hasSet){
+ mHasSet = hasSet;
+ }
+
+ public boolean containsSet(){
+ return mHasSet;
+ }
+
+ public void setPackageName(String aPackageName){
+ mPackageName = aPackageName;
+ }
+
+ public String getPackageName(){
+ return mPackageName;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public void setLocaleManager(LocaleManager aLocaleManager){
+ mLocaleManager = aLocaleManager;
+ }
+
+ public int compareTo(Object o) {
+ String thisName = getUserObject().toString();
+ String otherString = o.toString();
+ return thisName.compareTo(otherString);
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/Makefile.am b/src/com/sun/apoc/tools/profileeditor/Makefile.am
new file mode 100644
index 0000000..34e56be
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/Makefile.am
@@ -0,0 +1,7 @@
+ANT = @ANT@
+
+all:
+ $(ANT)
+
+clean-local:
+ $(ANT) -q clean
diff --git a/src/com/sun/apoc/tools/profileeditor/PanelFactory.java b/src/com/sun/apoc/tools/profileeditor/PanelFactory.java
new file mode 100644
index 0000000..fe745d0
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/PanelFactory.java
@@ -0,0 +1,218 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor;
+
+import com.sun.apoc.tools.profileeditor.gui.OnlineHelpFrame;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJLabel;
+import com.sun.apoc.tools.profileeditor.gui.SectionPanel;
+import com.sun.apoc.tools.profileeditor.gui.SetPanel;
+import com.sun.apoc.tools.profileeditor.gui.TitledSectionJPanel;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.packages.Template;
+import com.sun.apoc.tools.profileeditor.templates.TemplateCategory;
+import com.sun.apoc.tools.profileeditor.templates.TemplatePage;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+import com.sun.apoc.tools.profileeditor.templates.TemplateSection;
+import com.sun.apoc.tools.profileeditor.templates.TemplateSet;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+
+import javax.swing.*;
+import java.util.Iterator;
+import java.util.List;
+
+public class PanelFactory {
+ private static final boolean DEBUG = false;
+ private final static Dimension SIZE = new Dimension(300,35);
+
+
+ public static JPanel getTemplatePanel(Template template, StandaloneProfileManager aProfileModel, JTree aTree){
+ LocaleManager aLocaleManager = template.getLocaleManager();
+ String aPackageName = template.getPackageName();
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS) );
+
+ // Lock the listModel so it doesnt keep calling
+ // repaints of the summary view
+ aProfileModel.getListModel().setLocked(true);
+ addSections( template, template.getRootCategory(), panel, aProfileModel, aLocaleManager, aPackageName, aTree );
+ aProfileModel.getListModel().setLocked(false);
+ aProfileModel.getListModel().notifyListeners();
+
+ JPanel mainPanel = new JPanel( new BorderLayout() );
+ JPanel spacerPanel = new JPanel();
+ spacerPanel.setBackground( Color.WHITE );
+ mainPanel.add( panel, BorderLayout.PAGE_START );
+ mainPanel.add(spacerPanel, BorderLayout.CENTER);
+
+ return mainPanel;
+ }
+
+
+ private static void addSections(Template template, TemplateCategory category, JPanel mainPanel, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager,String aPackageName, JTree aTree){
+
+ if( category.hasSubCategories() ){
+ String[] keys = category.getKeys();
+
+ for(int i = 0; i < keys.length; i++){
+ addSections( template, category.getSubCategory( keys[i] ), mainPanel, aProfileModel, aLocaleManager, aPackageName, aTree );
+ }
+ }else{
+ List sectionList = ((TemplatePage)category).getSections();
+ mainPanel.add( getInlineHelp(template, (TemplatePage)category, aLocaleManager) );
+ Iterator it = sectionList.iterator();
+ while( it.hasNext() )
+ {
+ Object section = it.next();
+ if( section instanceof TemplateSet ){
+ mainPanel.add( getSetPanel(template, section, aProfileModel, aLocaleManager, aPackageName, aTree ) );
+ }else if( section instanceof TemplateSection ){
+ mainPanel.add( getSectionPanel(template, section, aProfileModel, aLocaleManager, aPackageName) );
+ }
+ }
+ }
+ }
+
+ private static JPanel getSectionPanel(Template template, Object section, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager,String aPackageName){
+
+ TitledSectionJPanel sectionPanel = new TitledSectionJPanel();
+ sectionPanel.setTitleLabel( (TemplateSection)section, aPackageName, aLocaleManager);
+
+ JPanel panel = new SectionPanel( template, (TemplateSection)section, aProfileModel, aLocaleManager, aPackageName );
+ sectionPanel.setContentPanel( panel, true );
+ return sectionPanel;
+ }
+
+ private static JPanel getSetPanel(Template template, Object section, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager,String aPackageName, JTree aTree){
+
+ TitledSectionJPanel sectionPanel = new TitledSectionJPanel();
+ sectionPanel.setTitleLabel((TemplateSet)section, aPackageName, aLocaleManager);
+
+ JPanel panel = new SetPanel(template, (TemplateSet)section, aProfileModel, aLocaleManager, aPackageName, aTree );
+ sectionPanel.setContentPanel( panel, true );
+ return sectionPanel;
+ }
+
+ private static JPanel getInlineHelp(Template template, TemplatePage page, LocaleManager aLocaleManager){
+ File file = template.getTemplateFile();
+ JButton button = null;
+ String helpPath = file.toString();
+ helpPath = helpPath.substring(0, helpPath.indexOf("templates/"));
+ helpPath = helpPath + "web" + page.getHelpFile();
+
+ final String path = helpPath;
+ final LocaleManager locale = aLocaleManager;
+
+ button = new JButton("Online Help");
+ button.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ new OnlineHelpFrame(locale, path);
+ }
+ });
+
+
+ TitledSectionJPanel helpPanel = new TitledSectionJPanel();
+ helpPanel.setTitleLabel(page.getResourceId(), page.getDefaultName(), aLocaleManager);
+ PropertyJLabel inlineHelp = new PropertyJLabel();
+
+ inlineHelp.setResourceId( page.getDescriptionId());
+ inlineHelp.setDefaultName( page.getDescriptionId());
+ inlineHelp.setLocaleManager(aLocaleManager);
+ inlineHelp.update();
+
+ JLabel label = new JLabel("InLine Help: ");
+ label.setMinimumSize(SIZE);
+ label.setPreferredSize(SIZE);
+
+ JPanel contentPanel = new JPanel();
+ contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS));
+ contentPanel.setOpaque(false);
+
+ contentPanel.add(label);
+ contentPanel.add(button);
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BorderLayout());
+ panel.setOpaque(false);
+ panel.add(contentPanel, BorderLayout.LINE_START);
+ panel.add(inlineHelp, BorderLayout.CENTER);
+ helpPanel.setContentPanel(panel, true);
+
+ return helpPanel;
+ }
+
+ private static void printProperties(TemplateSection section)
+ {
+ List list = section.getProperties();
+ Iterator it = list.iterator();
+ while( it.hasNext() ){
+ TemplateProperty property = (TemplateProperty)it.next();
+
+ debug( "\t\tPROPERTY: " + property.getDefaultName() );
+ debug( "\t\t\tChoserPath: " + property.getChooserPath() );
+ debug( "\t\t\tConstraints: " + property.getConstraints() );
+ debug( "\t\t\tDataPath: " + property.getDataPath() );
+ debug( "\t\t\tDataType: " + property.getDataType() );
+ debug( "\t\t\tDefaultValue: " + property.getDefaultValue() );
+ debug( "\t\t\tDescriptionId: " + property.getDescriptionId() );
+ debug( "\t\t\tExtendsChooser: " + property.getExtendsChooser() );
+ debug( "\t\t\tExtraData: " + property.getExtraData() );
+ debug( "\t\t\tExtraHtml: " + property.getExtraHtml() );
+ debug( "\t\t\tLabelPopup: " + property.getLabelPopup() );
+ debug( "\t\t\tLabelPost: " + property.getLabelPost() );
+ debug( "\t\t\tResourceBundle: " + property.getResourceBundle() );
+ debug( "\t\t\tResourceId: " + property.getResourceId() );
+ debug( "\t\t\tSeperator: " + property.getSeparator() );
+ debug( "\t\t\tVisualType: " + property.getVisualType() );
+ debug( "\t\t\tXmlHandler: " + property.getXmlHandler() );
+ }
+ }
+
+ private static void debug(String msg){
+ if(DEBUG){
+ System.out.println(msg);
+ }
+ }
+
+}//end Class
diff --git a/src/com/sun/apoc/tools/profileeditor/PreferenceNotifier.java b/src/com/sun/apoc/tools/profileeditor/PreferenceNotifier.java
new file mode 100644
index 0000000..dba6a2e
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/PreferenceNotifier.java
@@ -0,0 +1,50 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+/**
+ *
+ * @author cs202741
+ */
+public interface PreferenceNotifier {
+
+ void attach(PreferenceSubscriber sub);
+
+ void detach(PreferenceSubscriber sub);
+
+ void notifySubscribers();
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/PreferenceSubscriber.java b/src/com/sun/apoc/tools/profileeditor/PreferenceSubscriber.java
new file mode 100644
index 0000000..c25900d
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/PreferenceSubscriber.java
@@ -0,0 +1,46 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+/**
+ *
+ * @author cs202741
+ */
+public interface PreferenceSubscriber {
+
+ void update();
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/ProfileEditor.java b/src/com/sun/apoc/tools/profileeditor/ProfileEditor.java
new file mode 100644
index 0000000..f03a914
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/ProfileEditor.java
@@ -0,0 +1,763 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.tools.profileeditor.gui.AboutFrame;
+import com.sun.apoc.tools.profileeditor.gui.ErrorPanel;
+import com.sun.apoc.tools.profileeditor.gui.GeneralPropertiesPanel;
+import com.sun.apoc.tools.profileeditor.gui.GradientJPanel;
+import com.sun.apoc.tools.profileeditor.gui.GradientTabPaneUI;
+import com.sun.apoc.tools.profileeditor.gui.SetPanel;
+import com.sun.apoc.tools.profileeditor.gui.SetSubPanel;
+import com.sun.apoc.tools.profileeditor.gui.SummaryJPanel;
+import com.sun.apoc.tools.profileeditor.gui.TitledSectionJPanel;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.gui.PreferencesJPanel;
+import com.sun.apoc.tools.profileeditor.gui.PropertyComponent;
+import com.sun.apoc.tools.profileeditor.gui.ImageButton;
+import com.sun.apoc.tools.profileeditor.gui.InfoPanel;
+import com.sun.apoc.tools.profileeditor.gui.ProfileEditorJMenuBar;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJListModel;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJListPanel;
+import com.sun.apoc.tools.profileeditor.packages.*;
+import com.sun.apoc.tools.profileeditor.templates.TemplateCategory;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+import java.util.Vector;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JSplitPane;
+
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.UIManager;
+import javax.swing.event.*;
+import javax.swing.JButton;
+import javax.swing.JTree;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JFileChooser;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeSelectionModel;
+
+
+public class ProfileEditor extends JFrame implements WindowListener{
+
+ public static final String VERSION = "0.12";
+
+ public static final String PREFERENCES = "preferences.cfg";
+ public static final int buttonHeight = 42;
+ public static final int infoHeight = 20;
+ public static final int centerHeight = 600;
+ public static final int outputHeight = 240;
+ public static final int windowHeight = buttonHeight + infoHeight + centerHeight + outputHeight;
+
+ public static final int leftWidth = 220;
+ public static final int centerWidth = 640;
+ public static final int rightWidth = 240;
+ public static final int windowWidth = leftWidth + centerWidth + rightWidth;
+
+ private JPanel contentPanel, outputPanel, mPropertyListPanel;
+ private GeneralPropertiesPanel mGeneralProperties = null;
+ private SummaryJPanel summaryPanel;
+ private JSplitPane mainSplitPane;
+ private JScrollPane contentScrollPane, treeScrollPane;
+ private JComboBox localeComboBox;
+ private JLabel profileLabel;
+ private JTabbedPane mTabbedPane = null;
+ private JTree mTemplateTree = null;
+ private JButton btnSave = null;
+
+ private LocaleManager mLocaleManager = null;
+ private ProfileEditorPreferences mPreferences = null;
+ private StandaloneProfileManager mProfileManager = null;
+ private PropertyJListModel mListModel = null;
+ private PackageManager mPackageManager = null;
+
+ private String mLocale = Locale.getDefault().toString();
+ private String mProfilePath = "";
+ private File mPackagePath = null;
+
+ private Vector mLastSave = null;
+
+
+ public ProfileEditor(){
+ super("Profile Editor");
+ makeFrame();
+ loadPreferences();
+
+ mLocaleManager = new LocaleManager();
+ mLocaleManager.setPreferences( mPreferences );
+ mLocaleManager.setLocale( Locale.getDefault().toString() );
+ mListModel = new PropertyJListModel(this);
+ mProfileManager = new StandaloneProfileManager(mListModel);
+ summaryPanel = new SummaryJPanel(mLocaleManager);
+ mListModel.addListDataListener( summaryPanel );
+
+ this.getContentPane().add( getTopPanel() ,BorderLayout.NORTH);
+ //this.getContentPane().add( mainSplitPane, BorderLayout.CENTER );
+ this.getContentPane().add( getContentTabbedPane(), BorderLayout.CENTER);
+
+ this.pack();
+
+ openPackage( mPreferences.getProperty( "templatePackagePath" ) );
+ }
+
+
+ private JPanel getContentTabbedPane(){
+ JPanel panel = new JPanel( new BorderLayout() );
+ mTabbedPane = new JTabbedPane();
+ mTabbedPane.setUI( new GradientTabPaneUI() );
+
+ contentPanel = new JPanel( new BorderLayout() );
+ contentPanel.setBackground( Color.WHITE );
+ contentScrollPane = new JScrollPane(contentPanel);
+
+ mainSplitPane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, getTreeScrollPane(), contentScrollPane );
+ mainSplitPane.setDividerSize(4);
+ mainSplitPane.setDividerLocation(200);
+
+ JScrollPane summaryScrollPane = new JScrollPane( summaryPanel );
+ mGeneralProperties = new GeneralPropertiesPanel(this, mProfileManager);
+ mTabbedPane.add( "General Properties", mGeneralProperties );
+ mTabbedPane.add( "Configuration Settings", mainSplitPane );
+ mTabbedPane.add( "Settings Summary", summaryScrollPane );
+ mTabbedPane.add( "Info", new InfoPanel() );
+ mTabbedPane.add( "Errors", new ErrorPanel() );
+
+ panel.add( mTabbedPane, BorderLayout.CENTER );
+ return panel;
+ }
+
+
+ private JPanel getTopPanel(){
+ JPanel topPanel = new JPanel(new BorderLayout());
+ //topPanel.setLayout( new BoxLayout( topPanel, BoxLayout.PAGE_AXIS ) );
+ topPanel.add( getImageButtonPanel(), BorderLayout.PAGE_START );
+ topPanel.add( getInfoPanel(), BorderLayout.PAGE_END );
+
+ return topPanel;
+ }
+
+
+ public JScrollPane getTreeScrollPane(){
+
+ treeScrollPane = new JScrollPane();
+ treeScrollPane.setPreferredSize( new Dimension( leftWidth, centerHeight));
+
+ return treeScrollPane;
+ }
+
+
+ public void createJTree(DefaultMutableTreeNode node){
+
+ Icon leafIcon = new ImageIcon( "images/tree_document.gif");
+ Icon parentIcon = new ImageIcon( "images/tree_folder.gif");
+
+ UIManager.put("Tree.collapsedIcon",new ImageIcon("images/tree_closed.gif"));
+ UIManager.put("Tree.expandedIcon",new ImageIcon("images/tree_open.gif"));
+
+ mTemplateTree = new JTree( node );
+ mTemplateTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+ DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer)mTemplateTree.getCellRenderer();
+
+ mTemplateTree.putClientProperty("JTree.lineStyle", "None");
+
+ renderer.setTextNonSelectionColor(new Color( 0x405661 ));
+ renderer.setTextSelectionColor(new Color( 0x405661 ));
+ renderer.setLeafIcon(leafIcon);
+ renderer.setOpenIcon( parentIcon );
+ renderer.setClosedIcon( parentIcon );
+
+ mTemplateTree.addTreeSelectionListener( new TreeListener() );
+ mTemplateTree.addMouseListener( new TreeMouseListener() );
+ treeScrollPane.setViewportView( mTemplateTree );
+ }
+
+
+ private JPanel getListPanel(){
+ mPropertyListPanel = new PropertyJListPanel(mListModel);
+ return mPropertyListPanel;
+ }//end getListPanel()
+
+
+ private JPanel getOutputPanel(){
+ outputPanel = new InfoPanel();
+ return outputPanel;
+ }//end getOutputPanel()
+
+
+ private JPanel getInfoPanel(){
+ //JPanel panel = new JPanel();
+ GradientJPanel panel = new GradientJPanel(new Color(0xCBCFD5), new Color(0xFFFFFF),
+ GradientJPanel.ROUNDED_NONE, 0, 0);
+
+ panel.setLayout( new FlowLayout(FlowLayout.LEFT) );
+ profileLabel = new JLabel("Current Profile: ");
+ panel.add( profileLabel );
+
+ return panel;
+ }//end getInfoPanel()
+
+
+ private JPanel getImageButtonPanel(){
+
+ ActionListener listener = new ButtonListener();
+
+ GradientJPanel mainPanel = new GradientJPanel(new Color(0xCBCFD5), new Color(0xFFFFFF),
+ GradientJPanel.ROUNDED_NONE, 20, 5);
+ mainPanel.setLayout( new BorderLayout() );
+
+ JPanel buttonPanel = new JPanel( new FlowLayout(FlowLayout.LEFT ) );
+ buttonPanel.setOpaque(false);
+ JPanel localePanel = new JPanel( new FlowLayout( FlowLayout.RIGHT) );
+ localePanel.setOpaque(false);
+
+ JButton btnNew = new ImageButton( new ImageIcon("images/new.png") );
+ JButton btnOpen = new ImageButton( new ImageIcon("images/open.png") );
+ btnSave = new ImageButton( new ImageIcon("images/save.png") );
+ JButton btnSaveAs = new ImageButton( new ImageIcon("images/save_as.png") );
+ JButton btnPreferences = new ImageButton( new ImageIcon("images/preferences.png") );
+
+ btnNew.setActionCommand("New");
+ btnOpen.setActionCommand("OpenProfile");
+ btnSave.setActionCommand("Save");
+ btnSaveAs.setActionCommand("SaveAs");
+ btnPreferences.setActionCommand("Preferences");
+
+ btnNew.addActionListener( listener );
+ btnOpen.addActionListener( listener );
+ btnSave.addActionListener( listener );
+ btnSaveAs.addActionListener( listener );
+ btnPreferences.addActionListener( listener );
+
+ btnNew.setToolTipText("Create New Profile");
+ btnOpen.setToolTipText("Open Profile");
+ btnSave.setToolTipText("Save Profile");
+ btnSaveAs.setToolTipText("Save Profile As");
+ btnPreferences.setToolTipText("Preferences");
+
+
+ String locales = mPreferences.getProperty("defaultLocales");
+ String userLocales = mPreferences.getProperty("userLocales");
+ if( userLocales != null ){
+ locales += "," + userLocales;
+ }
+ String[] splitLocales = locales.split(",");
+ localeComboBox = new JComboBox(splitLocales);
+ localeComboBox.setSelectedItem( Locale.getDefault().toString() );
+ localeComboBox.setActionCommand("localeChange");
+ localeComboBox.addActionListener( new ButtonListener() );
+
+ //panel.setPreferredSize( new Dimension(windowWidth, buttonHeight) );
+ buttonPanel.add(btnNew);
+ buttonPanel.add(btnOpen);
+ buttonPanel.add(btnSave);
+ buttonPanel.add(btnSaveAs);
+ buttonPanel.add(btnPreferences);
+
+ localePanel.add( new JLabel(" Locale:") );
+ localePanel.add(localeComboBox);
+
+ mainPanel.add( buttonPanel, BorderLayout.LINE_START );
+ mainPanel.add( localePanel, BorderLayout.LINE_END );
+
+ return mainPanel;
+ }//end getButtonPanel()
+
+
+
+ public void makeFrame(){
+ this.setJMenuBar( new ProfileEditorJMenuBar( new ButtonListener() ) );
+ this.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
+ this.addWindowListener( this );
+ this.setLayout( new BorderLayout() );
+ this.setExtendedState(this.MAXIMIZED_BOTH );
+ this.setVisible(true);
+ } // makeFrame
+
+
+ private void openPackage(String packagePath){
+
+ if( packagePath == null ){
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
+ chooser.setDialogTitle("Select a Package directory.");
+ int returnVal = chooser.showOpenDialog(this);
+
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = chooser.getSelectedFile();
+ mPackagePath = file;
+ mPreferences.setProperty( "templatePackagePath", file.toString() );
+ try{
+ mPreferences.store();
+ }catch(IOException e){}
+ }else
+ return;
+ }else{
+ mPackagePath = new File(packagePath);
+ }
+
+ SwingWorker worker = new SwingWorker(){
+ @Override
+ public Object construct() {
+ openPackage();
+ return "done";
+ }
+ };
+ worker.start();
+
+ }//end openPackage()
+
+
+ public void openPackage(){
+
+ mListModel.removeAll();
+ contentPanel.removeAll();
+ contentPanel.revalidate();
+ contentPanel.repaint();
+ mPackageManager = new PackageManager( mPackagePath, mProfileManager, mLocaleManager );
+
+ try {
+ mPackageManager.initialize();
+ } catch (FileNotFoundException ex) {
+ JOptionPane.showMessageDialog(
+ null,
+ "Error: Invalid package directory:\n",
+ "Invalid Package Directory!",
+ JOptionPane.ERROR_MESSAGE);
+ openPackage(null);
+ }
+
+ createJTree( mPackageManager.getRootTreeNode() );
+ this.setTitle( "Profile Editor - " );
+
+ }//end openPackage(File)
+
+
+ public void updateTemplate(JPanel aPanel){
+ contentPanel.removeAll();
+ contentPanel.add(aPanel, BorderLayout.CENTER);
+ contentPanel.revalidate();
+ contentPanel.repaint();
+ }
+
+
+ public void updateSavedState(){
+
+ if( changedSinceSave() ){
+ this.setTitle( "Profile Editor - " + mProfilePath + " *CHANGED");
+ }else {
+ this.setTitle( "Profile Editor - " + mProfilePath );
+ }
+ }
+
+
+ public void saveProfile(){
+
+ if( changedSinceSave() ){
+ if( !mProfileManager.exists() ){
+ createNewProfileRepository();
+ }
+ Enumeration e = mListModel.elements();
+ while( e.hasMoreElements() ){
+ ((PropertyComponent)e.nextElement()).saveProperty();
+ }
+ mGeneralProperties.applyChanges();
+ mProfileManager.writeChanges();
+ mLastSave = (Vector)mListModel.getPropertyVector();
+ updateSavedState();
+ }else{
+ //JOptionPane.showMessageDialog(this, "Nothing to save!", "Warning!", JOptionPane.WARNING_MESSAGE);
+ }
+
+ }//end saveProfile()
+
+
+ private void saveProfileAs(){
+
+ if( changedSinceSave() ){
+ if( createNewProfileRepository() ){
+ saveProfile();
+ }
+ }else{
+ JOptionPane.showMessageDialog(this, "Nothing to save!", "Warning!", JOptionPane.WARNING_MESSAGE);
+ }
+
+ }//end saveProfileAs()
+
+
+ private boolean changedSinceSave(){
+ boolean changed = true;
+
+ if( mLastSave == null && mListModel.getSize() > 0 ){
+ return changed;
+ }
+
+ if( mLastSave == null && mListModel.getSize() == 0 ){
+ if( mGeneralProperties.hasChanged() ){
+ return changed;
+ }else {
+ return false;
+ }
+ }
+
+ if( mLastSave.size() != mListModel.getSize() ){
+ return changed;
+ }
+
+ if( mGeneralProperties.hasChanged() ){
+ return changed;
+ }
+
+ HashSet savedSet = new HashSet();
+ HashSet currentSet = new HashSet();
+
+ Enumeration e = mListModel.elements();
+ while(e.hasMoreElements()){
+ PropertyComponent propComp = (PropertyComponent)e.nextElement();
+ currentSet.add( propComp.getDataPath() + propComp.getValue() );
+ }
+
+ e = mLastSave.elements();
+ while(e.hasMoreElements()){
+ PropertyComponent oldProp = (PropertyComponent)e.nextElement();
+ savedSet.add( oldProp.getDataPath() + oldProp.getValue() );
+ }
+
+
+ if( savedSet.equals(currentSet) ){
+ changed = false;
+ }
+
+ return changed;
+ }
+
+
+ private boolean createNewProfileRepository(){
+ File file;
+
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogType( JFileChooser.SAVE_DIALOG );
+ chooser.setDialogTitle("Save Profile");
+ chooser.setSelectedFile( new File( mProfileManager.getDisplayName() ));
+
+ int returnVal = chooser.showSaveDialog(this);
+
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ file = chooser.getSelectedFile();
+ String name = file.getName();
+
+ String path = file.getPath();
+ String url = "file://" + path.substring( 0, path.length() - name.length() );
+ try {
+ mProfileManager.destroyProfile();
+ mProfileManager.createProfile( file.getName(), url);
+ mGeneralProperties.applyChanges();
+ mProfilePath = url + name;
+ profileLabel.setText( "Current Profile - " + mProfilePath);
+ this.setTitle( "Profile Editor - " + mProfilePath);
+ return true;
+ } catch (SPIException ex) {
+ ex.printStackTrace();
+ System.err.println("Could not create profile!");
+ }
+ }
+
+ return false;
+
+ }//end createNewProfile()
+
+ private void openProfile(){
+
+ if( mPackageManager.isOpen() ){
+ File file;
+
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogTitle("Open Profile");
+
+ int returnVal = chooser.showOpenDialog(this);
+
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ file = chooser.getSelectedFile();
+ String name = file.getName();
+ String path = file.getPath();
+ String url = "file://" + path.substring( 0, path.length() - name.length() );
+
+ try {
+ mProfileManager.openProfile(name, url, mPackageManager, mLocaleManager, mTemplateTree);
+ mGeneralProperties.update();
+ mPackageManager.clearTemplatePanels();
+ treeClicked();
+ mLastSave = (Vector)mListModel.getPropertyVector();
+ profileLabel.setText( "Current Profile - " + url + name);
+ this.setTitle( "Profile Editor - " + url + name);
+ } catch (SPIException ex) {
+ JOptionPane.showMessageDialog(this, "Could not open profile!", "Error!", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }else{
+ JOptionPane.showMessageDialog(this, "You must open a package location first!", "No Packages Open!", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ private void newProfile(){
+
+ if( mListModel.getSize() > 0 && changedSinceSave() ){
+ int val = JOptionPane.showConfirmDialog(this, "The existing Profile has unsaved changes.\n" +
+ "Do you want to save the changes before continuing?",
+ "Warning!",
+ JOptionPane.YES_NO_CANCEL_OPTION);
+
+ if( val == JOptionPane.OK_OPTION ){
+ saveProfile();
+ closeProfile();
+ }else if( val == JOptionPane.NO_OPTION ){
+ closeProfile();
+ }else
+ return;
+ }else
+ closeProfile();
+ }
+
+
+ private void closeProfile(){
+ try {
+ mPackageManager.removeSets();
+
+ mListModel.removeAll();
+ mProfileManager.destroyProfile();
+ mGeneralProperties.reset();
+ mPackageManager.clearTemplatePanels();
+ mProfilePath = "";
+ treeClicked();
+ profileLabel.setText( "Current Profile - ");
+ this.setTitle( "Profile Editor");
+ mTemplateTree.revalidate();
+ mTemplateTree.repaint();
+ } catch (SPIException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+
+ private void loadPreferences(){
+ mPreferences = new ProfileEditorPreferences();
+ try{
+ mPreferences.load();
+ }catch(IOException e){System.out.println("Could not Load Default Preferences");}
+ }
+
+
+ public String getCurrentLocale(){
+ return mLocale;
+ }
+
+ public void openTemplate(Template template){
+
+ }
+
+ private void shutDown(){
+
+ if( mListModel.getSize() != 0 && changedSinceSave() ){
+ int result = JOptionPane.showConfirmDialog(
+ this,
+ "Would you like to save your profile before exiting?",
+ "Save Profile?",
+ JOptionPane.YES_NO_OPTION);
+ if( result == JOptionPane.YES_OPTION ){
+ saveProfile();
+ }
+ }
+ System.exit(0);
+ }
+
+
+ private void treeClicked(){
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)
+ mTemplateTree.getLastSelectedPathComponent();
+
+ if (node == null) return;
+
+ Object obj = node.getUserObject();
+ if( obj instanceof Template ){
+ Template template = (Template)node.getUserObject();
+ updateTemplate( mPackageManager.getTemplatePanel( template, mLocale, mTemplateTree ) );
+ }else if( obj instanceof SetSubPanel ){
+ updateTemplate( (JPanel)obj );
+ }else if( obj instanceof TitledSectionJPanel ){
+ updateTemplate( (JPanel)obj );
+ }
+ }
+
+
+ public static void main(String [] argv){
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ new ProfileEditor();
+ }
+ });
+ }
+
+ public void windowOpened(WindowEvent e) {
+ }
+
+ public void windowClosing(WindowEvent e) {
+ shutDown();
+ }
+
+ public void windowClosed(WindowEvent e) {
+ }
+
+ public void windowIconified(WindowEvent e) {
+ }
+
+ public void windowDeiconified(WindowEvent e) {
+ }
+
+ public void windowActivated(WindowEvent e) {
+ }
+
+ public void windowDeactivated(WindowEvent e) {
+ }
+
+
+ public class ButtonListener implements ActionListener {
+
+ public void actionPerformed(ActionEvent event){
+
+ if( event.getActionCommand().equals("New") ){
+ newProfile();
+ }else if( event.getActionCommand().equals("OpenProfile") ){
+ openProfile();
+ }else if( event.getActionCommand().equals("OpenPackage") ){
+ openPackage( null );
+ }else if( event.getActionCommand().equals("Save") ){
+ saveProfile();
+ }else if( event.getActionCommand().equals("SaveAs") ){
+ saveProfileAs();
+ }else if( event.getActionCommand().equals("Preferences") ){
+ mTabbedPane.add( "Preferences", new PreferencesJPanel( mPreferences, mTabbedPane ) );
+ mTabbedPane.setSelectedIndex( mTabbedPane.getComponentCount() - 1 );
+ }else if( event.getActionCommand().equals("localeChange") ){
+ mLocale = ((JComboBox)event.getSource()).getSelectedItem().toString();
+ mLocaleManager.setLocale( mLocale );
+ mTemplateTree.repaint();
+ }else if( event.getActionCommand().equals("Exit") ){
+ shutDown();
+ }else if( event.getActionCommand().equals("About") ){
+ new AboutFrame();
+ }
+ }
+
+ }//end ButtonListener
+
+
+ public class TreeListener implements TreeSelectionListener {
+
+ public void valueChanged(TreeSelectionEvent e) {
+
+ SwingWorker worker = new SwingWorker(){
+ @Override
+ public Object construct() {
+ treeClicked();
+ return "done";
+ }
+ };
+ worker.start();
+ }
+ }//
+
+ public class TreeMouseListener implements MouseListener {
+ public void mouseClicked(MouseEvent e) {
+ if( e.getClickCount() == 2 ){
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)
+ mTemplateTree.getLastSelectedPathComponent();
+
+ if (node == null) return;
+
+ if (node.isLeaf()) {
+ try{
+ Template template = (Template)node.getUserObject();
+ openTemplate( template );
+ }catch(ClassCastException cce){
+ System.out.println(cce);
+ }
+ }
+ }
+ }
+
+ public void mousePressed(MouseEvent e) {
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ public void mouseExited(MouseEvent e) {
+ }
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/ProfileEditorPreferences.java b/src/com/sun/apoc/tools/profileeditor/ProfileEditorPreferences.java
new file mode 100644
index 0000000..324bc88
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/ProfileEditorPreferences.java
@@ -0,0 +1,124 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+/**
+ *
+ * @author cs202741
+ */
+public class ProfileEditorPreferences extends Properties implements PreferenceNotifier{
+ private final String PREFERENCE_FILE = "preferences.cfg";
+ private final String PREFERENCE_DIR = ".profileeditor";
+ private final String DEFAULT_LOCALES = "de,en,en_US,es,fr,ja,ko,zh_CN,zh_TW";
+
+ private FileInputStream in = null;
+ private FileOutputStream out = null;
+
+ private ArrayList<PreferenceSubscriber> mSubscribers = null;
+
+ /** Creates a new instance of ProfileEditorPreferences */
+ public ProfileEditorPreferences() {
+ super();
+ mSubscribers = new ArrayList();
+ verifyDefaults();
+ }
+
+ public void load() throws IOException {
+ String prefFile = System.getProperty("user.home") + File.separator + PREFERENCE_DIR + File.separator + PREFERENCE_FILE;
+
+ File file = new File(prefFile);
+ if( file.exists() ){
+ in = new FileInputStream( prefFile );
+ super.load( in );
+ in.close();
+ verifyDefaults();
+ notifySubscribers();
+ }
+
+ }
+
+ public void store() throws IOException {
+ String prefDir = System.getProperty("user.home") + File.separator + PREFERENCE_DIR;
+
+ File dir = new File(prefDir);
+ if( !dir.exists() ){
+ if( !dir.mkdirs() ){
+ System.err.println("Could not create directory: " + prefDir + "!");
+ prefDir = PREFERENCE_FILE;
+ }
+ }
+
+ if(dir.canWrite()){
+ out = new FileOutputStream( prefDir + File.separator + PREFERENCE_FILE );
+ super.store( out, "ProfileEditor Default Preferences");
+ out.close();
+ notifySubscribers();
+ }else{
+ System.err.println("Cannot write to: " + dir.toString());
+ }
+ }
+
+ private void verifyDefaults(){
+
+ if( this.getProperty( "defaultLocales" ) == null ){
+ this.setProperty("defaultLocales", DEFAULT_LOCALES);
+ }
+ }
+
+ public void attach(PreferenceSubscriber sub) {
+ mSubscribers.add( sub );
+ }
+
+ public void detach(PreferenceSubscriber sub) {
+ mSubscribers.remove( sub );
+ }
+
+ public void notifySubscribers() {
+ Iterator it = mSubscribers.iterator();
+ while( it.hasNext() ){
+ ((PreferenceSubscriber)it.next()).update();
+ }
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/PropertyComponentDummy.java b/src/com/sun/apoc/tools/profileeditor/PropertyComponentDummy.java
new file mode 100644
index 0000000..b875c28
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/PropertyComponentDummy.java
@@ -0,0 +1,295 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.cfgtree.property.ReadWritePropertyImpl;
+import com.sun.apoc.tools.profileeditor.gui.PropertyComponent;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJListModel;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyComponentDummy implements PropertyComponent, Subscriber {
+
+ // PropertyComponent Variables
+ private boolean mIsSet = false;
+ private String mResourceId = null;
+ private String mDefaultName = null;
+ private String mDataType = null;
+ private String mSectionName = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefaultValue = null;
+ private String mValue = null;
+ private String mLabel = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileManager = null;
+
+ private TemplateProperty mProperty = null;
+
+ // Subscriber Interface
+ private LocaleManager mLocaleManage = null;
+
+
+ /** Creates a new instance of PropertyComponentDummy */
+ public PropertyComponentDummy(String aDataPath, ReadWritePropertyImpl aProperty) throws SPIException {
+ mDataPath = aDataPath;
+ mSeperator = aProperty.getSeparator();
+ mDataType = aProperty.getDataType().getStringValue();
+ mValue = aProperty.getValue();
+ }
+
+ public void cloneTemplateProperty(TemplateProperty aProperty){
+ setChooserPath( aProperty.getChooserPath() );
+ setDefaultName( aProperty.getDefaultName() );
+ setDefaultValue( aProperty.getDefaultValue() );
+ setDescriptionId( aProperty.getDescriptionId() );
+ setExtendsChooser( aProperty.getExtendsChooser() );
+ setPath( aProperty.getPath() );
+ setResourceId( aProperty.getResourceId() );
+ setResourceIdPath( aProperty.getResourceIdPath() );
+ setVisualType( aProperty.getVisualType() );
+ }
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+
+ public void setDataType(String aDataType) {
+ mDataType = aDataType;
+ }
+
+ public String getDataType() {
+ return mDataType;
+ }
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType) {
+ mVisualType = aVisualType;
+ }
+
+ public String getVisualType() {
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath) {
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath() {
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault) {
+ mDefaultValue = aDefault;
+ }
+
+ public String getDefaultValue() {
+ return mDefaultValue;
+ }
+
+ public void setValue(String aValue) {
+ mValue = aValue;
+ }
+
+ public String getValue() {
+ return mValue;
+ }
+
+ public void setLabel(String aLabel) {
+ mLabel = aLabel;
+ }
+
+ public String getLabel() {
+
+ if( mLabel != null ){
+ return mLabel;
+ }
+
+ if( getVisualType().equals("checkBox") ){
+ if( getValue().equals("true") ){
+ return "Enabled";
+ }else{
+ return "Disabled";
+ }
+ }
+
+ return getValue();
+ }
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+
+ public void checkForLoadedProperty() {
+ }
+
+ public boolean hasChanged() {
+ return true;
+ }
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel) {
+ mProfileManager = aProfileModel;
+ }
+
+ public void saveProperty() {
+ if( hasChanged() ){
+ mProfileManager.createProperty( this );
+ }
+ }
+
+ public PropertyJListModel getListModel() {
+ return mProfileManager.getListModel();
+ }
+
+ public void reset() {
+ mProfileManager.removeProperty( this );
+ PropertyJListModel model = getListModel();
+ model.removeItem( this );
+ }
+
+
+ //
+ // Used so we can get the constraints of the property to
+ // localize its value in Summary View.
+ //
+ public void setTemplateProperty(TemplateProperty prop){
+ mProperty = prop;
+ }
+
+
+ public TemplateProperty getTemplateProperty(){
+ return mProperty;
+ }
+
+
+ //
+ // Subscriber interface methods
+ //
+ public void setPackageName(String aPackageName) {
+ }
+
+ public void setLocaleManager(LocaleManager aLocaleManager) {
+ mLocaleManage = aLocaleManager;
+ aLocaleManager.attach( this );
+ update();
+ }
+
+ public void update() {
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/Subscriber.java b/src/com/sun/apoc/tools/profileeditor/Subscriber.java
new file mode 100644
index 0000000..7a290f1
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/Subscriber.java
@@ -0,0 +1,54 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor;
+
+/**
+ *
+ * @author cs202741
+ */
+public interface Subscriber {
+
+ void setPackageName(String aPackageName);
+
+ void setResourceId(String aResourceId);
+
+ void setDefaultName(String aDefaultName);
+
+ void setLocaleManager(LocaleManager aLocaleManager);
+
+ void update();
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/SwingWorker.java b/src/com/sun/apoc/tools/profileeditor/SwingWorker.java
new file mode 100644
index 0000000..cb34923
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/SwingWorker.java
@@ -0,0 +1,165 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor;
+
+import javax.swing.SwingUtilities;
+
+/**
+ * This is the 3rd version of SwingWorker (also known as
+ * SwingWorker 3), an abstract class that you subclass to
+ * perform GUI-related work in a dedicated thread. For
+ * instructions on and examples of using this class, see:
+ *
+ * http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
+ *
+ * Note that the API changed slightly in the 3rd version:
+ * You must now invoke start() on the SwingWorker after
+ * creating it.
+ */
+public abstract class SwingWorker {
+ private Object value; // see getValue(), setValue()
+
+ /**
+ * Class to maintain reference to current worker thread
+ * under separate synchronization control.
+ */
+ private static class ThreadVar {
+ private Thread thread;
+ ThreadVar(Thread t) { thread = t; }
+ synchronized Thread get() { return thread; }
+ synchronized void clear() { thread = null; }
+ }
+
+ private ThreadVar threadVar;
+
+ /**
+ * Get the value produced by the worker thread, or null if it
+ * hasn't been constructed yet.
+ */
+ protected synchronized Object getValue() {
+ return value;
+ }
+
+ /**
+ * Set the value produced by worker thread
+ */
+ private synchronized void setValue(Object x) {
+ value = x;
+ }
+
+ /**
+ * Compute the value to be returned by the <code>get</code> method.
+ */
+ public abstract Object construct();
+
+ /**
+ * Called on the event dispatching thread (not on the worker thread)
+ * after the <code>construct</code> method has returned.
+ */
+ public void finished() {
+ }
+
+ /**
+ * A new method that interrupts the worker thread. Call this method
+ * to force the worker to stop what it's doing.
+ */
+ public void interrupt() {
+ Thread t = threadVar.get();
+ if (t != null) {
+ t.interrupt();
+ }
+ threadVar.clear();
+ }
+
+ /**
+ * Return the value created by the <code>construct</code> method.
+ * Returns null if either the constructing thread or the current
+ * thread was interrupted before a value was produced.
+ *
+ * @return the value created by the <code>construct</code> method
+ */
+ public Object get() {
+ while (true) {
+ Thread t = threadVar.get();
+ if (t == null) {
+ return getValue();
+ }
+ try {
+ t.join();
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt(); // propagate
+ return null;
+ }
+ }
+ }
+
+
+ /**
+ * Start a thread that will call the <code>construct</code> method
+ * and then exit.
+ */
+ public SwingWorker() {
+ final Runnable doFinished = new Runnable() {
+ public void run() { finished(); }
+ };
+
+ Runnable doConstruct = new Runnable() {
+ public void run() {
+ try {
+ setValue(construct());
+ }
+ finally {
+ threadVar.clear();
+ }
+
+ SwingUtilities.invokeLater(doFinished);
+ }
+ };
+
+ Thread t = new Thread(doConstruct);
+ threadVar = new ThreadVar(t);
+ }
+
+ /**
+ * Start the worker thread.
+ */
+ public void start() {
+ Thread t = threadVar.get();
+ if (t != null) {
+ t.start();
+ }
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/XMLFileFilter.java b/src/com/sun/apoc/tools/profileeditor/XMLFileFilter.java
new file mode 100644
index 0000000..a1862f0
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/XMLFileFilter.java
@@ -0,0 +1,76 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor;
+import java.io.File;
+import javax.swing.*;
+import javax.swing.filechooser.*;
+
+
+public class XMLFileFilter extends FileFilter {
+
+ public boolean accept(File f) {
+ if (f.isDirectory()) {
+ return true;
+ }
+
+ String extension = getExtension(f);
+ if (extension != null) {
+ if ( extension.equalsIgnoreCase("xml") ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ return false;
+ }
+
+ //The description of this filter
+ public String getDescription() {
+ return "XML files";
+ }
+
+
+ public String getExtension(File f) {
+ String ext = null;
+ String s = f.getName();
+ int i = s.lastIndexOf('.');
+
+ if (i > 0 && i < s.length() - 1) {
+ ext = s.substring(i+1).toLowerCase();
+ }
+ return ext;
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/build.xml.in b/src/com/sun/apoc/tools/profileeditor/build.xml.in
new file mode 100644
index 0000000..dc62b7a
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/build.xml.in
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+#*************************************************************************
+#*
+#* $RCSfile: build.xml,v $
+#*
+#* last change $Author: cm122549 $ $Date: 2007/01/18 12:55:19 $
+#* $Revision: 1.12 $
+#*
+#* Copyright 2004, Sun Microsystems, Inc. All Rights Reserved.
+#*
+#*************************************************************************
+-->
+<project name="apoc_profile_editor" default="main" basedir="../../../../../../">
+
+ <property name="jarname" value="apoc_peditor.jar"/>
+ <property name="package" value="com/sun/apoc/tools/profileeditor"/>
+
+ <!-- The name of the out/dist directory (e.g. "out" or "unxsols4.pro") -->
+ <property name="inpath" value="build"/>
+ <property name="build.dir" value="${inpath}"/>
+ <property name="build.class" value="${build.dir}/class"/>
+ <!--property name="build.doc" value="${build.dir}/doc/profileeditor"/-->
+
+ <path id="classpath">
+ <pathelement location="@SPIJDK@"/>
+ </path>
+
+ <target name="prepare">
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.class}"/>
+ </target>
+
+ <target name="compile" depends="prepare">
+ <javac srcdir="src"
+ destdir="${build.class}"
+ classpathref="classpath"
+ debug="${debug}">
+ <include name="${package}/*/*.java"/>
+ <include name="${package}/*.java"/>
+ </javac>
+ </target>
+
+ <target name="jar" depends="compile">
+ <jar jarfile="${build.class}/${jarname}"
+ basedir="${build.class}">
+ <include name="${package}/*/*"/>
+ <include name="${package}/*"/>
+ <manifest>
+ <attribute name="Main-Class" value="com.sun.apoc.tools.profileeditor.ProfileEditor"/>
+ <attribute name="Class-Path" value="@SPIJDK@"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="main" depends="jar"/>
+
+ <target name="clean">
+ <delete file="${build.class}/${jarname}"/>
+ <delete dir="${build.class}/${package}"/>
+ </target>
+
+</project>
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/AboutFrame.java b/src/com/sun/apoc/tools/profileeditor/gui/AboutFrame.java
new file mode 100644
index 0000000..0b0a309
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/AboutFrame.java
@@ -0,0 +1,104 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.ProfileEditor;
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.GraphicsEnvironment;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author cs202741
+ */
+public class AboutFrame extends JFrame implements ActionListener{
+ private static final int WIDTH = 300;
+ private static final int HEIGHT = 250;
+ private JPanel contentPanel = null;
+
+ /** Creates a new instance of AboutPanel */
+ public AboutFrame() {
+ super("About Profile Editor");
+ contentPanel = new JPanel(new BorderLayout());
+ this.setContentPane( contentPanel );
+ this.setAlwaysOnTop(true);
+
+ contentPanel.add( getInfoPanel(), BorderLayout.PAGE_START );
+ contentPanel.add( getButtonPanel(), BorderLayout.PAGE_END );
+
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Point center = ge.getCenterPoint();
+ Rectangle bounds = ge.getMaximumWindowBounds();
+
+ int x = center.x - WIDTH/2, y = center.y - HEIGHT/2;
+ this.setBounds(x, y, WIDTH, HEIGHT);
+ if (WIDTH == bounds.width && HEIGHT == bounds.height){
+ this.setExtendedState(Frame.MAXIMIZED_BOTH);
+ }
+ this.validate();
+ this.setVisible(true);
+ this.pack();
+ }
+
+ private JPanel getInfoPanel(){
+ JPanel panel = new JPanel();
+ panel.setBorder( BorderFactory.createEmptyBorder( 30, 30, 30, 30) );
+ panel.add( new JLabel("Profile Editor - version " + ProfileEditor.VERSION));
+ return panel;
+ }
+
+ private JPanel getButtonPanel(){
+ JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+ JButton close = new JButton("Close");
+ close.addActionListener(this);
+ panel.add(close);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ this.dispose();
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/ColourButton.java b/src/com/sun/apoc/tools/profileeditor/gui/ColourButton.java
new file mode 100644
index 0000000..8e64954
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/ColourButton.java
@@ -0,0 +1,100 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import javax.swing.JButton;
+
+/**
+ *
+ * @author cs202741
+ */
+public class ColourButton extends JButton{
+ private Color buttonColour = Color.WHITE;
+
+ /** Creates a new instance of ColourButton */
+ public ColourButton() {
+ super();
+ setMargin(new Insets(5,5,5,5));
+ setIconTextGap(0);
+ setText(null);
+ }
+
+ public void setColor(Color color){
+ if(color != null){
+ buttonColour = color;
+ repaint();
+ }
+ }
+
+ public void setColor(String color){
+ if( color == null ){
+ return;
+ }
+
+ if( color.charAt(0) =='#' ){
+ color = color.substring(1);
+ }
+
+ if( color.length() != 6 ){
+ return;
+ }
+
+ try {
+ int red = Integer.parseInt( color.substring(0,2), 16 );
+ int green = Integer.parseInt( color.substring(2,4), 16 );
+ int blue = Integer.parseInt( color.substring(4,6), 16 );
+
+ buttonColour = new Color(red, green, blue);
+ repaint();
+ } catch (NumberFormatException ex) {}
+
+ }
+
+ protected void paintComponent(Graphics g){
+ Graphics2D g2d = (Graphics2D)g;
+
+ g2d.setColor(buttonColour);
+ g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
+ g2d.setColor(Color.BLACK);
+ g2d.drawRect(0, 0, this.getWidth(), this.getHeight());
+ g2d.dispose();
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/ComboBoxElement.java b/src/com/sun/apoc/tools/profileeditor/gui/ComboBoxElement.java
new file mode 100644
index 0000000..a3396d9
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/ComboBoxElement.java
@@ -0,0 +1,132 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.Subscriber;
+
+/**
+ *
+ * @author cs202741
+ */
+public class ComboBoxElement extends Object implements Subscriber{
+ private String mValue = null;
+ private String mLabel = null;
+ private String mDefaultValue = null;
+
+ // Subscriber Interface Var's
+ private LocaleManager mLocaleManager;
+ private String mResourceId = null;
+ private String mPackageName = null;
+ private String mDefaultName = null;
+
+
+ /** Creates a new instance of ComboBoxElement */
+ public ComboBoxElement() {
+ }
+
+ public void setValue(String aValue){
+ mValue = aValue;
+ }
+
+ public String getValue(){
+ return mValue;
+ }
+
+ public void setLabel(String aLabel){
+ mLabel = aLabel;
+ }
+
+ public String getLabel(){
+ return mLabel;
+ }
+
+ public void setLocaleManager(LocaleManager aLocaleManager){
+ mLocaleManager = aLocaleManager;
+ mLocaleManager.attach( this );
+ }
+
+ public String toString(){
+ return mLabel;
+ }
+
+ public void setPackageName(String name){
+ mPackageName = name;
+ }
+
+ public void setResourceId(String id){
+ mResourceId = id;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public void setDefault(String defaultValue){
+ mDefaultValue = defaultValue;
+ }
+
+ public void update() {
+
+ if( mResourceId != null ){
+ String label = mLocaleManager.getLocalizedName(mPackageName, mResourceId, mDefaultName );
+
+ if( label == null ){
+ if( mValue.equals("true") )
+ if( mValue.equals( mDefaultValue ) )
+ setLabel("Enabled *");
+ else
+ setLabel("Enabled");
+ else if( mValue.equals("false") ){
+ if( mValue.equals( mDefaultValue ) ){
+ setLabel("Disabled *");
+ }
+ else{
+ setLabel("Disabled");
+ }
+ }
+ }else{
+ setLabel( label );
+ }
+ }else{
+ mLabel = mValue;
+ }
+
+ if( mValue.equals( mDefaultValue ) ){
+ setLabel( getLabel() + " *" );
+ }
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/ComponentListener.java b/src/com/sun/apoc/tools/profileeditor/gui/ComponentListener.java
new file mode 100644
index 0000000..62f9294
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/ComponentListener.java
@@ -0,0 +1,111 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+/**
+ *
+ * @author cs202741
+ */
+public class ComponentListener implements ActionListener, KeyListener, FocusListener {
+
+ public void actionPerformed(ActionEvent event){
+
+ if( event.getSource() instanceof PropertyComponent ){
+ this.updateJListModel( (PropertyComponent)event.getSource() );
+ }
+
+ }//end actionPerformed()
+
+
+ public void keyTyped(KeyEvent e) {
+ ((PropertyComponent)e.getSource()).hasChanged();
+ }
+
+ /** Handle the key pressed event from the text field. */
+ public void keyPressed(KeyEvent e) {
+ ((PropertyComponent)e.getSource()).hasChanged();
+ }
+
+ /** Handle the key released event from the text field. */
+ public void keyReleased(KeyEvent e) {
+ ((PropertyComponent)e.getSource()).hasChanged();
+ }
+
+
+ public void focusGained(FocusEvent event){
+
+ }
+
+ public void focusLost(FocusEvent event){
+
+ if( event.getSource() instanceof PropertyComponent ){
+ this.updateJListModel( (PropertyComponent)event.getSource() );
+ }
+
+ }
+
+ private void updateJListModel(PropertyComponent aComponent){
+
+ PropertyJListModel listModel = aComponent.getListModel();
+
+ if( aComponent.hasChanged() ){
+ if( listModel.exists( aComponent ) ){
+ int index = listModel.indexOf( aComponent );
+ listModel.removeItem( aComponent );
+ listModel.addItem( index, aComponent );
+ //System.out.println("REMOVING FROM LIST BEFORE ADD: " + propComp.getDataPath() );
+ }else{
+ listModel.addItem( aComponent );
+ //System.out.println("ADDING TO LIST: " + propComp.getDataPath() );
+ }
+
+ }else {
+ if( listModel.exists( aComponent ) ){
+ listModel.removeItem( aComponent );
+ //System.out.println("REMOVING FROM LIST: " + propComp.getDataPath() );
+ }
+ }
+ }
+
+
+}//end ComponentListener
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/ErrorPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/ErrorPanel.java
new file mode 100644
index 0000000..ab229dd
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/ErrorPanel.java
@@ -0,0 +1,97 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.*;
+import java.awt.Font;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTabbedPane;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+
+public class ErrorPanel extends JPanel {
+ private JTextArea errorTextArea;
+
+ public ErrorPanel(){
+
+ this.setLayout( new BorderLayout() );
+ this.setPreferredSize( new Dimension(ProfileEditor.windowWidth, ProfileEditor.outputHeight) );
+
+ errorTextArea = new JTextArea();
+ errorTextArea.setEditable(false);
+ Font font = errorTextArea.getFont();
+ font = font.deriveFont(Font.PLAIN, font.getSize()-1 );
+ errorTextArea.setFont( font );
+
+ JScrollPane infoScrollPane = new JScrollPane(errorTextArea);
+
+ this.add(infoScrollPane, BorderLayout.CENTER);
+
+ System.setErr(new PrintStream( new JTextAreaOutputStream(errorTextArea) ) );
+ }
+
+ public void addText(String message){
+ errorTextArea.setText("\n" + message);
+ errorTextArea.setCaretPosition( errorTextArea.getDocument().getLength() );
+ }
+
+
+ public class JTextAreaOutputStream extends OutputStream {
+ JTextArea textArea;
+
+ public JTextAreaOutputStream(JTextArea text){
+ super();
+ textArea = text;
+ }
+
+ public void write(int i){
+ char[] chars = new char[1];
+ chars[0] = (char)i;
+ String s = new String(chars);
+ textArea.append(s);
+ }
+
+ public void write(char[] buf, int off, int len){
+ String s = new String(buf, off, len);
+ textArea.append(s);
+ }
+ }
+
+}//end OutputPane \ No newline at end of file
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/GeneralPropertiesPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/GeneralPropertiesPanel.java
new file mode 100644
index 0000000..a4dc4ca
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/GeneralPropertiesPanel.java
@@ -0,0 +1,366 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.spi.profiles.Applicability;
+import com.sun.apoc.tools.profileeditor.ProfileEditor;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.security.auth.module.UnixSystem;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.border.BevelBorder;
+
+/**
+ *
+ * @author cs202741
+ */
+public class GeneralPropertiesPanel extends TitledSectionJPanel implements ActionListener, KeyListener, FocusListener{
+
+ private ProfileEditor mProfileEditor = null;
+
+ private JTextField mDisplayName = null;
+ private JTextField mAuthor = null;
+ private JTextArea mComment = null;
+ private JComboBox mApplicability = null;
+ private JComboBox mPriority = null;
+ private JButton applyButton = null;
+ private JButton cancelButton = null;
+ private StandaloneProfileManager mProfileManager = null;
+
+ /** Creates a new instance of GeneralPropertiesPanel */
+ public GeneralPropertiesPanel(ProfileEditor profileEditor, StandaloneProfileManager profileManager) {
+ super( new JLabel("General Properties") );
+ this.setContentPanel( getContentPanel(), true );
+ mProfileManager = profileManager;
+ mProfileEditor = profileEditor;
+ }
+
+
+ private JPanel getContentPanel(){
+ JPanel mainPanel = new JPanel( new BorderLayout() );
+ JPanel contentPanel = new JPanel( new GridBagLayout() );
+ JPanel buttonPanel = new JPanel( new FlowLayout(FlowLayout.RIGHT) );
+
+ mainPanel.setOpaque(false);
+ contentPanel.setOpaque(false);
+ buttonPanel.setOpaque(false);
+
+ JLabel label = new JLabel("Display Name:");
+ label.setForeground( new Color(0x405661) );
+ Font font = label.getFont();
+ font = font.deriveFont( Font.PLAIN, font.getSize() );
+ label.setFont( font );
+
+ addWithGridBag( label, contentPanel,
+ 0, 0, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ mDisplayName = new JTextField(25);
+ mDisplayName.setText("NewProfile");
+ mDisplayName.addFocusListener(this);
+ mDisplayName.addKeyListener(this);
+ addWithGridBag( mDisplayName, contentPanel,
+ 1, 0, 2, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ label = new JLabel("Comment:");
+ label.setForeground( new Color(0x405661) );
+ label.setFont( font );
+ addWithGridBag( label, contentPanel,
+ 0, 1, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ mComment = new JTextArea(6, 60);
+ mComment.addFocusListener(this);
+ mComment.addKeyListener(this);
+ JScrollPane scroll = new JScrollPane(mComment);
+ addWithGridBag( scroll, contentPanel,
+ 1, 1, 2, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ label = new JLabel("Author:");
+ label.setForeground( new Color(0x405661) );
+ label.setFont( font );
+ addWithGridBag( label, contentPanel,
+ 0, 2, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ mAuthor = new JTextField(25);
+ mAuthor.addFocusListener(this);
+ mAuthor.addKeyListener(this);
+ mAuthor.setText( System.getProperty("user.name") );
+ addWithGridBag( mAuthor, contentPanel,
+ 1, 2, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ label = new JLabel("* e.g. Lastname, Firstname");
+ addWithGridBag( label, contentPanel,
+ 2, 2, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ label = new JLabel("Applicability:");
+ label.setForeground( new Color(0x405661) );
+ label.setFont( font );
+ addWithGridBag( label, contentPanel,
+ 0, 3, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+
+ String[] items = { "USER" };
+ mApplicability = new JComboBox(items);
+ mApplicability.addActionListener(this);
+ addWithGridBag( mApplicability, contentPanel,
+ 1, 3, 2, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ label = new JLabel("Priority:");
+ label.setForeground( new Color(0x405661) );
+ label.setFont( font );
+ addWithGridBag( label, contentPanel,
+ 0, 4, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+
+ String[] priorities = { "0", "1", "2" };
+ mPriority = new JComboBox(priorities);
+ mPriority.addActionListener(this);
+ addWithGridBag( mPriority, contentPanel,
+ 1, 4, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ label = new JLabel("*Warning, having more than one profile available to the APOC daemon with the same priority can cause errors!");
+ addWithGridBag( label, contentPanel,
+ 2, 4, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ applyButton = new JButton("Save");
+ applyButton.addActionListener(this);
+ cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener(this);
+
+ buttonPanel.add(applyButton);
+ buttonPanel.add(cancelButton);
+ mainPanel.add(contentPanel, BorderLayout.CENTER);
+ mainPanel.add(buttonPanel, BorderLayout.PAGE_END);
+
+ return mainPanel;
+ }
+
+
+ public void reset(){
+ mDisplayName.setText( "NewProfile" );
+ mAuthor.setText( System.getProperty("user.name") );
+ mComment.setText("");
+ mApplicability.setSelectedIndex(0);
+ mPriority.setSelectedIndex(0);
+ }
+
+
+ public void update(){
+ mDisplayName.setText( mProfileManager.getDisplayName() );
+ mComment.setText( mProfileManager.getComment() );
+ mAuthor.setText( mProfileManager.getAuthor() );
+ mApplicability.setSelectedIndex( 0 );
+ mPriority.setSelectedIndex( mProfileManager.getPriority() );
+ }
+
+
+ public void applyChanges(){
+ mProfileManager.setDisplayName( mDisplayName.getText() );
+ mProfileManager.setComment( mComment.getText() );
+ mProfileManager.setAuthor( mAuthor.getText() );
+ mProfileManager.setApplicability( Applicability.getApplicability(mApplicability.getSelectedItem().toString() ));
+ mProfileManager.setPriority( mPriority.getSelectedIndex() );
+ }
+
+ private void saveChanges(){
+ mProfileEditor.saveProfile();
+ }
+
+ public boolean hasChanged(){
+
+ if( ! mProfileManager.getDisplayName().equals( mDisplayName.getText() )){
+ if( ! mDisplayName.getText().equals("NewProfile") ){
+ return true;
+ }
+ }
+
+ if( ! mProfileManager.getComment().equals( mComment.getText() )){
+ return true;
+ }
+
+ if( ! mProfileManager.getAuthor().equals( mAuthor.getText() )){
+ if( ! mAuthor.getText().equals(System.getProperty("user.name")) ){
+ return true;
+ }
+ }
+
+ String savedApplic = mProfileManager.getApplicability().toString();
+ String currentApplic = mApplicability.getSelectedItem().toString();
+
+ if( ! savedApplic.equals( currentApplic ) ){
+ if( mProfileManager.exists() ){
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ if( mProfileManager.getPriority() != mPriority.getSelectedIndex() ){
+ if( mProfileManager.exists() ){
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ return false;
+ }
+
+
+ public void setDisplayName(String name){
+ mDisplayName.setText( name );
+ }
+
+
+ public String getDisplayName(){
+ return mDisplayName.getText();
+ }
+
+
+ public void setAuthor(String author){
+ mAuthor.setText( author );
+ }
+
+
+ public String getAuthor(){
+ return mAuthor.getText();
+ }
+
+
+ public void setComment(String comment){
+ mComment.setText( comment );
+ }
+
+
+ public String getComment(){
+ return mComment.getText();
+ }
+
+
+ private void addWithGridBag(Component comp, Container cont,
+ int x, int y,
+ int width, int height,
+ int anchor, int fill,
+ int weightx, int weighty){
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.insets = new Insets(6,7,6,3);
+ gbc.gridx = x;
+ gbc.gridy = y;
+ gbc.gridwidth = width;
+ gbc.gridheight = height;
+ gbc.anchor = anchor;
+ gbc.fill = fill;
+ gbc.weightx = weightx;
+ gbc.weighty = weighty;
+ cont.add(comp, gbc);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ mProfileEditor.updateSavedState();
+
+ if(e.getSource() == applyButton){
+ saveChanges();
+ }else if(e.getSource() == cancelButton){
+ update();
+ }
+ }
+
+ public void keyTyped(KeyEvent e) {
+ mProfileEditor.updateSavedState();
+ }
+
+ public void keyPressed(KeyEvent e) {
+ //mProfileEditor.updateSavedState();
+ }
+
+ public void keyReleased(KeyEvent e) {
+ //mProfileEditor.updateSavedState();
+ }
+
+ public void focusGained(FocusEvent e) {
+ //mProfileEditor.updateSavedState();
+ }
+
+ public void focusLost(FocusEvent e) {
+ mProfileEditor.updateSavedState();
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/GradientJButton.java b/src/com/sun/apoc/tools/profileeditor/gui/GradientJButton.java
new file mode 100644
index 0000000..886ac8b
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/GradientJButton.java
@@ -0,0 +1,83 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import javax.swing.JButton;
+
+/**
+ *
+ * @author cs202741
+ */
+public class GradientJButton extends JButton{
+ private Color color1 = new Color(0xf2fafa);
+ private Color color2 = new Color(0xd2e0eb);
+ private Color border = new Color(0x6699cc);
+
+ /** Creates a new instance of GradientJButton */
+ public GradientJButton(String label) {
+ super("My Button");
+ setIconTextGap(0);
+ setBorderPainted(false);
+ //setBorder(null);
+ //setContentAreaFilled(false);
+ //setMargin(new Insets(5, 5, 5, 5));
+ }
+
+ public void paintComponent(Graphics g){
+ Graphics2D _g = (Graphics2D)g;
+ Color origColor = _g.getColor();
+
+ Paint gradientPaint = new GradientPaint(0,getHeight(), color1, 0, 0, color2, true);
+
+ _g.setPaint( gradientPaint );
+ _g.fillRoundRect(0, 0, getWidth(), getHeight(), 15, 15);
+ _g.setColor( border );
+ _g.drawRoundRect( 0, 0, getWidth(), getHeight(), 15, 15);
+
+ _g.setColor( origColor );
+ super.paintComponent(g);
+ }
+
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/GradientJPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/GradientJPanel.java
new file mode 100644
index 0000000..b032a2c
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/GradientJPanel.java
@@ -0,0 +1,107 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author cs202741
+ */
+public class GradientJPanel extends JPanel{
+ public static final int ROUNDED_NONE = 0;
+ public static final int ROUNDED_TOP = 1;
+ public static final int ROUNDED_BOTTOM = 2;
+ public static final int ROUNDED_BOTH = 3;
+
+ private Color color1 = null;
+ private Color color2 = null;
+
+ private int CORNER_STYLE = ROUNDED_NONE;
+ private int ARC_RADIUS = 5;
+ private int OFFSET = 5;
+ private int HEIGHT = 0;
+
+ public GradientJPanel(Color color1, Color color2, int cornerStyle, int arcRadius, int gradientOffset){
+ super();
+ this.setOpaque( false );
+
+ this.color1 = color1;
+ this.color2 = color2;
+ CORNER_STYLE = cornerStyle;
+ ARC_RADIUS = arcRadius;
+ OFFSET = gradientOffset;
+ }
+
+
+ public void setColours(Color color1, Color color2){
+ this.color1 = color1;
+ this.color2 = color2;
+ }
+
+ public void setGradientHeight(int height){
+ HEIGHT = height;
+ }
+
+ public void paintComponent(Graphics _g){
+ Graphics2D g = (Graphics2D)_g;
+ Rectangle bounds = getBounds();
+
+ Paint gradientPaint = new GradientPaint(0,bounds.height - OFFSET, color1, 0, 0, color2, true);
+
+ g.setPaint(gradientPaint);
+
+ if( CORNER_STYLE == ROUNDED_NONE ){
+ g.fillRect(0,0,bounds.width, bounds.height);
+ }else if( CORNER_STYLE == ROUNDED_BOTTOM ){
+ g.fillRoundRect(0,0,bounds.width, HEIGHT, ARC_RADIUS, ARC_RADIUS);
+ g.fillRect(0,0,bounds.width, HEIGHT - ARC_RADIUS + 2);
+ }else if( CORNER_STYLE == ROUNDED_TOP ){
+ g.fillRoundRect(0, HEIGHT, bounds.width, bounds.height, ARC_RADIUS, ARC_RADIUS);
+ g.fillRect(0, HEIGHT + ARC_RADIUS - 2, bounds.width, bounds.height);
+ }else if( CORNER_STYLE == ROUNDED_BOTH ){
+ g.fillRoundRect(0,0,bounds.width, bounds.height, ARC_RADIUS, ARC_RADIUS);
+ }
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/GradientTabPaneUI.java b/src/com/sun/apoc/tools/profileeditor/gui/GradientTabPaneUI.java
new file mode 100644
index 0000000..754c4b9
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/GradientTabPaneUI.java
@@ -0,0 +1,195 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import javax.swing.Icon;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.basic.BasicTabbedPaneUI;
+
+/**
+ *
+ * @author csmith
+ */
+public class GradientTabPaneUI extends BasicTabbedPaneUI{
+
+ private static final int TAB_HEIGHT = 10;
+ private static final int TAB_WIDTH = 10;
+
+ protected Color lightHighlight = new Color(0x71838d);
+ protected Color shadow = new Color(0x71838d);
+ protected Color darkShadow = new Color(0x495b67);
+
+ /** Creates a new instance of GradientTabPaneUI */
+ public GradientTabPaneUI() {
+ super();
+ }
+
+ protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) {
+ int tabCount = tabPane.getTabCount();
+
+ Rectangle iconRect = new Rectangle(),
+ textRect = new Rectangle();
+ Rectangle clipRect = g.getClipBounds();
+
+ // Paint tabRuns of tabs from back to front
+ for (int i = runCount - 1; i >= 0; i--) {
+ int start = tabRuns[i];
+ int next = tabRuns[(i == runCount - 1)? 0 : i + 1];
+ int end = (next != 0? next - 1: tabCount - 1);
+ for (int j = start; j <= end; j++) {
+ if (j != selectedIndex && rects[j].intersects(clipRect)) {
+ paintTab(g, tabPlacement, rects, j, iconRect, textRect);
+ }
+ }
+ }
+
+ // Paint selected tab if its in the front run
+ // since it may overlap other tabs
+ if (selectedIndex >= 0 && rects[selectedIndex].intersects(clipRect)) {
+ paintTab(g, tabPlacement, rects, selectedIndex, iconRect, textRect);
+ }
+ }
+
+ protected void paintTab(Graphics g, int tabPlacement,
+ Rectangle[] rects, int tabIndex,
+ Rectangle iconRect, Rectangle textRect) {
+ Rectangle tabRect = rects[tabIndex];
+ int selectedIndex = tabPane.getSelectedIndex();
+ boolean isSelected = selectedIndex == tabIndex;
+ Graphics2D g2 = null;
+ Polygon cropShape = null;
+ Shape save = null;
+ int cropx = 0;
+ int cropy = 0;
+
+
+ //if (tabPane.isOpaque()) {
+ paintTabBackground(g, tabPlacement, tabIndex, tabRect.x, tabRect.y,
+ tabRect.width, tabRect.height, isSelected);
+ //}
+
+ paintTabBorder(g, tabPlacement, tabIndex, tabRect.x, tabRect.y,
+ tabRect.width, tabRect.height, isSelected);
+
+ String title = tabPane.getTitleAt(tabIndex);
+ Font font = tabPane.getFont();
+ //FontMetrics metrics = SwingUtilities2.getFontMetrics(tabPane, g, font);
+ FontMetrics metrics = g.getFontMetrics( font );
+ Icon icon = getIconForTab(tabIndex);
+
+ layoutLabel(tabPlacement, metrics, tabIndex, title, icon,
+ tabRect, iconRect, textRect, isSelected);
+
+ paintText(g, tabPlacement, font, metrics,
+ tabIndex, title, textRect, isSelected);
+
+ paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
+
+ paintFocusIndicator(g, tabPlacement, rects, tabIndex,
+ iconRect, textRect, isSelected);
+
+ }
+
+
+ protected void paintTabBorder(Graphics g, int tabPlacement,
+ int tabIndex,
+ int x, int y, int w, int h,
+ boolean isSelected ) {
+
+ g.setColor(lightHighlight);
+
+ g.drawLine(x, y+2, x, y+h-1); // left highlight
+ g.drawLine(x+1, y+1, x+1, y+1); // top-left highlight
+ g.drawLine(x+2, y, x+w-3, y); // top highlight
+
+ g.setColor(shadow);
+ g.drawLine(x+w-2, y+2, x+w-2, y+h-1); // right shadow
+
+ g.setColor(darkShadow);
+ g.drawLine(x+w-1, y+2, x+w-1, y+h-1); // right dark-shadow
+ g.drawLine(x+w-2, y+1, x+w-2, y+1); // top-right shadow
+
+ }
+
+
+ protected void paintTabBackground(Graphics g, int tabPlacement,
+ int tabIndex,
+ int x, int y, int w, int h,
+ boolean isSelected ) {
+
+ Graphics2D _g = (Graphics2D)g;
+ Paint gradientPaint;
+
+ if( isSelected ){
+ gradientPaint = new GradientPaint(0,h, new Color(0xdee7e7), 0, 0, new Color(0xFFFFFF), true);
+ }else{
+ gradientPaint = new GradientPaint(0,h, new Color(0xa5aeb5), 0, 0, new Color(0xced3de), true);
+ }
+ _g.setPaint( gradientPaint );
+
+ switch(tabPlacement) {
+ case LEFT:
+ _g.fillRect(x+1, y+1, w-1, h-3);
+ break;
+ case RIGHT:
+ _g.fillRect(x, y+1, w-2, h-3);
+ break;
+ case BOTTOM:
+ _g.fillRect(x+1, y, w-3, h-1);
+ break;
+ case TOP:
+ default:
+ _g.fillRect(x+1, y+1, w-3, h-1);
+ }
+ }
+
+ protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight){
+ return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight) + TAB_HEIGHT;
+ }
+
+ protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
+ return super.calculateTabWidth(tabPlacement, tabIndex, metrics) + TAB_WIDTH;
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/ImageButton.java b/src/com/sun/apoc/tools/profileeditor/gui/ImageButton.java
new file mode 100644
index 0000000..122fc6e
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/ImageButton.java
@@ -0,0 +1,79 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.event.MouseListener;
+import javax.swing.JButton;
+import javax.swing.ImageIcon;
+
+import java.awt.Insets;
+import java.awt.event.MouseEvent;
+
+
+public class ImageButton extends JButton {
+
+ public ImageButton(ImageIcon icon){
+ super();
+ setSize(icon.getImage().getWidth(null),
+ icon.getImage().getHeight(null));
+ setIcon(icon);
+ setMargin(new Insets(5,5,5,5));
+ setIconTextGap(0);
+ setBorderPainted(false);
+ setBorder(null);
+ setText(null);
+ setContentAreaFilled(false);
+
+ this.addMouseListener(new MouseListener() {
+ public void mouseClicked(MouseEvent e) {
+ }
+ public void mouseEntered(MouseEvent e) {
+ ((JButton)e.getSource()).setContentAreaFilled(true);
+ //setBorderPainted(true);
+ //setBorder(border);
+ }
+ public void mouseExited(MouseEvent e) {
+ ((JButton)e.getSource()).setContentAreaFilled(false);
+ //setBorderPainted(false);
+ //setBorder(null);
+ }
+ public void mousePressed(MouseEvent e) {
+ }
+ public void mouseReleased(MouseEvent e) {
+ }
+ });
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/ImageButtonMouseListener.java b/src/com/sun/apoc/tools/profileeditor/gui/ImageButtonMouseListener.java
new file mode 100644
index 0000000..42334af
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/ImageButtonMouseListener.java
@@ -0,0 +1,98 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import javax.swing.CellRendererPane;
+import javax.swing.JList;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author csmith
+ */
+public class ImageButtonMouseListener implements MouseListener {
+ private JList mList = null;
+
+ public ImageButtonMouseListener(JList aList){
+ mList = aList;
+ }
+
+ public boolean isClickInButton(MouseEvent event){
+ Rectangle r = ((ImageButton)event.getSource()).getBounds();
+ CellRendererPane cell = (CellRendererPane)mList.getComponent(0);
+ JPanel panel = (JPanel)cell.getComponent(0);
+ double cellHeight = panel.getPreferredSize().getHeight();
+ //System.out.println("Cell Height: " + cellHeight);
+ double x = event.getX() - 16;
+ double y = event.getY() - 26 - (cellHeight * mList.getSelectedIndex() );
+
+ //System.out.println("Rectangle: " + r);
+ //System.out.println("Click X: " + x + " Y: " + y);
+
+ if( r.contains( x, y) )
+ return true;
+ else
+ return false;
+ }
+
+ public void mouseClicked(MouseEvent event) {
+ if( isClickInButton( event ) ) {
+ //System.out.println("Clicked Button");
+ PropertyComponent propComp = (PropertyComponent)mList.getSelectedValue();
+ propComp.reset();
+ }
+ }
+
+ public void mouseEntered(MouseEvent e) {
+
+ }
+
+ public void mouseExited(MouseEvent e) {
+
+ }
+
+ public void mousePressed(MouseEvent e) {
+
+ }
+
+ public void mouseReleased(MouseEvent e) {
+
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/InfoPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/InfoPanel.java
new file mode 100644
index 0000000..abcbf3b
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/InfoPanel.java
@@ -0,0 +1,96 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.gui;
+import com.sun.apoc.tools.profileeditor.*;
+import java.awt.Font;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTabbedPane;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+
+public class InfoPanel extends JPanel {
+ private JTextArea infoTextArea;
+
+ public InfoPanel(){
+
+ this.setLayout( new BorderLayout() );
+ this.setPreferredSize( new Dimension(ProfileEditor.windowWidth, ProfileEditor.outputHeight) );
+
+ infoTextArea = new JTextArea();
+ infoTextArea.setEditable(false);
+ Font font = infoTextArea.getFont();
+ font = font.deriveFont(Font.PLAIN, font.getSize()-1 );
+ infoTextArea.setFont( font );
+
+ JScrollPane infoScrollPane = new JScrollPane(infoTextArea);
+
+ this.add(infoScrollPane, BorderLayout.CENTER);
+
+ System.setOut(new PrintStream( new JTextAreaOutputStream(infoTextArea) ) );
+ }
+
+ public void addText(String message){
+ infoTextArea.setText("\n" + message);
+ infoTextArea.setCaretPosition( infoTextArea.getDocument().getLength() );
+ }
+
+
+ public class JTextAreaOutputStream extends OutputStream {
+ JTextArea textArea;
+
+ public JTextAreaOutputStream(JTextArea text){
+ super();
+ textArea = text;
+ }
+
+ public void write(int i){
+ char[] chars = new char[1];
+ chars[0] = (char)i;
+ String s = new String(chars);
+ textArea.append(s);
+ }
+
+ public void write(char[] buf, int off, int len){
+ String s = new String(buf, off, len);
+ textArea.append(s);
+ }
+ }
+
+}//end OutputPane \ No newline at end of file
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/LocalizedTitledBorder.java b/src/com/sun/apoc/tools/profileeditor/gui/LocalizedTitledBorder.java
new file mode 100644
index 0000000..228c33b
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/LocalizedTitledBorder.java
@@ -0,0 +1,85 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.Subscriber;
+import javax.swing.border.Border;
+import javax.swing.border.TitledBorder;
+
+/**
+ *
+ * @author cs202741
+ */
+public class LocalizedTitledBorder extends TitledBorder implements Subscriber{
+
+ // Subscriber Interface Variables
+ private String mResourceID = null;
+ private String mPackageName = null;
+ private String mDefaultName = null;
+ private LocaleManager mLocaleManager = null;
+
+ public LocalizedTitledBorder(Border border){
+ super(border);
+ this.setTitleJustification( TitledBorder.LEFT );
+ }
+
+ public void setPackageName(String aPackageName) {
+ mPackageName = aPackageName;
+ }
+
+ public void setResourceId(String aResourceID) {
+ mResourceID = aResourceID;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public void setLocaleManager(LocaleManager aLocaleManager) {
+ mLocaleManager = aLocaleManager;
+ mLocaleManager.attach( this );
+ update();
+ }
+
+ public void update() {
+ String sectionName = mLocaleManager.getLocalizedName( mPackageName, mResourceID, mDefaultName);
+ if( sectionName == null ){
+ sectionName = mResourceID;
+ }
+ this.setTitle(sectionName);
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/OnlineHelpFrame.java b/src/com/sun/apoc/tools/profileeditor/gui/OnlineHelpFrame.java
new file mode 100644
index 0000000..08a0d4f
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/OnlineHelpFrame.java
@@ -0,0 +1,103 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.GraphicsEnvironment;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.io.File;
+import java.net.URL;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+
+/**
+ *
+ * @author cs202741
+ */
+public class OnlineHelpFrame extends JFrame {
+ private static final int WIDTH = 640;
+ private static final int HEIGHT = 480;
+
+ private String helpPath = null;
+
+ /** Creates a new instance of OnlineHelpFrame */
+ public OnlineHelpFrame(LocaleManager aLocaleManager, String path) {
+ super("Online Help: ");
+ helpPath = path;
+
+ JPanel contentPanel = new JPanel(new BorderLayout());
+ this.setContentPane( contentPanel );
+ this.setAlwaysOnTop(true);
+
+ JTextPane tp = new JTextPane();
+ tp.setBackground(new Color(0xbec7cc));
+ tp.setForeground(new Color(0x405661));
+ JScrollPane scroll = new JScrollPane(tp);
+ contentPanel.add( scroll );
+
+ File file = new File(helpPath + "_" + aLocaleManager.getCurrentLocale() + ".html");
+ if( file.exists() ){
+ try {
+ System.out.println("help Path: " + helpPath);
+ URL url = new URL("file://" + helpPath + "_" + aLocaleManager.getCurrentLocale() + ".html");
+ tp.setPage(url);
+ }
+ catch (Exception e) {System.out.println("exception!");}
+ }else{
+ tp.setText("No HTML help file found for current locale: " + aLocaleManager.getCurrentLocale());
+ }
+
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Point center = ge.getCenterPoint();
+ Rectangle bounds = ge.getMaximumWindowBounds();
+
+ int x = center.x - WIDTH/2, y = center.y - HEIGHT/2;
+ this.setBounds(x, y, WIDTH, HEIGHT);
+ if (WIDTH == bounds.width && HEIGHT == bounds.height){
+ this.setExtendedState(Frame.MAXIMIZED_BOTH);
+ }
+ //this.validate();
+ this.setVisible(true);
+ //this.pack();
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PreferencesJPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/PreferencesJPanel.java
new file mode 100644
index 0000000..532ece1
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PreferencesJPanel.java
@@ -0,0 +1,244 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.ProfileEditorPreferences;
+import com.sun.apoc.tools.profileeditor.gui.GradientJButton;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextField;
+import javax.swing.border.Border;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PreferencesJPanel extends JPanel implements ActionListener{
+
+ private ProfileEditorPreferences mPreferences = null;
+ private JPanel mainPanel = null;
+ private ArrayList<Component> components = null;
+ private JTabbedPane mTabbedPane = null;
+
+ /** Creates a new instance of PreferencesPanel */
+ public PreferencesJPanel(ProfileEditorPreferences aPreferences, JTabbedPane tabbedPane) {
+ mPreferences = aPreferences;
+ mTabbedPane = tabbedPane;
+ components = new ArrayList();
+
+ this.setBackground( Color.WHITE );
+ this.setLayout( new BorderLayout() );
+
+ mainPanel = new JPanel();
+ mainPanel.setLayout( new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS) );
+
+ mainPanel.add( getGeneral() );
+ mainPanel.add( getButtons() );
+
+ this.add( mainPanel, BorderLayout.PAGE_START);
+ }
+
+ private JPanel getGeneral(){
+
+ TitledSectionJPanel titledPanel = new TitledSectionJPanel(new JLabel("General Preferences"));
+
+ JPanel panel = new JPanel(new GridBagLayout());
+ titledPanel.setContentPanel( panel, true );
+
+ // displayResourceIds
+ String value = mPreferences.getProperty( "displayResourceIds");
+ addWithGridBag( new JLabel("<html>Display Resource ID's instead of default name<br>" +
+ "when no locale information is available?</html>"), panel,
+ 0, 0, 1, 1,
+ GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL,
+ 0, 0);
+
+ JCheckBox box = new JCheckBox();
+ box.setOpaque(false);
+ box.setSelected( Boolean.valueOf( value ) );
+ box.setName( "displayResourceIds");
+ components.add( box );
+ addWithGridBag( box, panel,
+ 1, 0, 1, 1,
+ GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
+ 0, 0);
+
+
+ // templatePackagePath
+ value = mPreferences.getProperty( "templatePackagePath");
+ addWithGridBag( new JLabel("Path to Template Package Root: "), panel,
+ 0, 1, 1, 1,
+ GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL,
+ 0, 0);
+
+ JTextField text = new JTextField( value );
+ text.setName("templatePackagePath");
+ components.add(text);
+ addWithGridBag( text, panel,
+ 1, 1, 1, 1,
+ GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
+ 0, 0);
+
+ // userLocales
+ value = mPreferences.getProperty( "userLocales");
+ addWithGridBag( new JLabel("User Locales: "), panel,
+ 0, 2, 1, 1,
+ GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL,
+ 0, 0);
+ text = new JTextField( value );
+ text.setName("userLocales");
+ components.add(text);
+ addWithGridBag( text, panel,
+ 1, 2, 1, 1,
+ GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
+ 0, 0);
+
+ addWithGridBag( new JLabel("Defaults: " + mPreferences.getProperty("defaultLocales")), panel,
+ 1, 3, 1, 1,
+ GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
+ 0, 0);
+
+ return titledPanel;
+ }
+
+
+ private JPanel getButtons(){
+
+ Border border = BorderFactory.createEmptyBorder(5, 5, 5, 5);
+ JPanel panel = new JPanel( new FlowLayout( FlowLayout.RIGHT, 12, 0));
+ panel.setBackground( Color.WHITE );
+ panel.setBorder( border );
+
+ JButton ok = new JButton("Ok");
+ ok.setActionCommand("Ok");
+ ok.addActionListener(this);
+
+ JButton reset = new JButton("Reset Defaults");
+ reset.setActionCommand("ResetDefaults");
+ reset.addActionListener(this);
+
+ JButton cancel = new JButton("Cancel");
+ cancel.setActionCommand("Cancel");
+ cancel.addActionListener(this);
+
+ panel.add(ok);
+ panel.add(reset);
+ panel.add(cancel);
+
+ return panel;
+ }
+
+
+ private void addWithGridBag(Component comp, Container cont,
+ int x, int y,
+ int width, int height,
+ int anchor, int fill,
+ int weightx, int weighty){
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.insets = new Insets( 10, 5, 10, 5);
+ gbc.gridx = x;
+ gbc.gridy = y;
+ gbc.gridwidth = width;
+ gbc.gridheight = height;
+ gbc.anchor = anchor;
+ gbc.fill = fill;
+ gbc.weightx = weightx;
+ gbc.weighty = weighty;
+ cont.add(comp, gbc);
+ }
+
+
+ private void savePreferences(){
+ Iterator it = components.iterator();
+
+ while(it.hasNext()){
+ Object comp = it.next();
+
+ if( comp instanceof JTextField ){
+ JTextField text = (JTextField)comp;
+ if( !(text.getText().equals("")) ){
+ mPreferences.setProperty( text.getName(), text.getText() );
+ }else
+ mPreferences.remove( text.getName() );
+ }else if( comp instanceof JCheckBox ){
+ JCheckBox box = (JCheckBox)comp;
+ mPreferences.setProperty( box.getName(), Boolean.toString( box.isSelected() ) );
+ }
+ }
+ try {
+ mPreferences.store();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void resetDefaults(){
+
+ }
+
+ public void actionPerformed(ActionEvent event) {
+
+ if( event.getActionCommand().equals("Ok") ){
+ savePreferences();
+ mTabbedPane.remove( mTabbedPane.getSelectedIndex() );
+ mTabbedPane.setSelectedIndex(0);
+ }else if( event.getActionCommand().equals("Cancel") ){
+ mTabbedPane.remove( mTabbedPane.getSelectedIndex() );
+ mTabbedPane.setSelectedIndex(0);
+ }else if( event.getActionCommand().equals("ResetDefaults") ){
+ resetDefaults();
+ }
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/ProfileEditorJMenuBar.java b/src/com/sun/apoc/tools/profileeditor/gui/ProfileEditorJMenuBar.java
new file mode 100644
index 0000000..3ab8538
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/ProfileEditorJMenuBar.java
@@ -0,0 +1,129 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+
+/**
+ *
+ * @author cs202741
+ */
+public class ProfileEditorJMenuBar extends JMenuBar {
+ ActionListener mListener = null;
+
+ /** Creates a new instance of ProfileEditorJMenuBar */
+ public ProfileEditorJMenuBar( ActionListener aListener ) {
+ mListener = aListener;
+
+ this.add( getFileMenu() );
+ this.add( getToolsMenu() );
+ this.add( getHelpMenu() );
+
+ }
+
+ private JMenu getFileMenu(){
+ JMenu fileMenu = new JMenu( "File" );
+ fileMenu.setMnemonic( KeyEvent.VK_F );
+
+ JMenuItem menuItem = new JMenuItem( "New Profile", KeyEvent.VK_N );
+ menuItem.setActionCommand("New");
+ menuItem.addActionListener(mListener);
+ fileMenu.add(menuItem);
+
+ menuItem = new JMenuItem( "Open Profile", KeyEvent.VK_O );
+ menuItem.setActionCommand("OpenProfile");
+ menuItem.addActionListener(mListener);
+ fileMenu.add(menuItem);
+
+ fileMenu.addSeparator();
+
+ menuItem = new JMenuItem( "Open Package", KeyEvent.VK_O );
+ menuItem.setActionCommand("OpenPackage");
+ menuItem.addActionListener(mListener);
+ fileMenu.add(menuItem);
+
+ fileMenu.addSeparator();
+
+ menuItem = new JMenuItem( "Save", KeyEvent.VK_S );
+ menuItem.setActionCommand("Save");
+ menuItem.addActionListener(mListener);
+ fileMenu.add(menuItem);
+
+ menuItem = new JMenuItem( "Save As", KeyEvent.VK_A );
+ menuItem.setActionCommand("SaveAs");
+ menuItem.addActionListener(mListener);
+ fileMenu.add(menuItem);
+
+ fileMenu.addSeparator();
+
+ menuItem = new JMenuItem( "Exit", KeyEvent.VK_X );
+ menuItem.setActionCommand("Exit");
+ menuItem.addActionListener(mListener);
+ fileMenu.add(menuItem);
+
+ return fileMenu;
+ }
+
+ public JMenu getToolsMenu(){
+ JMenu toolsMenu = new JMenu("Tools");
+ JMenuItem menuItem = null;
+ toolsMenu.setMnemonic( KeyEvent.VK_T );
+
+ menuItem = new JMenuItem( "Preferences", KeyEvent.VK_N );
+ menuItem.addActionListener(mListener);
+ menuItem.setActionCommand("Preferences");
+ toolsMenu.add( menuItem );
+
+ return toolsMenu;
+ }
+
+ public JMenu getHelpMenu(){
+ JMenu helpMenu = new JMenu("Help");
+ JMenuItem menuItem = null;
+ helpMenu.setMnemonic( KeyEvent.VK_H );
+
+ menuItem = new JMenuItem( "About", KeyEvent.VK_A );
+ menuItem.addActionListener(mListener);
+ menuItem.setActionCommand("About");
+ helpMenu.add( menuItem );
+
+ return helpMenu;
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyChooser.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyChooser.java
new file mode 100644
index 0000000..5e3b1ce
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyChooser.java
@@ -0,0 +1,474 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+import com.sun.apoc.tools.profileeditor.templates.TemplatePropertyConstraint;
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Enumeration;
+import java.util.Vector;
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyChooser extends JPanel implements PropertyComponent, ActionListener {
+
+ // PropertyComponent Variables
+ private boolean mIsSet = false;
+ private String mResourceId = null;
+ private String mDefaultName = null;
+ private String mDataType = null;
+ private String mSectionName = null;
+ private String mResourceIdPath = null;
+ private String mPath = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefault = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileModel = null;
+
+
+ private TemplateProperty mProperty = null;
+ private String[] mDefaultItems;
+ private PropertyJListModel mPropertyListModel = null;
+
+ // GUI Comps
+ private JComboBox itemsComboBox = null;
+ private JButton editButton, addButton, deleteButton, okButton, resetDefaultsButton, cancelButton;
+ private JTextField mNewItemText = null;
+ private JList mList = null;
+ private DefaultListModel mDefaultListModel = null;
+ private JFrame frame;
+
+ private boolean updateLock = false;
+
+ /** Creates a new instance of PropertyStringList */
+ public PropertyChooser(TemplateProperty aProperty) {
+ this.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ this.setOpaque(false);
+ setChooserPath( aProperty.getChooserPath() );
+ setExtendsChooser( aProperty.getExtendsChooser() );
+ mProperty = aProperty;
+ DefaultComboBoxModel model = new DefaultComboBoxModel( getItems() );
+ itemsComboBox = new JComboBox(model);
+ itemsComboBox.addActionListener( this );
+
+ editButton = new JButton("Edit");
+ editButton.addActionListener( this );
+
+ this.add( itemsComboBox );
+ this.add( editButton );
+ }
+
+ private String[] getItems(){
+ Vector v = mProperty.getConstraints();
+ if( v != null){
+ Object[] items = v.toArray();
+ mDefaultItems = new String[items.length + 1];
+ mDefaultItems[0] = "-- Not Set --";
+ for(int i = 0; i < items.length; i++){
+ mDefaultItems[i + 1] = ((TemplatePropertyConstraint)items[i]).getValue();
+ }
+
+ return mDefaultItems;
+ }
+ String[] str = new String[1];
+ str[0] = "-- Not Set --";
+ return str;
+ }
+
+ private void showEditFrame(){
+ frame = new JFrame("Edit Options");
+ JPanel contentPanel = new JPanel(new BorderLayout());
+ contentPanel.setBorder( BorderFactory.createEmptyBorder( 30, 30, 30, 30) );
+
+ frame.setContentPane( contentPanel );
+
+ contentPanel.add( getNewItemPanel(), BorderLayout.PAGE_START );
+ contentPanel.add( getListPanel(), BorderLayout.CENTER );
+ contentPanel.add( getButtonPanel(), BorderLayout.PAGE_END );
+
+ frame.setVisible(true);
+ frame.pack();
+ }
+
+ private JPanel getNewItemPanel(){
+ JPanel panel = new JPanel( new FlowLayout( FlowLayout.LEFT) );
+ mNewItemText = new JTextField(13);
+ mNewItemText.addActionListener( this );
+ addButton = new JButton("Add Item");
+ addButton.addActionListener( this );
+
+ panel.add(mNewItemText);
+ panel.add(addButton);
+
+ return panel;
+ }
+
+ private JPanel getListPanel(){
+ JPanel mainPanel = new JPanel();
+ mainPanel.setLayout( new BoxLayout( mainPanel, BoxLayout.LINE_AXIS ) );
+
+ mDefaultListModel = new DefaultListModel();
+ mList = new JList( mDefaultListModel );
+ JScrollPane scroll = new JScrollPane( mList );
+ loadListFromCombo();
+
+ deleteButton = new JButton("Delete");
+ deleteButton.addActionListener( this );
+
+ mainPanel.add( scroll );
+ mainPanel.add( deleteButton );
+
+ return mainPanel;
+ }
+
+
+ private JPanel getButtonPanel(){
+ JPanel panel = new JPanel( new FlowLayout( FlowLayout.RIGHT ) );
+ okButton = new JButton("OK");
+ okButton.addActionListener( this );
+ resetDefaultsButton = new JButton("Restore Defaults");
+ resetDefaultsButton.addActionListener( this );
+ cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener( this );
+
+ panel.add( okButton );
+ panel.add( resetDefaultsButton );
+ panel.add( cancelButton );
+ return panel;
+ }
+
+
+ private void loadDefaultList(){
+ mDefaultListModel.clear();
+ for(int i = 1; i < mDefaultItems.length; i++){
+ mDefaultListModel.addElement( mDefaultItems[i] );
+ }
+ }
+
+ private void loadListFromCombo(){
+ DefaultComboBoxModel model = (DefaultComboBoxModel)itemsComboBox.getModel();
+ mDefaultListModel.clear();
+
+ for( int i = 1; i < model.getSize(); i++){
+ mDefaultListModel.addElement( model.getElementAt(i) );
+ }
+
+ }
+
+ private void updateComboBox(Enumeration e){
+ DefaultComboBoxModel model = (DefaultComboBoxModel)itemsComboBox.getModel();
+ model.removeAllElements();
+ model.addElement("-- Not Set --");
+
+ while( e.hasMoreElements() ){
+ model.addElement( (String)e.nextElement() );
+ }
+ }
+
+
+ //
+ // PropertyComponent Interface Methods
+ //
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+ public void setDataType(String aDataType) {
+ mDataType = aDataType;
+ }
+
+ public String getDataType() {
+ return mDataType;
+ }
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType) {
+ mVisualType = aVisualType;
+ }
+
+ public String getVisualType() {
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath) {
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath() {
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault) {
+ mDefault = aDefault;
+ }
+
+ public String getDefaultValue() {
+ return mDefault;
+ }
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+ public void setValue(String aValue) {
+ }
+
+ public String getValue() {
+ return (String)itemsComboBox.getSelectedItem();
+ }
+
+ public void setLabel(String aLabel) {
+ }
+
+ public String getLabel() {
+ return (String)itemsComboBox.getSelectedItem();
+ }
+
+ public boolean hasChanged() {
+ if( itemsComboBox.getSelectedIndex() != 0)
+ return true;
+ else
+ return false;
+ }
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel) {
+ mProfileModel = aProfileModel;
+ mPropertyListModel = mProfileModel.getListModel();
+
+ checkForLoadedProperty();
+ }
+
+
+ public void checkForLoadedProperty() {
+ PropertyComponent propComp = getListModel().existsByDataPath( mDataPath );
+ if( propComp instanceof PropertyComponent ){
+ updateLock = true;
+ clonePropertyComponent( propComp );
+
+ // Check if loaded value is in list, if so we select it
+ // and return, otherwise we have to add the item and select it.
+ //
+ for( int i = 0; i < itemsComboBox.getItemCount(); i++){
+ String item = (String)itemsComboBox.getItemAt(i);
+ if( item.equals( propComp.getValue() )){
+ getListModel().replaceItem(propComp, this);
+ itemsComboBox.setSelectedIndex(i);
+ return;
+ }
+ }
+ getListModel().replaceItem(propComp, this);
+
+ itemsComboBox.addItem( propComp.getValue() );
+ itemsComboBox.setSelectedItem( propComp.getValue() );
+ updateLock = false;
+ }
+ }
+
+ private void clonePropertyComponent(PropertyComponent propComp){
+ this.setChooserPath( propComp.getChooserPath() );
+ this.setDataPath( propComp.getDataPath() );
+ this.setDataType( propComp.getDataType() );
+ this.setDefaultName( propComp.getDefaultName() );
+ this.setDefaultValue( propComp.getDefaultValue() );
+ this.setDescriptionId( propComp.getDescriptionId() );
+ this.setExtendsChooser( propComp.getExtendsChooser() );
+ this.setPath( propComp.getPath() );
+ this.setResourceId( propComp.getResourceId() );
+ this.setResourceIdPath( propComp.getResourceIdPath() );
+ this.setSeperator( propComp.getSeperator() );
+ this.setVisualType( propComp.getVisualType() );
+ }
+
+ public void saveProperty() {
+ if( this.hasChanged() ){
+ mProfileModel.createProperty( this );
+ }
+ }
+
+ public PropertyJListModel getListModel() {
+ return mPropertyListModel;
+ }
+
+ public void reset() {
+ mProfileModel.removeProperty( this );
+ itemsComboBox.setSelectedIndex(0);
+ }
+
+
+
+ //
+ // ActionListener Interface Methods
+ //
+ public void actionPerformed(ActionEvent e) {
+
+ if( e.getSource() == editButton ){
+ showEditFrame();
+ }else if( e.getSource() == addButton || e.getSource() == mNewItemText ){
+ if( ! mNewItemText.getText().equals("") ){
+ mDefaultListModel.addElement( mNewItemText.getText() );
+ mNewItemText.setText("");
+ }
+ }else if( e.getSource() == deleteButton ){
+ if( ! mList.isSelectionEmpty() && ! mDefaultListModel.isEmpty() ){
+ mDefaultListModel.removeElementAt( mList.getSelectedIndex() );
+ }
+ }else if( e.getSource() == okButton ){
+ updateComboBox( mDefaultListModel.elements() );
+ frame.setVisible( false);
+ frame = null;
+ }else if( e.getSource() == resetDefaultsButton ){
+ loadDefaultList();
+ }else if( e.getSource() == cancelButton ){
+ frame.setVisible( false);
+ frame = null;
+ }else if( e.getSource() == itemsComboBox ){
+ updateJListModel();
+ }
+ }
+
+ private void updateJListModel(){
+
+ if( !updateLock ){
+ if( this.hasChanged() ) {
+ if( mPropertyListModel.exists( this ) ){
+ int index = mPropertyListModel.indexOf( this );
+ mPropertyListModel.removeItem( this );
+ mPropertyListModel.addItem( index, this );
+ }else{
+ mPropertyListModel.addItem( this );
+ }
+ }else {
+ if( mPropertyListModel.exists( this ) ){
+ mPropertyListModel.removeItem( this );
+ }
+ }
+ }
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyColorChooser.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyColorChooser.java
new file mode 100644
index 0000000..0660983
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyColorChooser.java
@@ -0,0 +1,423 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JColorChooser;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.border.Border;
+import javax.swing.border.SoftBevelBorder;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyColorChooser extends JPanel implements PropertyComponent, ActionListener, KeyListener, FocusListener {
+
+ // PropertyCompnent Interface
+ private boolean mIsSet = false;
+ private String mResourceId = null;
+ private String mDefaultName = null;
+ private String mDataType = null;
+ private String mSectionName = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefault = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileModel = null;
+
+ // Local Variables
+ private Border mBorder = null;
+ private Border mErrorBorder = null;
+ private String mHexChars = "0123456789abcdef";
+
+ private JTextField mColorField = null;
+ private ColourButton btnPickColor = null;
+
+
+ /** Creates a new instance of PropertyColorChooser */
+ public PropertyColorChooser() {
+ super();
+ this.setLayout( new BoxLayout(this, BoxLayout.LINE_AXIS) );
+ mColorField = new JTextField(20);
+ mColorField.addKeyListener(this);
+ mColorField.addFocusListener(this);
+
+ mBorder = mColorField.getBorder();
+ Color c1 = new Color(255,0,0);
+ Color c2 = new Color(139,0,0);
+ mErrorBorder = new SoftBevelBorder(1, c1, c2);
+
+ btnPickColor = new ColourButton();
+ btnPickColor.addActionListener(this);
+ btnPickColor.addActionListener(new ComponentListener());
+
+ this.add( mColorField );
+ this.add( btnPickColor );
+ }
+
+ private void pickColor(){
+
+ Color color = JColorChooser.showDialog(
+ null,
+ "Select a colour.",
+ Color.RED);
+
+ if( color != null ){
+ String red = Integer.toHexString( color.getRed() );
+ String green = Integer.toHexString( color.getGreen() );
+ String blue = Integer.toHexString( color.getBlue() );
+
+ if( red.length() < 2 ){
+ red = "0" + red;
+ }
+ if( green.length() < 2 ){
+ green = "0" + green;
+ }
+ if( blue.length() < 2 ){
+ blue = "0" + blue;
+ }
+
+ mColorField.setText( "#" + red + green + blue );
+ btnPickColor.setColor( color );
+ updateJListModel();
+ }
+ }
+
+
+ public boolean checkInput(){
+ mColorField.setBorder(mBorder);
+
+ if( !mColorField.getText().equals("") ){
+ String color = mColorField.getText();
+ if( color.charAt(0) == '#' ){
+ color = color.substring(1);
+ }
+
+ if( color.length() != 6 ){
+ mColorField.setBorder(mErrorBorder);
+ return false;
+ }
+
+ for(int i = 0; i < color.length(); i++){
+ String c = color.substring(i,i+1);
+ c = c.toLowerCase();
+ if( mHexChars.indexOf(c) == -1 ){
+ mColorField.setBorder(mErrorBorder);
+ return false;
+ }
+ }
+ }
+ return true;
+ }//end checkInput()
+
+
+ //
+ // PropertyComponent Interface methods
+ //
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+ public void setDataType(String aDataType){
+ mDataType = aDataType;
+ }
+
+ public String getDataType(){
+ return mDataType;
+ }
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType){
+ mVisualType = aVisualType;
+ }
+
+ public String getVisualType(){
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath){
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath(){
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault){
+ mDefault = aDefault;
+ mColorField.setText( mDefault );
+ btnPickColor.setColor( mDefault );
+ }
+
+ public String getDefaultValue(){
+ return mDefault;
+ }
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+
+ public void setValue(String s){
+ }
+
+ public String getValue(){
+ return mColorField.getText();
+ }
+
+ public void setLabel(String s){
+ }
+
+ public String getLabel(){
+ return mColorField.getText();
+ }
+
+
+ public boolean hasChanged(){
+
+ if( !checkInput() ){
+ return false;
+ }
+
+ String currentValue = mColorField.getText();
+
+ if( currentValue.equals( this.getDefaultValue() )
+ || currentValue.equals("") )
+ return false;
+ else{
+ btnPickColor.setColor( currentValue );
+ return true;
+ }
+ }
+
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel){
+ mProfileModel = aProfileModel;
+
+ checkForLoadedProperty();
+ }
+
+
+ public void checkForLoadedProperty() {
+
+ PropertyComponent propComp = getListModel().existsByDataPath( mDataPath );
+ if( propComp instanceof PropertyComponent ){
+ clonePropertyComponent(propComp);
+ mColorField.setText( propComp.getValue() );
+ getListModel().replaceItem(propComp, this);
+ }
+ }
+
+ private void clonePropertyComponent(PropertyComponent propComp){
+ this.setChooserPath( propComp.getChooserPath() );
+ this.setDataPath( propComp.getDataPath() );
+ this.setDataType( propComp.getDataType() );
+ this.setDefaultName( propComp.getDefaultName() );
+ this.setDefaultValue( propComp.getDefaultValue() );
+ this.setDescriptionId( propComp.getDescriptionId() );
+ this.setExtendsChooser( propComp.getExtendsChooser() );
+ this.setPath( propComp.getPath() );
+ this.setResourceId( propComp.getResourceId() );
+ this.setResourceIdPath( propComp.getResourceIdPath() );
+ this.setSeperator( propComp.getSeperator() );
+ this.setVisualType( propComp.getVisualType() );
+ }
+
+
+ public void saveProperty(){
+ if( this.hasChanged() && checkInput() ){
+ mProfileModel.createProperty( this );
+ }
+ }
+
+ public PropertyJListModel getListModel(){
+ return mProfileModel.getListModel();
+ }
+
+ public void reset(){
+ mProfileModel.removeProperty( this );
+ mColorField.setText( this.getDefaultValue() );
+ //mColorField.fireActionPerformed();
+ }
+
+ public String toString(){
+ String result = "Path: " + this.getDataPath();
+ result += "\nValue: " + (String)mColorField.getText();
+ return result;
+ }
+
+
+
+ //
+ // Interface methods for Listeners
+ //
+ public void actionPerformed(ActionEvent e) {
+ if( e.getSource() == btnPickColor ){
+ pickColor();
+ }
+ }
+
+ public void keyTyped(KeyEvent e) {
+ hasChanged();
+ }
+
+ public void keyPressed(KeyEvent e) {
+ hasChanged();
+ }
+
+ public void keyReleased(KeyEvent e) {
+ hasChanged();
+ }
+
+ public void focusGained(FocusEvent e) {
+ }
+
+ public void focusLost(FocusEvent e) {
+ updateJListModel();
+ }
+
+ private void updateJListModel(){
+
+ PropertyJListModel listModel = getListModel();
+
+ if( this.hasChanged() ){
+ if( listModel.exists( this ) ){
+ listModel.replaceItem(this, this);
+ System.out.println("replacing item");
+ //System.out.println("REMOVING FROM LIST BEFORE ADD: " + propComp.getDataPath() );
+ }else{
+ listModel.addItem( this );
+ System.out.println("adding item");
+ //System.out.println("ADDING TO LIST: " + propComp.getDataPath() );
+ }
+
+ }else {
+ if( listModel.exists( this ) ){
+ listModel.removeItem( this );
+ //System.out.println("REMOVING FROM LIST: " + propComp.getDataPath() );
+ }
+ }
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyColorSelector.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyColorSelector.java
new file mode 100644
index 0000000..a583599
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyColorSelector.java
@@ -0,0 +1,310 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import java.awt.Color;
+import javax.swing.JTextField;
+import javax.swing.border.Border;
+import javax.swing.border.SoftBevelBorder;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyColorSelector extends JTextField implements PropertyComponent {
+ // PropertyCompnent Interface
+ private boolean mIsSet = false;
+ private String mResourceId = null;
+ private String mDefaultName = null;
+ private String mDataType = null;
+ private String mSectionName = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefault = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileModel = null;
+
+ // Local Variables
+ private Border mBorder = null;
+ private Border mErrorBorder = null;
+ private String mHexChars = "0123456789abcdef";
+
+
+ public PropertyColorSelector() {
+ super();
+ mBorder = this.getBorder();
+ Color c1 = new Color(255,0,0);
+ Color c2 = new Color(139,0,0);
+ mErrorBorder = new SoftBevelBorder(1, c1, c2);
+ }
+
+ public boolean checkInput(){
+ this.setBorder(mBorder);
+
+ if( !this.getText().equals("") ){
+ String color = this.getText();
+ if( color.charAt(0) == '#' ){
+ color = color.substring(1);
+ }
+
+ if( color.length() != 6 ){
+ this.setBorder(mErrorBorder);
+ return false;
+ }
+
+ for(int i = 0; i < color.length(); i++){
+ String c = color.substring(i,i+1);
+ c = c.toLowerCase();
+ if( mHexChars.indexOf(c) == -1 ){
+ this.setBorder(mErrorBorder);
+ return false;
+ }
+ }
+ }
+ return true;
+ }//end checkInput()
+
+
+ //
+ // PropertyComponent Interface methods
+ //
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+ public void setDataType(String aDataType){
+ mDataType = aDataType;
+ }
+
+ public String getDataType(){
+ return mDataType;
+ }
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType){
+ mVisualType = aVisualType;
+ }
+
+ public String getVisualType(){
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath){
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath(){
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault){
+ mDefault = aDefault;
+ }
+
+ public String getDefaultValue(){
+ return mDefault;
+ }
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+
+ public void setValue(String s){
+ }
+
+ public String getValue(){
+ return this.getText();
+ }
+
+ public void setLabel(String s){
+ }
+
+ public String getLabel(){
+ return this.getText();
+ }
+
+
+ public boolean hasChanged(){
+
+ if( !checkInput() ){
+ return false;
+ }
+
+ String currentValue = this.getText();
+
+ if( currentValue.equals( this.getDefaultValue() )
+ || currentValue.equals("") )
+ return false;
+ else
+ return true;
+ }
+
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel){
+ mProfileModel = aProfileModel;
+
+ checkForLoadedProperty();
+ }
+
+
+ public void checkForLoadedProperty() {
+
+ PropertyComponent propComp = getListModel().existsByDataPath( mDataPath );
+ if( propComp instanceof PropertyComponent ){
+ clonePropertyComponent(propComp);
+ this.setText( propComp.getValue() );
+ getListModel().replaceItem(propComp, this);
+ }
+ }
+
+ private void clonePropertyComponent(PropertyComponent propComp){
+ this.setChooserPath( propComp.getChooserPath() );
+ this.setDataPath( propComp.getDataPath() );
+ this.setDataType( propComp.getDataType() );
+ this.setDefaultName( propComp.getDefaultName() );
+ this.setDefaultValue( propComp.getDefaultValue() );
+ this.setDescriptionId( propComp.getDescriptionId() );
+ this.setExtendsChooser( propComp.getExtendsChooser() );
+ this.setPath( propComp.getPath() );
+ this.setResourceId( propComp.getResourceId() );
+ this.setResourceIdPath( propComp.getResourceIdPath() );
+ this.setSeperator( propComp.getSeperator() );
+ this.setVisualType( propComp.getVisualType() );
+ }
+
+
+ public void saveProperty(){
+ if( this.hasChanged() && checkInput() ){
+ mProfileModel.createProperty( this );
+ }
+ }
+
+ public PropertyJListModel getListModel(){
+ return mProfileModel.getListModel();
+ }
+
+ public void reset(){
+ mProfileModel.removeProperty( this );
+ this.setText( this.getDefaultValue() );
+ this.fireActionPerformed();
+ }
+
+ public String toString(){
+ String result = "Path: " + this.getDataPath();
+ result += "\nValue: " + (String)this.getText();
+ return result;
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyComponent.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyComponent.java
new file mode 100644
index 0000000..f90b50a
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyComponent.java
@@ -0,0 +1,141 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+
+/**
+ *
+ * @author cs202741
+ */
+public interface PropertyComponent {
+
+ void setIsSetProperty(boolean isSet);
+
+ boolean isSetProperty();
+
+
+ void setDataType(String aDataType);
+
+ String getDataType();
+
+
+ void setVisualType(String aVisualType);
+
+ String getVisualType();
+
+
+ void setResourceId(String aResourceId);
+
+ String getResourceId();
+
+
+ void setDefaultName(String aDefaultName);
+
+ String getDefaultName();
+
+
+ void setSectionName(String aSectionName);
+
+ String getSectionName();
+
+
+ void setPath(String aPath);
+
+ String getPath();
+
+
+ void setResourceIdPath(String aResourceIdPath);
+
+ String getResourceIdPath();
+
+
+ void setDataPath(String aDataPath);
+
+ String getDataPath();
+
+
+ void setDefaultValue(String aDefault);
+
+ String getDefaultValue();
+
+
+ void setValue(String aValue);
+
+ String getValue();
+
+
+ void setLabel(String aLabel);
+
+ String getLabel();
+
+
+ void setSeperator(String aSeperator);
+
+ String getSeperator();
+
+
+ void setDescriptionId(String aDescriptionId);
+
+ String getDescriptionId();
+
+
+ void setChooserPath(String aChooserPath);
+
+ String getChooserPath();
+
+
+ void setExtendsChooser(String aExtendsChooser);
+
+ String getExtendsChooser();
+
+
+ void checkForLoadedProperty();
+
+
+ boolean hasChanged();
+
+ void setProfileModel(StandaloneProfileManager aProfileModel);
+
+ void saveProperty();
+
+
+ PropertyJListModel getListModel();
+
+ void reset();
+
+ String toString();
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJComboBox.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJComboBox.java
new file mode 100644
index 0000000..7fee4e8
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJComboBox.java
@@ -0,0 +1,280 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import javax.swing.ComboBoxModel;
+import javax.swing.JComboBox;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyJComboBox extends JComboBox implements PropertyComponent {
+
+ // PropertyComponent variables
+ private boolean mIsSet = false;
+ private String mResourceId = null;
+ private String mDefaultName = null;
+ private String mValue = null;
+ private String mSectionName = null;
+ private String mLabel = null;
+ private String mDataType = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefault = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileModel = null;
+
+
+
+ public PropertyJComboBox(ComboBoxModel model){
+ super(model);
+ }
+
+ public PropertyJComboBox() {
+ super();
+ }
+
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+ public void setDataType(String aDataType){
+ mDataType = aDataType;
+ }
+
+ public String getDataType(){
+ return mDataType;
+ }
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType){
+ mVisualType = aVisualType;
+ }
+
+ public String getVisualType(){
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath){
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath(){
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault){
+ mDefault = aDefault;
+ }
+
+ public String getDefaultValue(){
+ return mDefault;
+ }
+
+ public boolean hasChanged(){
+
+ if( this.getSelectedIndex() == 0 ){
+ return false;
+ }else
+ return true;
+ }
+
+ public void setValue(String aValue){
+ mValue = aValue;
+ }
+
+ public String getValue(){
+ return ((ComboBoxElement)this.getSelectedItem()).getValue();
+ }
+
+ public void setLabel(String aLabel){
+ mLabel = aLabel;
+ }
+
+ public String getLabel(){
+ return ((ComboBoxElement)this.getSelectedItem()).getLabel();
+ }
+
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel){
+ mProfileModel = aProfileModel;
+ checkForLoadedProperty();
+ }
+
+
+ public void checkForLoadedProperty() {
+ PropertyComponent propComp = getListModel().existsByDataPath( mDataPath );
+ if( propComp instanceof PropertyComponent ){
+ clonePropertyComponent(propComp);
+
+ //
+ // Go through comboBox elements and select
+ // the value that matches the one loaded.
+ //
+ String value = propComp.getValue();
+ for( int i = 0; i < this.getModel().getSize(); i++){
+ String elementValue = ((ComboBoxElement)this.getItemAt(i)).getValue();
+ if( elementValue.equals( value ) ){
+ getListModel().replaceItem(propComp, this);
+ this.setSelectedIndex(i);
+ return;
+ }
+ }
+ getListModel().replaceItem(propComp, this);
+ }
+ }
+
+ private void clonePropertyComponent(PropertyComponent propComp){
+ this.setChooserPath( propComp.getChooserPath() );
+ this.setDataPath( propComp.getDataPath() );
+ this.setDataType( propComp.getDataType() );
+ this.setDefaultName( propComp.getDefaultName() );
+ this.setDefaultValue( propComp.getDefaultValue() );
+ this.setDescriptionId( propComp.getDescriptionId() );
+ this.setExtendsChooser( propComp.getExtendsChooser() );
+ this.setPath( propComp.getPath() );
+ this.setResourceId( propComp.getResourceId() );
+ this.setResourceIdPath( propComp.getResourceIdPath() );
+ this.setSeperator( propComp.getSeperator() );
+ this.setVisualType( propComp.getVisualType() );
+ }
+
+ public void saveProperty(){
+ if( this.hasChanged() ){
+ mProfileModel.createProperty( this );
+ }
+ }
+
+ public PropertyJListModel getListModel(){
+ return mProfileModel.getListModel();
+ }
+
+ public void reset(){
+ mProfileModel.removeProperty( this );
+ this.setSelectedIndex( 0 );
+ }
+
+ public String toString(){
+ String result = "Path: " + this.getDataPath();
+ result += "\nValue: " + this.getSelectedItem().toString();
+ return result;
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJLabel.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJLabel.java
new file mode 100644
index 0000000..10ad947
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJLabel.java
@@ -0,0 +1,129 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.Subscriber;
+import javax.swing.JLabel;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyJLabel extends JLabel implements Subscriber{
+
+ private final static int MAX_LINE_CHARS = 50;
+
+ // Subscriber Interface Variables
+ private String mResourceId = null;
+ private String mPackageName = null;
+ private String mDefaultName = null;
+ private LocaleManager mLocaleManager;
+
+
+ /** Creates a new instance of PropertyJLabel */
+ public PropertyJLabel() {
+ super();
+ }
+
+
+ private String formatText(String text){
+ if( text == null )
+ return text;
+
+ String result = "";
+ String current = text;
+ while(true){
+
+ if( current.length() < MAX_LINE_CHARS ){
+ break;
+ }
+
+ for( int i = MAX_LINE_CHARS-1; i >= 0; i-- ){
+ if( current.charAt(i) == ' ' ){
+ result += "<br>" + current.substring(0, i);
+ current = current.substring(i+1);
+ break;
+ }
+ }
+
+ }
+ result += "<br>" + current;
+ if( result.startsWith("<br>") ){
+ result = result.substring(4);
+ }
+
+ return "<html>" + result + "</html>";
+ }
+
+ public void setText(String text){
+ text = formatText(text);
+ if(text == null){
+ text = mResourceId;
+ }
+ super.setText( text );
+ }
+
+
+ //
+ // PropertComponent Interface Methods
+ //
+ public void update() {
+ String text = formatText( mLocaleManager.getLocalizedName(mResourceId, mDefaultName) );
+ if(text == null){
+ text = mResourceId;
+ }
+
+ super.setText( text );
+ }
+
+ public void setResourceId(String id){
+ mResourceId = id;
+ }
+
+ public void setPackageName(String name){
+ mPackageName = name;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public void setLocaleManager(LocaleManager aLocaleManager){
+ mLocaleManager = aLocaleManager;
+ mLocaleManager.attach( this );
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJList.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJList.java
new file mode 100644
index 0000000..c4f909e
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJList.java
@@ -0,0 +1,199 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.gui.ImageButton;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJListModel;
+import com.sun.apoc.tools.profileeditor.gui.ImageButtonMouseListener;
+import com.sun.apoc.tools.profileeditor.gui.PropertyComponent;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyJList extends JList {
+ static Color listForeground, listBackground,
+ listSelectionForeground, listSelectionBackground,
+
+ listEven1, listEven2,
+ listOdd1, listOdd2,
+ listSelection1, listSelection2;
+
+ static {
+ UIDefaults uid = UIManager.getLookAndFeel().getDefaults();
+ listForeground = uid.getColor("List.forground");
+ listBackground = uid.getColor("List.background");
+
+ listEven1 = new Color(0xFFFFFF);
+ listEven2 = new Color(0xE5EBE9);
+ listOdd1 = new Color(0xE5EBE9);
+ listOdd2 = new Color(0xCBCFD5);
+
+ listSelection1 = new Color(0x81939B);
+ listSelection2 = new Color(0xBEC7CC);
+ }
+
+ JComponent propertyCell;
+ JLabel propertyNameLabel, dataTypeLabel, valueLabel, pathLabel;
+ ImageIcon closeIcon;
+ JButton imageButton;
+ /** Creates a new instance of PropertyJList */
+ public PropertyJList(PropertyJListModel aListModel) {
+ super(aListModel);
+ buildCells();
+ this.setCellRenderer(new PropertyRenderer() );
+ }
+
+
+ protected void buildCells(){
+
+ propertyCell = new GradientJPanel(new Color(0xCBCFD5), new Color(0xFFFFFF),
+ GradientJPanel.ROUNDED_NONE, 0, 0);
+ propertyCell.setLayout( new GridBagLayout() );
+
+ propertyNameLabel = new JLabel();
+ Font defaultFont = propertyNameLabel.getFont();
+ Font defaultLabelFont = defaultFont.deriveFont( Font.PLAIN, defaultFont.getSize() - 2);
+ Font nameFont = defaultFont.deriveFont( Font.BOLD, defaultFont.getSize() - 1);
+ propertyNameLabel.setFont( nameFont );
+ addWithGridBag( propertyNameLabel, propertyCell,
+ 1, 0, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 1, 0);
+
+ dataTypeLabel = new JLabel();
+ dataTypeLabel.setFont( defaultLabelFont );
+ addWithGridBag( dataTypeLabel, propertyCell,
+ 1, 1, 1, 1,
+ GridBagConstraints.WEST,
+ GridBagConstraints.NONE, 1, 0);
+
+ closeIcon = new ImageIcon( "images/close.png" );
+ imageButton = new ImageButton(closeIcon);
+ imageButton.addMouseListener( new ImageButtonMouseListener(this) );
+
+ addWithGridBag(imageButton, propertyCell,
+ 2, 0, 1, 2,
+ GridBagConstraints.EAST,
+ GridBagConstraints.NONE, 1, 1);
+
+ opacify(propertyCell);
+ }
+
+ private void addWithGridBag(Component comp, Container cont,
+ int x, int y,
+ int width, int height,
+ int anchor, int fill,
+ int weightx, int weighty){
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridx = x;
+ gbc.gridy = y;
+ gbc.gridwidth = width;
+ gbc.gridheight = height;
+ gbc.anchor = anchor;
+ gbc.fill = fill;
+ gbc.weightx = weightx;
+ gbc.weighty = weighty;
+ cont.add(comp, gbc);
+ }
+
+ private void opacify(Container cont){
+ Component[] comps = cont.getComponents();
+
+ for(int i = 0; i < comps.length; i++){
+ if(comps[i] instanceof JComponent){
+ ((JComponent)comps[i]).setOpaque(false);
+ }
+ }
+ }
+
+
+ public class PropertyRenderer extends Object implements ListCellRenderer{
+
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus){
+
+ if( value instanceof PropertyComponent ){
+ int numRows = list.getModel().getSize();
+ String dataType = ((PropertyComponent)value).getDataType();
+ dataType = dataType.substring( dataType.indexOf(":") + 1 );
+ String valueString = ((PropertyComponent)value).getValue();
+ String labelString = ((PropertyComponent)value).getLabel();
+
+ String name = ((PropertyComponent)value).getDataPath();
+
+ propertyNameLabel.setText(name);
+ dataTypeLabel.setText( dataType + ": " + valueString + " ( " + labelString + " )");
+ setColorsForSelectionState( propertyCell, isSelected, index, numRows );
+ }
+
+ return propertyCell;
+ }
+
+
+ private void setColorsForSelectionState(Container cont, boolean isSelected,
+ int index, int rows){
+
+ Component[] comps = cont.getComponents();
+
+ if(isSelected){
+ ((GradientJPanel)cont).setColours(listSelection1, listSelection2);
+ }else{
+ if(index % 2 == 0){
+ ((GradientJPanel)cont).setColours(listEven2, listEven1);
+ }else
+ ((GradientJPanel)cont).setColours(listOdd1, listOdd2);
+ }
+ }//end setColorsForSelectionState()
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJListModel.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJListModel.java
new file mode 100644
index 0000000..9782605
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJListModel.java
@@ -0,0 +1,194 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.*;
+import com.sun.apoc.tools.profileeditor.gui.PropertyComponent;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Vector;
+import javax.swing.AbstractListModel;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyJListModel extends AbstractListModel {
+ private Vector mProperties = null;
+ private ProfileEditor mProfileEditor = null;
+
+ // if 'locked' then model will not fire
+ // contents changed event. This is to
+ // stop a redraw of the summary view after
+ // each component is added
+ private boolean locked = false;
+
+
+ /** Creates a new instance of PropertyListModel */
+ public PropertyJListModel(ProfileEditor profileEditor) {
+ mProperties = new Vector();
+ mProfileEditor = profileEditor;
+ }
+
+ public int getSize(){
+ return mProperties.size();
+ }
+
+ public Object getElementAt( int index ){
+ return mProperties.get( index );
+ }
+
+ public void addItem(PropertyComponent aComponent){
+ mProperties.add(aComponent);
+ if(!locked){
+ this.fireContentsChanged(this, mProperties.size()-1, mProperties.size() );
+ mProfileEditor.updateSavedState();
+ }
+ }
+
+ public void addItem(int index, PropertyComponent aComponent){
+ mProperties.add(index, aComponent);
+ if(!locked){
+ this.fireContentsChanged(this, mProperties.size()-1, mProperties.size() );
+ mProfileEditor.updateSavedState();
+ }
+ }
+
+ public void addAll(Collection c){
+ mProperties.addAll(c);
+ if(!locked){
+ this.fireContentsChanged(this, 0, mProperties.size() );
+ mProfileEditor.updateSavedState();
+ }
+ }
+
+ public boolean exists(PropertyComponent aComponent){
+ return mProperties.contains(aComponent);
+ }
+
+ public PropertyComponent existsByDataPath(String aDataPath){
+
+ for(int i = 0; i < mProperties.size(); i++){
+ PropertyComponent propComp = (PropertyComponent)mProperties.get(i);
+ if( propComp.getDataPath().equals( aDataPath ) ){
+ return propComp;
+ }
+ }
+
+ return null;
+ }
+
+
+ public int indexOf(PropertyComponent aComponent){
+
+ for(int i = 0; i < mProperties.size(); i++){
+ PropertyComponent propComp = (PropertyComponent)mProperties.get(i);
+ if( propComp.getDataPath().equals( aComponent.getDataPath() ) ){
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+
+
+ public void replaceItem(PropertyComponent aComponent, PropertyComponent aReplacement){
+ mProperties.remove( aComponent );
+ mProperties.add(aReplacement);
+ if(!locked){
+ this.fireContentsChanged(this, 0, mProperties.size());
+ mProfileEditor.updateSavedState();
+ }
+ }
+
+
+ public void removeItem(PropertyComponent aComponent){
+ mProperties.remove( aComponent );
+ if(!locked){
+ this.fireContentsChanged(this, 0, mProperties.size() );
+ mProfileEditor.updateSavedState();
+ }
+ }
+
+ public void removeItem(int index){
+
+ if( index < mProperties.size() ){
+ mProperties.removeElementAt( index );
+ if(!locked){
+ this.fireContentsChanged(this, 0, mProperties.size() );
+ mProfileEditor.updateSavedState();
+ }
+ }
+ }
+
+ public void removeAll(){
+ mProperties.clear();
+ this.fireContentsChanged(this, 0, mProperties.size() );
+ mProfileEditor.updateSavedState();
+ }
+
+ public Enumeration elements(){
+ return mProperties.elements();
+ }
+
+ public void setLocked(boolean lock){
+ locked = lock;
+ }
+
+ public Object getPropertyVector(){
+ return mProperties.clone();
+ }
+
+ public void printItems(){
+ int count = 0;
+ Iterator it = mProperties.iterator();
+ while(it.hasNext()){
+ System.err.println("PROPERTY" + count++ + ": " + ((PropertyComponent)it.next()).getDataPath() );
+ }
+ }
+
+ //
+ // Used to force a redraw of the summary view
+ // after properties have been added or removed
+ //
+ public void notifyListeners(){
+ this.fireContentsChanged(this, 0, mProperties.size() );
+ mProfileEditor.updateSavedState();
+ }
+
+}//end class
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJListPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJListPanel.java
new file mode 100644
index 0000000..6de283d
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJListPanel.java
@@ -0,0 +1,172 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.*;
+import com.sun.apoc.tools.profileeditor.packages.Template;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import javax.swing.CellRendererPane;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyJListPanel extends JPanel {
+ private JList mList = null;
+ private JButton mClearButton = null;
+ private PropertyJListModel mListModel = null;
+ //private Template mFilterTemplate = null;
+
+ /** Creates a new instance of PropertyListPanel */
+ public PropertyJListPanel(PropertyJListModel aListModel) {
+ super( new BorderLayout() );
+ mListModel = aListModel;
+
+ GradientJPanel buttonPanel = new GradientJPanel(new Color(0xCBCFD5), new Color(0xFFFFFF),
+ GradientJPanel.ROUNDED_NONE, 0, 0);
+ buttonPanel.setLayout( new FlowLayout(FlowLayout.LEFT) );
+
+ mClearButton = new JButton("Clear All");
+ mClearButton.addActionListener( new FilterBoxActionListener() );
+
+ buttonPanel.add( mClearButton );
+
+ mList = new PropertyJList(aListModel);
+ mList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ mList.addMouseListener( new PropertyJListButtonMouseListener() );
+
+ JScrollPane scrollPane = new JScrollPane( mList );
+
+ this.add(buttonPanel, BorderLayout.PAGE_START );
+ this.add(scrollPane, BorderLayout.CENTER );
+ }
+
+
+ class FilterBoxActionListener implements ActionListener {
+
+ public void actionPerformed(ActionEvent e) {
+
+ if( e.getSource() == mClearButton ){
+ ArrayList list = new ArrayList();
+ Enumeration en = mListModel.elements();
+ while(en.hasMoreElements()){
+ list.add( (PropertyComponent)en.nextElement() );
+ }
+ Iterator it = list.iterator();
+ while( it.hasNext() )
+ ((PropertyComponent)it.next()).reset();
+ }
+ }
+ }
+
+ class PropertyJListButtonMouseListener implements MouseListener {
+
+ private void forwardEventToButton(MouseEvent event){
+ JList list = (PropertyJList)event.getSource();
+
+ PropertyJListModel model = (PropertyJListModel)list.getModel();
+
+ JButton button = null;
+ MouseEvent buttonEvent = null;
+
+ if( list.isSelectionEmpty() || (model.getSize() == 0) ){
+ return;
+ }
+
+ if( ! (list.getComponent( 0 ) instanceof CellRendererPane) ){
+ return;
+ }
+
+ CellRendererPane cellPane = (CellRendererPane)list.getComponent(0);
+
+ JPanel panel = (JPanel)cellPane.getComponent(0);
+ Component[] comps = panel.getComponents();
+
+ for(int i = 0;i<comps.length;i++){
+ if( comps[i] instanceof ImageButton ){
+ button = (ImageButton)comps[i];
+ }
+ }
+
+ if( button == null ){
+ return;
+ }
+
+ buttonEvent = (MouseEvent)SwingUtilities.convertMouseEvent(list, event, button);
+ button.dispatchEvent(buttonEvent);
+ list.repaint();
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ JList list = (PropertyJList)e.getSource();
+ if( !list.isSelectionEmpty() ){
+ forwardEventToButton(e);
+ }
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ //forwardEventToButton(e);
+ }
+
+ public void mouseExited(MouseEvent e) {
+ //forwardEventToButton(e);
+ }
+
+ public void mousePressed(MouseEvent e) {
+ //forwardEventToButton(e);
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ //forwardEventToButton(e);
+ }
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJPasswordField.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJPasswordField.java
new file mode 100644
index 0000000..ae94d32
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJPasswordField.java
@@ -0,0 +1,268 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import javax.swing.JPasswordField;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyJPasswordField extends JPasswordField implements PropertyComponent {
+
+ // PropertyCompnent Interface Variables
+ private boolean mIsSet = false;
+ private String mResourceId = null;
+ private String mDefaultName = null;
+ private String mDataType = null;
+ private String mSectionName = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefault = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileModel = null;
+
+ /** Creates a new instance of PropertyJTextField */
+ public PropertyJPasswordField(int length) {
+ super(length);
+ }
+
+ //
+ // PropertyComponent Interface Methods
+ //
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+
+ public void setDataType(String aDataType){
+ mDataType = aDataType;
+ }
+
+ public String getDataType(){
+ return mDataType;
+ }
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType){
+ mVisualType = aVisualType;
+ }
+
+ public String getVisualType(){
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath){
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath(){
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault){
+ mDefault = aDefault;
+ }
+
+ public String getDefaultValue(){
+ return mDefault;
+ }
+
+ public boolean hasChanged(){
+
+ String currentValue = new String( this.getPassword() );
+
+ if( currentValue.equals( this.getDefaultValue() )
+ || currentValue.equals("") )
+ return false;
+ else
+ return true;
+ }
+
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+ public void setValue(String s){
+
+ }
+
+ public String getValue(){
+ char[] pword = this.getPassword();
+ return new String( pword );
+ }
+
+ public void setLabel(String s){
+
+ }
+
+ public String getLabel(){
+ return "*PASSWORD*";
+ }
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel){
+ mProfileModel = aProfileModel;
+
+ checkForLoadedProperty();
+ }
+
+
+ public void checkForLoadedProperty() {
+ PropertyComponent propComp = getListModel().existsByDataPath( mDataPath );
+ if( propComp instanceof PropertyComponent ){
+ clonePropertyComponent(propComp);
+
+ this.setText( propComp.getValue() );
+ getListModel().replaceItem(propComp, this);
+ }
+ }
+
+ private void clonePropertyComponent(PropertyComponent propComp){
+ this.setChooserPath( propComp.getChooserPath() );
+ this.setDataPath( propComp.getDataPath() );
+ this.setDataType( propComp.getDataType() );
+ this.setDefaultName( propComp.getDefaultName() );
+ this.setDefaultValue( propComp.getDefaultValue() );
+ this.setDescriptionId( propComp.getDescriptionId() );
+ this.setExtendsChooser( propComp.getExtendsChooser() );
+ this.setPath( propComp.getPath() );
+ this.setResourceId( propComp.getResourceId() );
+ this.setResourceIdPath( propComp.getResourceIdPath() );
+ this.setSeperator( propComp.getSeperator() );
+ this.setValue( propComp.getValue() );
+ this.setVisualType( propComp.getVisualType() );
+ }
+
+ public void saveProperty(){
+ if( this.hasChanged() ){
+ mProfileModel.createProperty( this );
+ }
+ }
+
+ public PropertyJListModel getListModel(){
+ return mProfileModel.getListModel();
+ }
+
+ public void reset(){
+ mProfileModel.removeProperty( this );
+ this.setText( this.getDefaultValue() );
+ this.fireActionPerformed();
+ }
+
+ public String toString(){
+ return "Password: " + new String( this.getPassword() );
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJRadioButtonGroupPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJRadioButtonGroupPanel.java
new file mode 100644
index 0000000..4f10d30
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJRadioButtonGroupPanel.java
@@ -0,0 +1,403 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.Subscriber;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyJRadioButtonGroupPanel extends JPanel implements PropertyComponent, Subscriber {
+ private static final int MAX_LINE_CHARS = 50;
+
+
+ // PropertyComponent Interface variables
+ private boolean mIsSet = false;
+ private String mDefaultName = null;
+ private String mLabel = null;
+ private String mSectionName = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+ private String mDataType = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefault = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileModel = null;
+
+
+ // Subscriber Interface Variables
+ private String mResourceId = null;
+ private String mPackageName = null;
+ private LocaleManager mLocaleManager;
+
+ // Local variabels
+ private JRadioButton[] mRadioButtons = null;
+ private ButtonGroup mButtonGroup = null;
+ private int index = 0;
+ private int defaultIndex = 0;
+
+ /** Creates a new instance of PropertyJRadioButton */
+ public PropertyJRadioButtonGroupPanel(int size) {
+ this.setLayout( new BoxLayout( this, BoxLayout.PAGE_AXIS ) );
+ this.setOpaque(false);
+
+ mRadioButtons = new JRadioButton[size+1];
+ mButtonGroup = new ButtonGroup();
+ mRadioButtons[index] = new JRadioButton("-- Not Set --");
+ mRadioButtons[index].setSelected( true );
+ mRadioButtons[index].addActionListener( new PropertyJRadioButtonListener( this ) );
+ mRadioButtons[index].setOpaque(false);
+ mButtonGroup.add( mRadioButtons[index] );
+ this.add( mRadioButtons[index] );
+ index++;
+ }
+
+ public void addRadioButton(String value){
+
+ String name = mLocaleManager.getLocalizedName( mPackageName, mResourceId + "." + value, null );
+ if(name == null){
+ name = value;
+ }
+
+ mRadioButtons[index] = new JRadioButton( formatText(name) );
+ mRadioButtons[index].setName(value);
+ mRadioButtons[index].addActionListener( new PropertyJRadioButtonListener( this ) );
+ mRadioButtons[index].setOpaque(false);
+ if( value.equals( this.getDefaultValue() ) ){
+ mRadioButtons[index].setText( mRadioButtons[index].getText() + " *" );
+ defaultIndex = index;
+ }
+
+ mButtonGroup.add( mRadioButtons[index] );
+ this.add( mRadioButtons[index] );
+ index++;
+ }
+
+ private String formatText(String text){
+ if( text == null || text.length() < MAX_LINE_CHARS ){
+ return text;
+ }
+
+ String result = "";
+ String current = text;
+ while(true){
+ if( current.length() < MAX_LINE_CHARS ){
+ break;
+ }
+
+ for( int i = MAX_LINE_CHARS-1; i >= 0; i-- ){
+ if( current.charAt(i) == ' ' ){
+ result += "<br>" + current.substring(0, i);
+ current = current.substring(i+1);
+ break;
+ }
+ }
+ }
+ result += "<br>" + current;
+ if( result.startsWith("<br>") ){
+ result = result.substring(4);
+ }
+
+ return "<html>" + result + "</html>";
+ }
+
+
+ //
+ // PropertyComponent Interface Methods
+ //
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+
+ public void setDataType(String aDataType){
+ mDataType = aDataType;
+ }
+
+ public String getDataType(){
+ return mDataType;
+ }
+
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType){
+ mVisualType = aVisualType;
+ }
+
+ public String getVisualType(){
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath){
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath(){
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault){
+ mDefault = aDefault;
+ }
+
+ public String getDefaultValue(){
+ return mDefault;
+ }
+
+
+ public boolean hasChanged(){
+ if( mRadioButtons[0].isSelected() )
+ return false;
+ else
+ return true;
+ }
+
+ public void setValue(String aValue){
+ //mValue = aValue;
+ }
+
+ public String getValue(){
+ String result = null;
+
+ for(int i = 0; i < mRadioButtons.length; i++){
+ if( mRadioButtons[i].isSelected() ){
+ result = mRadioButtons[i].getName();
+ }
+ }
+
+ return result;
+ }
+
+ public void setLabel(String aLabel){
+ mLabel = aLabel;
+ }
+
+ public String getLabel(){
+ String result = null;
+
+ for(int i = 0; i < mRadioButtons.length; i++){
+ if( mRadioButtons[i].isSelected() ){
+ result = mRadioButtons[i].getText();
+ }
+ }
+ return result;
+ }
+
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel){
+ mProfileModel = aProfileModel;
+
+ checkForLoadedProperty();
+ }
+
+
+ public void checkForLoadedProperty() {
+ PropertyComponent propComp = getListModel().existsByDataPath( mDataPath );
+ if( propComp instanceof PropertyComponent ){
+ clonePropertyComponent( propComp );
+
+ //
+ // Loop through radioButtons and select the one
+ // matching the loaded value.
+ //
+ for( int i = 1; i < mRadioButtons.length; i++){
+ if( mRadioButtons[i].getName().equals( propComp.getValue() ) ){
+ getListModel().replaceItem(propComp, this);
+ mRadioButtons[i].doClick();
+ return;
+ }
+ }
+ getListModel().replaceItem(propComp, this);
+ }
+ }
+
+ private void clonePropertyComponent(PropertyComponent propComp){
+ this.setChooserPath( propComp.getChooserPath() );
+ this.setDataPath( propComp.getDataPath() );
+ this.setDataType( propComp.getDataType() );
+ this.setDefaultName( propComp.getDefaultName() );
+ this.setDefaultValue( propComp.getDefaultValue() );
+ this.setDescriptionId( propComp.getDescriptionId() );
+ this.setExtendsChooser( propComp.getExtendsChooser() );
+ this.setPath( propComp.getPath() );
+ this.setResourceId( propComp.getResourceId() );
+ this.setResourceIdPath( propComp.getResourceIdPath() );
+ this.setSeperator( propComp.getSeperator() );
+ this.setValue( propComp.getValue() );
+ this.setVisualType( propComp.getVisualType() );
+ }
+
+
+ public void saveProperty(){
+ if( this.hasChanged() ){
+ mProfileModel.createProperty( this );
+ }
+ }
+
+
+ public PropertyJListModel getListModel(){
+ return mProfileModel.getListModel();
+ }
+
+
+ public void reset(){
+ mProfileModel.removeProperty( this );
+ mRadioButtons[0].doClick();
+ }
+
+ public String toString(){
+ String result = "Path: " + this.getDataPath();
+ result += "\nValue: ";
+ return result;
+ }
+
+
+ //
+ // Subscriber Interface Methods
+ //
+ public void setPackageName(String aPackageName){
+ mPackageName = aPackageName;
+ }
+
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+
+ public void setLocaleManager(LocaleManager aLocaleManager) {
+ mLocaleManager = aLocaleManager;
+ mLocaleManager.attach( this );
+ }
+
+
+ public void update() {
+ for(int i = 1; i < mRadioButtons.length; i++){
+ String name = mLocaleManager.getLocalizedName( mPackageName, mResourceId+"."+mRadioButtons[i].getName(), null );
+ if(name == null){
+ name = mRadioButtons[i].getName();
+ }
+ mRadioButtons[i].setText( formatText( name ) );
+ }
+ mRadioButtons[defaultIndex].setText( mRadioButtons[defaultIndex].getText() + " *" );
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJRadioButtonListener.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJRadioButtonListener.java
new file mode 100644
index 0000000..e75ac4c
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJRadioButtonListener.java
@@ -0,0 +1,76 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JRadioButton;
+
+/**
+ *
+ * @author csmith
+ */
+public class PropertyJRadioButtonListener implements ActionListener{
+ PropertyJRadioButtonGroupPanel mRadioPanel = null;
+
+ public PropertyJRadioButtonListener(PropertyJRadioButtonGroupPanel aRadioPanel) {
+ mRadioPanel = aRadioPanel;
+ }
+
+ public void actionPerformed(ActionEvent event) {
+ if( event.getSource() instanceof JRadioButton ){
+ this.updateJListModel();
+ }
+ }
+
+ private void updateJListModel(){
+ PropertyJListModel listModel = mRadioPanel.getListModel();
+
+ if( mRadioPanel.hasChanged() ) {
+ if( listModel.exists( mRadioPanel ) ){
+ int index = listModel.indexOf( mRadioPanel );
+ listModel.removeItem( mRadioPanel );
+ listModel.addItem( index, mRadioPanel );
+ }else{
+ listModel.addItem( mRadioPanel );
+ }
+ }else {
+ if( listModel.exists( mRadioPanel ) ){
+ listModel.removeItem( mRadioPanel );
+ }
+ }
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyJTextField.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJTextField.java
new file mode 100644
index 0000000..6650bc8
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyJTextField.java
@@ -0,0 +1,311 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import java.awt.Color;
+import javax.swing.JTextField;
+import javax.swing.border.Border;
+import javax.swing.border.SoftBevelBorder;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyJTextField extends JTextField implements PropertyComponent {
+
+ // PropertyComponent Interface Methods
+ private boolean mIsSet = false;
+ private String mResourceId = null;
+ private String mDefaultName = null;
+ private String mDataType = null;
+ private String mSectionName = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefault = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileModel = null;
+
+
+ private Border mBorder = null;
+ private Border mErrorBorder = null;
+
+ /** Creates a new instance of PropertyJTextField */
+ public PropertyJTextField() {
+ super();
+ mBorder = this.getBorder();
+ Color c1 = new Color(255,0,0);
+ Color c2 = new Color(139,0,0);
+ mErrorBorder = new SoftBevelBorder(1, c1, c2);
+ }
+
+ public boolean checkInput(){
+ this.setBorder(mBorder);
+
+ if( !this.getText().equals("") ){
+ if(mDataType.equals("xs:int")){
+ try{
+ Integer.parseInt( this.getText() );
+ }catch(NumberFormatException nfe){
+ this.setBorder(mErrorBorder);
+ return false;
+ }
+ }else if(mDataType.equals("xs:short")){
+ try{
+ Integer.parseInt( this.getText() );
+ }catch(NumberFormatException nfe){
+ this.setBorder(mErrorBorder);
+ return false;
+ }
+ }else if(mDataType.equals("xs:double")){
+ try{
+ Integer.parseInt( this.getText() );
+ }catch(NumberFormatException nfe){
+ this.setBorder(mErrorBorder);
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }//end checkInput()
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+
+ public void setDataType(String aDataType){
+ mDataType = aDataType;
+ }
+
+ public String getDataType(){
+ return mDataType;
+ }
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType){
+ mVisualType = aVisualType;
+ }
+
+ public String getVisualType(){
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath){
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath(){
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault){
+ mDefault = aDefault;
+ }
+
+ public String getDefaultValue(){
+ return mDefault;
+ }
+
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+ public void setValue(String s){
+ this.setText(s);
+ }
+
+ public String getValue(){
+ return this.getText();
+ }
+
+ public void setLabel(String s){
+
+ }
+
+ public String getLabel(){
+ return this.getText();
+ }
+
+ public boolean hasChanged(){
+
+ if( !checkInput() ){
+ return false;
+ }
+
+ String currentValue = this.getText();
+
+ if( currentValue.equals( this.getDefaultValue() )
+ || currentValue.equals("") )
+ return false;
+ else
+ return true;
+ }
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel){
+ mProfileModel = aProfileModel;
+
+ checkForLoadedProperty();
+ }
+
+
+ public void checkForLoadedProperty() {
+
+ PropertyComponent propComp = getListModel().existsByDataPath( mDataPath );
+ if( propComp instanceof PropertyComponent ){
+ clonePropertyComponent( propComp );
+ this.setText( propComp.getValue() );
+ getListModel().replaceItem(propComp, this);
+ }
+ }
+
+ private void clonePropertyComponent(PropertyComponent propComp){
+ this.setChooserPath( propComp.getChooserPath() );
+ this.setDataPath( propComp.getDataPath() );
+ this.setDataType( propComp.getDataType() );
+ this.setDefaultName( propComp.getDefaultName() );
+ this.setDefaultValue( propComp.getDefaultValue() );
+ this.setDescriptionId( propComp.getDescriptionId() );
+ this.setExtendsChooser( propComp.getExtendsChooser() );
+ this.setPath( propComp.getPath() );
+ this.setResourceId( propComp.getResourceId() );
+ this.setResourceIdPath( propComp.getResourceIdPath() );
+ this.setSeperator( propComp.getSeperator() );
+ this.setVisualType( propComp.getVisualType() );
+ }
+
+
+ public void saveProperty(){
+ if( this.hasChanged() && checkInput() ){
+ mProfileModel.createProperty( this );
+ }
+ }
+
+ public PropertyJListModel getListModel(){
+ return mProfileModel.getListModel();
+ }
+
+ public void reset(){
+ mProfileModel.removeProperty( this );
+ this.setText( this.getDefaultValue() );
+ this.fireActionPerformed();
+ }
+
+ public String toString(){
+ String result = "Path: " + this.getDataPath();
+ result += "\nValue: " + (String)this.getText();
+ return result;
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/PropertyStringList.java b/src/com/sun/apoc/tools/profileeditor/gui/PropertyStringList.java
new file mode 100644
index 0000000..f25cd55
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/PropertyStringList.java
@@ -0,0 +1,419 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Enumeration;
+import javax.swing.BoxLayout;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+
+/**
+ *
+ * @author cs202741
+ */
+public class PropertyStringList extends JPanel implements PropertyComponent, ActionListener, ListDataListener {
+
+ // PropertyComponent Interface Methods
+ private boolean mIsSet = false;
+ private String mResourceId = null;
+ private String mDefaultName = null;
+ private String mDataType = null;
+ private String mSectionName = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+ private String mVisualType = null;
+ private String mDataPath = null;
+ private String mDefault = null;
+ private String mSeperator = null;
+ private String mDescriptionId = null;
+ private String mChooserPath = null;
+ private String mExtendsChooser = null;
+ private StandaloneProfileManager mProfileModel = null;
+
+ // Used so we can update the listModel without
+ // firing events like on 'checkForLoadedProperty()'.
+ private boolean updateLock = false;
+
+ private JList mList = null;
+ private DefaultListModel mDefaultListModel = null;
+
+
+ //private PropertyJListModel mPropertyListModel = null;
+ private JButton newButton, clearButton, deleteButton, setDefaultButton;
+
+ /** Creates a new instance of PropertyStringList */
+ public PropertyStringList() {
+ this.setLayout( new BorderLayout() );
+ this.setOpaque(false);
+
+ mDefaultListModel = new DefaultListModel();
+ mList = new JList(mDefaultListModel);
+ mDefaultListModel.addListDataListener( this );
+
+ JScrollPane scrollPane = new JScrollPane(mList);
+ scrollPane.setMinimumSize(new Dimension(160, 50) );
+
+ this.add( scrollPane, BorderLayout.CENTER );
+ this.add( getButtonPanel(), BorderLayout.LINE_END );
+ }
+
+ public JPanel getButtonPanel(){
+ JPanel buttonPanel = new JPanel(new GridLayout(0,1));
+ //buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.PAGE_AXIS ) );
+ buttonPanel.setOpaque(false);
+
+ newButton = new JButton("New");
+ newButton.addActionListener(this);
+ deleteButton = new JButton("Delete");
+ deleteButton.addActionListener(this);
+ clearButton = new JButton("Clear");
+ clearButton.addActionListener(this);
+ setDefaultButton = new JButton("Set Defaults");
+ setDefaultButton.addActionListener( this );
+
+ buttonPanel.add(newButton);
+ buttonPanel.add(deleteButton);
+ buttonPanel.add(clearButton);
+ buttonPanel.add(setDefaultButton);
+
+ return buttonPanel;
+ }
+
+ private void deleteSelectedItems(){
+ int[] index = mList.getSelectedIndices();
+ for(int i = index.length-1; i >= 0; i--){
+ mDefaultListModel.removeElementAt( index[i] );
+ }
+ if( mDefaultListModel.getSize() == 0 ){
+ reset();
+ }
+ }
+
+ private void addItemToList(){
+ String inputValue = JOptionPane.showInputDialog("Please input a value");
+
+ if( inputValue != null ){
+ mDefaultListModel.addElement( inputValue );
+ }
+ }
+
+
+ public void setIsSetProperty(boolean isSet) {
+ mIsSet = isSet;
+ }
+
+ public boolean isSetProperty() {
+ return mIsSet;
+ }
+
+ public void setDataType(String aDataType) {
+ mDataType = aDataType;
+ }
+
+ public String getDataType() {
+ return mDataType;
+ }
+
+ public void setResourceId(String aResourceId) {
+ mResourceId = aResourceId;
+ }
+
+ public String getResourceId() {
+ return mResourceId;
+ }
+
+ public void setDefaultName(String aDefaultName) {
+ mDefaultName = aDefaultName;
+ }
+
+ public String getDefaultName() {
+ return mDefaultName;
+ }
+
+ public void setSectionName(String aSectionName) {
+ mSectionName = aSectionName;
+ }
+
+ public String getSectionName() {
+ return mSectionName;
+ }
+
+ public void setPath(String aPath) {
+ mPath = aPath;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public void setResourceIdPath(String aResourceIdPath) {
+ mResourceIdPath = aResourceIdPath;
+ }
+
+ public String getResourceIdPath() {
+ return mResourceIdPath;
+ }
+
+ public void setVisualType(String aVisualType) {
+ }
+
+ public String getVisualType() {
+ return mVisualType;
+ }
+
+ public void setDataPath(String aDataPath) {
+ mDataPath = aDataPath;
+ }
+
+ public String getDataPath() {
+ return mDataPath;
+ }
+
+ public void setDefaultValue(String aDefault) {
+ mDefault = aDefault;
+ }
+
+ public String getDefaultValue() {
+ return mDefault;
+ }
+
+
+ public void setSeperator(String aSeperator) {
+ mSeperator = aSeperator;
+ }
+
+ public String getSeperator() {
+ if( mSeperator == null )
+ return " ";
+ else
+ return mSeperator;
+ }
+
+ public void setDescriptionId(String aDescriptionId) {
+ mDescriptionId = aDescriptionId;
+ }
+
+ public String getDescriptionId() {
+ return mDescriptionId;
+ }
+
+ public void setChooserPath(String aChooserPath) {
+ mChooserPath = aChooserPath;
+ }
+
+ public String getChooserPath() {
+ return mChooserPath;
+ }
+
+ public void setExtendsChooser(String aExtendsChooser) {
+ mExtendsChooser = aExtendsChooser;
+ }
+
+ public String getExtendsChooser() {
+ return mExtendsChooser;
+ }
+
+
+ public void setValue(String aValue) {
+ }
+
+ public String getValue() {
+ StringBuffer result = new StringBuffer();
+ if( mDefaultListModel.getSize() > 0){
+
+ Enumeration e = mDefaultListModel.elements();
+
+ while( e.hasMoreElements() ){
+ result.append( (String)e.nextElement() + mSeperator );
+ }
+
+ char[] c = mSeperator.toCharArray();
+
+ if( result.charAt( result.length() - 1 ) == c[0] ){
+ result = result.deleteCharAt(result.length()-1);
+ }
+ }
+
+ return result.toString();
+ }
+
+ public void setLabel(String aLabel) {
+ }
+
+ public String getLabel() {
+ return "";
+ }
+
+
+ public boolean hasChanged() {
+
+ if( mDefaultListModel.isEmpty() )
+ return false;
+ else
+ return true;
+ }
+
+ public void setProfileModel(StandaloneProfileManager aProfileModel) {
+ mProfileModel = aProfileModel;
+
+ checkForLoadedProperty();
+ }
+
+
+ public void checkForLoadedProperty() {
+ PropertyComponent propComp = getListModel().existsByDataPath( mDataPath );
+ if( propComp instanceof PropertyComponent ){
+ updateLock = true;
+ clonePropertyComponent(propComp);
+
+ String[] items = propComp.getValue().split( propComp.getSeperator() );
+ mDefaultListModel.clear();
+ for(int i =0; i < items.length; i++){
+ mDefaultListModel.addElement( items[i] );
+ }
+ getListModel().replaceItem( propComp , this);
+ updateLock = false;
+ }
+ }
+
+ private void clonePropertyComponent(PropertyComponent propComp){
+ this.setChooserPath( propComp.getChooserPath() );
+ this.setDataPath( propComp.getDataPath() );
+ this.setDataType( propComp.getDataType() );
+ this.setDefaultName( propComp.getDefaultName() );
+ this.setDefaultValue( propComp.getDefaultValue() );
+ this.setDescriptionId( propComp.getDescriptionId() );
+ this.setExtendsChooser( propComp.getExtendsChooser() );
+ this.setPath( propComp.getPath() );
+ this.setResourceId( propComp.getResourceId() );
+ this.setResourceIdPath( propComp.getResourceIdPath() );
+ this.setSeperator( propComp.getSeperator() );
+ this.setValue( propComp.getValue() );
+ this.setVisualType( propComp.getVisualType() );
+ }
+
+ public void saveProperty() {
+ if( this.hasChanged() ){
+ mProfileModel.createProperty( this );
+ }
+ }
+
+ public PropertyJListModel getListModel() {
+ return mProfileModel.getListModel();
+ }
+
+ public void reset() {
+ mDefaultListModel.clear();
+ mProfileModel.removeProperty( this );
+ }
+
+
+ //
+ // ActionListener Interface
+ //
+ public void actionPerformed(ActionEvent e) {
+
+ if( e.getSource() == newButton ){
+ addItemToList();
+ }else if( e.getSource() == deleteButton ){
+ deleteSelectedItems();
+ }else if( e.getSource() == clearButton ){
+ mDefaultListModel.clear();
+ }else if( e.getSource() == setDefaultButton ){
+ setDefaults();
+ }
+ }
+
+ //
+ // ListDataListener Interface Methods
+ //
+ public void intervalAdded(ListDataEvent e) {
+ updateProperties();
+ }
+
+ public void intervalRemoved(ListDataEvent e) {
+ updateProperties();
+ }
+
+ public void contentsChanged(ListDataEvent e) {
+ updateProperties();
+ }
+
+
+ private void setDefaults(){
+
+ if( !mDefault.equals("") ){
+ String[] items = mDefault.split( mSeperator );
+ for(int i = 0; i < items.length; i++){
+ mDefaultListModel.addElement( items[i] );
+ }
+ }
+ }
+
+
+ private void updateProperties(){
+
+ if( !updateLock ){
+ PropertyComponent aComponent = this;
+ PropertyJListModel listModel = aComponent.getListModel();
+
+ if( aComponent.hasChanged() ){
+ if( listModel.exists( aComponent ) ){
+ listModel.replaceItem( aComponent, aComponent);
+ }else{
+ listModel.addItem( aComponent );
+ }
+ }else {
+ if( listModel.exists( aComponent ) ){
+ listModel.removeItem( aComponent );
+ }
+ }
+ }
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/SectionPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/SectionPanel.java
new file mode 100644
index 0000000..a7c07f4
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/SectionPanel.java
@@ -0,0 +1,185 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.ComponentFactory;
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.packages.Template;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+import com.sun.apoc.tools.profileeditor.templates.TemplateSection;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Insets;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author cs202741
+ */
+public class SectionPanel extends JPanel {
+ final Dimension SIZE = new Dimension(300,30);
+
+ public SectionPanel(Template template, TemplateSection section, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager, String aPackageName) {
+
+ this.setLayout( new GridBagLayout() );
+
+ addContents( this, template, section, aProfileModel, aLocaleManager, aPackageName);
+ }
+
+
+ private void addContents(JPanel contentPanel, Template template, TemplateSection section, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager, String aPackageName){
+
+ HashMap choosers = new HashMap();
+
+ int row = 0;
+
+ List propertyList = section.getProperties();
+ Iterator it = propertyList.iterator();
+ while( it.hasNext() )
+ {
+ TemplateProperty property = (TemplateProperty)it.next();
+
+ JLabel label = new PropertyJLabel();
+
+ ((PropertyJLabel)label).setLocaleManager( aLocaleManager );
+ ((PropertyJLabel)label).setResourceId( property.getResourceId() );
+ ((PropertyJLabel)label).setPackageName( aPackageName );
+ ((PropertyJLabel)label).setDefaultName( property.getDefaultName() );
+ ((PropertyJLabel)label).update();
+
+ JPanel labelPanel = new JPanel( new FlowLayout(FlowLayout.LEFT) );
+ labelPanel.setOpaque(false);
+ labelPanel.setMinimumSize( SIZE );
+ labelPanel.setPreferredSize( SIZE );
+ labelPanel.add( label );
+
+ //contentPanel.add(labelPanel, BorderLayout.LINE_START);
+ addWithGridBag( labelPanel, contentPanel,
+ 0, row, 1, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 0, 1);
+
+ JComponent comp = ComponentFactory.getComponent( property, aProfileModel, aLocaleManager, aPackageName );
+ if( comp instanceof PropertyComponent ){
+ ((PropertyComponent)comp).setResourceIdPath( section.getResourceId() + ";" + template.getResourceIdPath() );
+ ((PropertyComponent)comp).setPath( section.getDefaultName() + ";" + template.getPath() );
+ ((PropertyComponent)comp).setDefaultName( property.getDefaultName() );
+ ((PropertyComponent)comp).setResourceId( property.getResourceId() );
+//
+// if( property.getVisualType().equals("chooser") ){
+// String chooserPath = getChooserPath( property.getPath() ) + property.getDefaultName();
+// choosers.put( chooserPath, property.getConstraints() );
+// System.out.println("Adding Chooser: " + chooserPath);
+// if( !property.getExtendsChooser().equals("") ){
+//
+// System.out.println("Property has Extends Chooser: " + property.getExtendsChooser() );
+// Vector v = (Vector)choosers.get( property.getExtendsChooser() );
+// if( v != null ){
+// System.out.println("Found chooser in hash");
+// String value = ((PropertyComponent)comp).getValue();
+// System.out.println("Current Value:" + value);
+//// String sep = ((PropertyComponent)comp).getSeperator();
+//// if( sep.equals("") ){
+//// sep = " ";
+//// }
+// }
+// }
+// }
+ }
+
+ JPanel componentPanel = new JPanel( new FlowLayout(FlowLayout.LEFT) );
+ componentPanel.setOpaque(false);
+ componentPanel.add( comp );
+
+ //contentPanel.add(componentPanel, BorderLayout.LINE_END);
+
+ addWithGridBag( componentPanel, contentPanel,
+ 1, row++, 2, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 0, 1);
+
+ }//end while
+ }
+
+
+ private void addWithGridBag(Component comp, Container cont,
+ int x, int y,
+ int width, int height,
+ int anchor, int fill,
+ int weightx, int weighty){
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridx = x;
+ gbc.gridy = y;
+ gbc.gridwidth = width;
+ gbc.gridheight = height;
+ gbc.anchor = anchor;
+ gbc.fill = fill;
+ gbc.weightx = weightx;
+ gbc.weighty = weighty;
+ gbc.insets = new Insets(5,5,5,5);
+ cont.add(comp, gbc);
+ }
+
+
+ private String getChooserPath(String path){
+
+ String[] tokens = path.split(";");
+ String newPath = "/";
+ for( int i = tokens.length-1; i >= 0; i--){
+ newPath += tokens[i] + "/";
+ }
+
+ newPath = newPath.substring( newPath.indexOf("/", 1) );
+ System.out.println("NewPath: " + newPath);
+ return newPath;
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/SetPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/SetPanel.java
new file mode 100644
index 0000000..c0c78f5
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/SetPanel.java
@@ -0,0 +1,366 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.LocalizedDefaultMutableTreeNode;
+import com.sun.apoc.tools.profileeditor.packages.Template;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.templates.TemplateSet;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.DefaultListModel;
+import javax.swing.JTree;
+import javax.swing.border.TitledBorder;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+
+/**
+ *
+ * @author cs202741
+ */
+public class SetPanel extends JPanel implements ActionListener, MouseListener {
+
+ public static final int MAIN_LIST = 0;
+ public static final int SUB_LIST = 1;
+
+ private StandaloneProfileManager mProfileModel = null;
+
+ // Subscriber Interface Vars
+ private String mPackageName = null;
+ private LocaleManager mLocaleManager = null;
+ private Template mTemplate;
+
+ private JList mMainList = null;
+ private JList mSubList = null;
+ private TemplateSet mSet = null;
+ private DefaultListModel mListModel = null;
+ private JTree mTree = null;
+ private DefaultMutableTreeNode mSetNode = null;
+
+ private Hashtable mSetNodesByName = null;
+
+ /** Creates a new instance of SetPanel */
+ public SetPanel(Template template, TemplateSet set, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager, String aPackageName, JTree aTree) {
+ super( );
+ mSet = set;
+ mLocaleManager = aLocaleManager;
+ mPackageName = aPackageName;
+ mProfileModel = aProfileModel;
+ mTemplate = template;
+ mTree = aTree;
+ mSetNode = getSetNode();
+ mSetNodesByName = new Hashtable();
+ mListModel = new DefaultListModel();
+ this.add( getSetPanel(MAIN_LIST) );
+
+ mSetNode.setUserObject( this.getTitledPanel() );
+
+ // So we can scan templates for sets when the user
+ // clicks 'New'.
+ mTemplate.addSetPanel(this);
+
+ checkForLoadedProperties();
+ }
+
+
+ private DefaultMutableTreeNode getSetNode(){
+ int count = mTemplate.getTreeNode().getChildCount();
+ for(int i = 0; i < count; i++){
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)mTemplate.getTreeNode().getChildAt(i);
+ TitledSectionJPanel panel = (TitledSectionJPanel)node.getUserObject();
+ if( panel.getName().equals( mSet.getDataPath() ) ){
+ return node;
+ }
+ }
+ LocalizedDefaultMutableTreeNode node = new LocalizedDefaultMutableTreeNode(mSet.getDefaultName(),
+ mPackageName, mSet.getResourceId(),
+ mSet.getDefaultName(), mLocaleManager);
+
+ mTemplate.getTreeNode().add( node );
+ return node;
+ }
+
+ private void checkForLoadedProperties(){
+
+ // If the SectionPanel is getting recreated we need to
+ // repopulate the 'mSetNodesByName' with sets currently on tree.
+ int count = mSetNode.getChildCount();
+ for(int i = 0; i < count; i++){
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)mSetNode.getChildAt(i);
+ mSetNodesByName.put( node.getUserObject().toString(), node);
+ mListModel.addElement( node.getUserObject().toString() );
+ }
+
+ HashMap setHash = new HashMap();
+ Enumeration e = mProfileModel.getListModel().elements();
+ while(e.hasMoreElements()){
+ PropertyComponent propComp = (PropertyComponent)e.nextElement();
+ String dataPath = propComp.getDataPath();
+ String loadedPropPath = dataPath.substring(0, dataPath.lastIndexOf("/") );
+ int index = loadedPropPath.lastIndexOf("/");
+ if( index > 0 ){
+ loadedPropPath = loadedPropPath.substring(0, index);
+ }
+
+ if( loadedPropPath.equals( mSet.getDataPath() ) ){
+ String setName = dataPath.substring( loadedPropPath.length() + 1, dataPath.lastIndexOf("/") );
+
+ setHash.put(setName, null);
+ }
+ }
+ Set sets = setHash.keySet();
+ Iterator it = sets.iterator();
+ while(it.hasNext()){
+ String setName = it.next().toString();
+ if( mSetNodesByName.containsKey(setName) ){
+ DefaultTreeModel model = (DefaultTreeModel)mTree.getModel();
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)mSetNodesByName.remove(setName);
+ SetSubPanel subPanel = (SetSubPanel)node.getUserObject();
+ model.removeNodeFromParent( node );
+ mListModel.removeElement(setName);
+ }
+ addItemToList(setName);
+ }
+
+ mTree.revalidate();
+ mTree.repaint();
+ }
+
+
+ private void printNodes(){
+ System.err.println("-------\nNODES:");
+ Enumeration e = mSetNodesByName.elements();
+ while(e.hasMoreElements()){
+ System.err.println(" " + e.nextElement().toString() );
+ }
+ System.err.println("-------");
+ }
+
+
+ private JPanel getSetPanel(int list){
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setOpaque(false);
+
+ JButton newButton = new JButton("New");
+ JButton deleteButton = new JButton("Delete");
+
+ newButton.setActionCommand("New");
+
+ newButton.addActionListener( this );
+ deleteButton.addActionListener( this );
+
+ JPanel buttonPanel = new JPanel( new FlowLayout(FlowLayout.LEFT) );
+ buttonPanel.setOpaque(false);
+ buttonPanel.add( newButton );
+ buttonPanel.add( deleteButton );
+ buttonPanel.setBorder( BorderFactory.createEmptyBorder(0,30,0,30));
+
+ JScrollPane scroll = null;
+ if(list == MAIN_LIST){
+ mMainList = new JList(mListModel);
+ mMainList.addMouseListener( this );
+ scroll = new JScrollPane( mMainList );
+ deleteButton.setActionCommand("MainDelete");
+ }else {
+ mSubList = new JList(mListModel);
+ mSubList.addMouseListener( this );
+ scroll = new JScrollPane( mSubList );
+ deleteButton.setActionCommand("SubDelete");
+ }
+
+ JPanel listPanel = new JPanel( new BorderLayout() );
+ listPanel.setOpaque(false);
+ listPanel.add( scroll, BorderLayout.CENTER );
+ listPanel.setBorder( BorderFactory.createEmptyBorder(15,30,15,30));
+
+ panel.add(buttonPanel, BorderLayout.PAGE_START);
+ panel.add(listPanel, BorderLayout.CENTER );
+
+ return panel;
+ }
+
+
+ //
+ // Returns a copy of 'this' panel wrapped in a titled panel
+ // So that it can be used for the tree node specific to this.
+ //
+ private JPanel getTitledPanel(){
+
+ TitledSectionJPanel sectionPanel = new TitledSectionJPanel();
+ sectionPanel.setTitleLabel( mSet, mPackageName, mLocaleManager);
+ sectionPanel.setContentPanel( getSetPanel(SUB_LIST), true );
+ sectionPanel.setName( mSet.getDataPath() );
+ return sectionPanel;
+ }
+
+
+
+ private SetSubPanel getSetSubPanel(String setName){
+
+ SetSubPanel setPanel = new SetSubPanel(mTemplate, mSet, setName, mProfileModel, mLocaleManager, mPackageName);
+ setPanel.setName(setName);
+
+ return setPanel;
+ }
+
+ private void addItemToList(){
+ String inputValue = JOptionPane.showInputDialog("Please input a value");
+ addItemToList( inputValue);
+ }
+
+
+ private void addItemToList(String inputValue){
+ if( inputValue == null ){
+ return;
+ }
+
+ if( mSetNodesByName.containsKey(inputValue) ){
+ JOptionPane.showMessageDialog(this, "Set already exists, please choose another name!",
+ "Invalid Set Name!", JOptionPane.ERROR_MESSAGE);
+ }
+
+ if( inputValue.length() > 0 ){
+ mListModel.addElement( inputValue );
+
+ DefaultTreeModel model = (DefaultTreeModel)mTree.getModel();
+
+ DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( getSetSubPanel(inputValue) );
+ mSetNodesByName.put( inputValue, newNode );
+ model.insertNodeInto( newNode, mSetNode, mSetNode.getChildCount() );
+ }
+ }
+
+ public void removeSet(String setName){
+
+ // Remove selected element from tree
+ DefaultTreeModel model = (DefaultTreeModel)mTree.getModel();
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)mSetNodesByName.remove(setName);
+ SetSubPanel subPanel = (SetSubPanel)node.getUserObject();
+ if( subPanel != null){
+ subPanel.deleteProperties();
+ }
+
+ model.removeNodeFromParent( node );
+
+ // Remove selected element from list
+ mListModel.removeElement(setName);
+ }
+
+ public void removeAllSets(){
+
+ mListModel.clear();
+ Collection c = mSetNodesByName.values();
+ Iterator it = c.iterator();
+ while( it.hasNext() ){
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)it.next();
+ SetSubPanel subPanel = (SetSubPanel)node.getUserObject();
+ if(subPanel!=null){
+ subPanel.deleteProperties();
+ }
+ }
+ mSetNodesByName.clear();
+ mSetNode.removeAllChildren();
+ ((DefaultTreeModel)mTree.getModel()).nodeStructureChanged(mSetNode);
+ }
+
+
+ public void actionPerformed(ActionEvent e) {
+
+ if( e.getActionCommand().equals("New") ){
+ addItemToList();
+ }else if( e.getActionCommand().equals("MainDelete") ){
+ if( !mMainList.isSelectionEmpty() ){
+ removeSet( mMainList.getSelectedValue().toString() );
+ }
+ }else if( e.getActionCommand().equals("SubDelete") ){
+ if( !mSubList.isSelectionEmpty() ){
+ removeSet( mSubList.getSelectedValue().toString() );
+ }
+ } else if( e.getActionCommand().equals("Done") ){
+
+ }else if( e.getActionCommand().equals("Cancel") ){
+
+ }
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ if( e.getClickCount() == 2){
+ if( e.getSource() instanceof JList ){
+ JList list = (JList)e.getSource();
+ if( !list.isSelectionEmpty() ){
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)mSetNode.getChildAt( list.getSelectedIndex() );
+ int[] row = mTree.getSelectionRows();
+ mTree.expandRow( row[0] );
+ mTree.setSelectionRow( row[0] + (list.getSelectedIndex()+1) );
+ }
+ }
+ }
+ }
+
+ public void mousePressed(MouseEvent e) {
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ public void mouseExited(MouseEvent e) {
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/SetSubPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/SetSubPanel.java
new file mode 100644
index 0000000..b8a4d5a
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/SetSubPanel.java
@@ -0,0 +1,177 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.ComponentFactory;
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.packages.Template;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.templates.TemplatePage;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+import com.sun.apoc.tools.profileeditor.templates.TemplateSection;
+import com.sun.apoc.tools.profileeditor.templates.TemplateSet;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author cs202741
+ */
+public class SetSubPanel extends TitledSectionJPanel {
+
+ private String mSetName = null;
+ private ArrayList mPropertyList = null;
+
+ /** Creates a new instance of SetPanel */
+ public SetSubPanel() {
+ super();
+ }
+
+ public SetSubPanel(Template template, TemplateSet aSet, String aSetName, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager, String aPackageName){
+ super();
+ this.setTitleLabel(aSet, aPackageName, aLocaleManager, " ( " + aSetName + " )");
+ mSetName = aSetName;
+
+ mPropertyList = new ArrayList();
+
+ JPanel contentPanel = new JPanel( new GridBagLayout() );
+ contentPanel.setOpaque(false);
+ addContents(contentPanel, template, aSet, aSetName, aProfileModel, aLocaleManager, aPackageName);
+ this.setContentPanel( contentPanel, true);
+ }
+
+
+ private void addContents(JPanel contentPanel, Template template, TemplateSet aSet, String aSetName, StandaloneProfileManager aProfileModel,
+ LocaleManager aLocaleManager, String aPackageName){
+
+ HashMap choosers = new HashMap();
+ int row = 0;
+
+ TemplatePage page = aSet.getPage();
+
+ List sectionList = page.getSections();
+ Iterator sectionIt = sectionList.iterator();
+ // Loop through Sections in Page
+ while( sectionIt.hasNext() ){
+ TemplateSection section = (TemplateSection)sectionIt.next();
+
+ // Loop through Properties in Section
+ List propertyList = section.getProperties();
+ Iterator propertyIt = propertyList.iterator();
+ while( propertyIt.hasNext() ){
+ TemplateProperty property = (TemplateProperty)propertyIt.next();
+
+ JLabel label = new PropertyJLabel();
+ ((PropertyJLabel)label).setLocaleManager( aLocaleManager );
+ ((PropertyJLabel)label).setResourceId( property.getResourceId() );
+ ((PropertyJLabel)label).setPackageName( aPackageName );
+ ((PropertyJLabel)label).update();
+
+ addWithGridBag( label, contentPanel,
+ 0, row, 1, 1,
+ GridBagConstraints.EAST,
+ GridBagConstraints.NONE, 0, 1);
+
+ JComponent comp = ComponentFactory.getComponent( property, aProfileModel, aLocaleManager, aPackageName );
+
+ if( comp instanceof PropertyComponent ){
+ ((PropertyComponent)comp).setSectionName( section.getDefaultName() );
+ String dataPath = ((PropertyComponent)comp).getDataPath();
+ dataPath = aSet.getDataPath() + "/" + aSetName + dataPath.substring( dataPath.lastIndexOf("/") );
+ ((PropertyComponent)comp).setPath( aSetName+";"+section.getPath() );
+ ((PropertyComponent)comp).setResourceIdPath( aSetName+";"+section.getResourceIdPath() );
+ ((PropertyComponent)comp).setDataPath( dataPath );
+ ((PropertyComponent)comp).setDefaultName( property.getDefaultName() );
+ ((PropertyComponent)comp).setResourceId( property.getResourceId() );
+ ((PropertyComponent)comp).setIsSetProperty(true);
+ ((PropertyComponent)comp).checkForLoadedProperty();
+ }
+
+ mPropertyList.add(comp);
+
+ addWithGridBag( comp, contentPanel,
+ 1, row++, 2, 1,
+ GridBagConstraints.LINE_START,
+ GridBagConstraints.NONE, 0, 1);
+ }//while
+ }//while
+ }
+
+
+ public void deleteProperties(){
+ Iterator it = mPropertyList.iterator();
+ while(it.hasNext()){
+ ((PropertyComponent)it.next()).reset();
+ }
+ }
+
+
+ private void addWithGridBag(Component comp, Container cont,
+ int x, int y,
+ int width, int height,
+ int anchor, int fill,
+ int weightx, int weighty){
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridx = x;
+ gbc.gridy = y;
+ gbc.gridwidth = width;
+ gbc.gridheight = height;
+ gbc.anchor = anchor;
+ gbc.fill = fill;
+ gbc.weightx = weightx;
+ gbc.weighty = weighty;
+ gbc.insets = new Insets(5,5,5,5);
+ cont.add(comp, gbc);
+ }
+
+ public String toString(){
+ return mSetName;
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/SummaryJPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/SummaryJPanel.java
new file mode 100644
index 0000000..a4f4053
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/SummaryJPanel.java
@@ -0,0 +1,349 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.spi.cfgtree.DataType;
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.gui.TitledSectionJPanel;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+import com.sun.apoc.tools.profileeditor.templates.TemplatePropertyConstraint;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+
+/**
+ *
+ * @author cs202741
+ */
+public class SummaryJPanel extends JPanel implements ListDataListener{
+ private JPanel mainPanel = null;
+ private LocaleManager mLocaleManager = null;
+
+ /** Creates a new instance of SummaryJPanel */
+ public SummaryJPanel(LocaleManager aLocaleManager) {
+ super(new BorderLayout());
+ this.setBackground(Color.WHITE);
+
+ mLocaleManager = aLocaleManager;
+ TitledSectionJPanel sectionPanel = new TitledSectionJPanel( new JLabel("Settings Summary") );
+ mainPanel = new JPanel(new BorderLayout());
+ sectionPanel.setContentPanel(mainPanel, false);
+ this.add( sectionPanel, BorderLayout.PAGE_START );
+ }
+
+ private void buildPanel(Enumeration e){
+
+ Map packageHash = new TreeMap();
+
+ while(e.hasMoreElements()){
+ PropertyComponent propComp = (PropertyComponent)e.nextElement();
+
+ String[] path = propComp.getPath().split(";");
+ String[] resource = propComp.getResourceIdPath().split(";");
+
+ Map hash = (TreeMap)packageHash.get(path[ path.length-2 ]+":"+resource[ resource.length-2]);
+ if( hash == null ){
+ hash = new TreeMap();
+ packageHash.put(path[ path.length-2 ]+":"+resource[ resource.length-2], hash );
+ }
+
+ String joinPath = joinString(path, path.length-3);
+ String joinResource = joinString(resource, resource.length-3);
+
+ ArrayList list = (ArrayList)hash.get( joinPath+":"+joinResource);
+ if( list == null ){
+ list = new ArrayList();
+ hash.put(joinPath+":"+joinResource, list);
+ }
+ list.add(propComp);
+ }
+
+ mainPanel.removeAll();
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
+ mainPanel.add( panel, BorderLayout.PAGE_START );
+ addPackagePanel(panel, packageHash);
+
+ this.validate();
+ this.repaint();
+ }
+
+
+ private void addPackagePanel(JPanel panel, Map subMap){
+ Set keys = subMap.keySet();
+ Iterator it = keys.iterator();
+ while(it.hasNext()){
+ String name = (String)it.next();
+ String[] path_resource = name.split(":");
+ PropertyJLabel label = new PropertyJLabel();
+ label.setFont( getFont(label, 1));
+ label.setPackageName(path_resource[0]);
+ label.setDefaultName(path_resource[0]);
+ label.setResourceId(path_resource[1]);
+ label.setLocaleManager(mLocaleManager);
+ label.update();
+
+ GradientJPanel pkgPanel = new GradientJPanel(new Color(0xCBCFD5), new Color(0xFFFFFF),
+ GradientJPanel.ROUNDED_NONE, 0, 0);
+ pkgPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
+ pkgPanel.setBorder( BorderFactory.createLineBorder(new Color(0x71838d),1) );
+ pkgPanel.add(label);
+ panel.add(pkgPanel);
+
+ Map newMap = (Map)subMap.get(name);
+ if( newMap != null){
+ addCategoryPanel(panel, path_resource[0], newMap);
+ }
+ }
+ }
+
+
+ private void addCategoryPanel(JPanel panel, String pkgName, Map subMap){
+ Set keys = subMap.keySet();
+ Iterator it = keys.iterator();
+ while(it.hasNext()){
+ JPanel mainPanel = new JPanel(new BorderLayout());
+
+ String name = (String)it.next();
+ GradientJPanel catPanel = new GradientJPanel(new Color(0xCBCFD5), new Color(0xFFFFFF),
+ GradientJPanel.ROUNDED_NONE, 0, 0);
+ catPanel.setBorder( BorderFactory.createLineBorder(new Color(0x71838d),1) );
+
+ JPanel spacer = new JPanel();
+ spacer.setBackground(new Color(0xbec7cc));
+ spacer.add( new JLabel(" "));
+
+ mainPanel.add(spacer, BorderLayout.LINE_START);
+ mainPanel.add( catPanel, BorderLayout.CENTER);
+
+ catPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
+
+ String[] both = name.split(":");
+ String[] path = both[0].split(";");
+ String[] resource = both[1].split(";");
+
+ for(int i = 0; i < path.length;i++){
+ PropertyJLabel label = new PropertyJLabel();
+ label.setFont( getFont(label, 0) );
+ label.setPackageName(pkgName);
+ label.setDefaultName(path[i]);
+ label.setResourceId(resource[i]);
+ label.setLocaleManager(mLocaleManager);
+ label.update();
+ catPanel.add(label);
+ if( i+1 < path.length ){
+ JLabel sep = new JLabel(">");
+ sep.setFont( getFont(sep, 0) );
+ catPanel.add( sep );
+ }
+ }
+ panel.add(mainPanel);
+
+ ArrayList list = (ArrayList)subMap.get(name);
+ if( list != null)
+ addPropertyPanel(panel, pkgName, list);
+ }
+ }
+
+
+
+ private void addPropertyPanel(JPanel panel, String pkgName, ArrayList list){
+ Iterator it = list.iterator();
+ while(it.hasNext()){
+ PropertyComponent propComp = (PropertyComponent)it.next();
+
+ JPanel mainPanel = new JPanel(new BorderLayout());
+
+ JPanel spacer = new JPanel();
+ spacer.setBackground(new Color(0xbec7cc));
+ spacer.add( new JLabel(" "));
+
+ mainPanel.add(spacer, BorderLayout.LINE_START);
+ mainPanel.add( getPropertyPanel(propComp, pkgName), BorderLayout.CENTER);
+
+ panel.add( mainPanel);
+ }
+ }
+
+
+ private JPanel getPropertyPanel(PropertyComponent propComp, String pkgName){
+ JPanel mainPanel = new JPanel(new GridLayout(1,0));
+ mainPanel.setBorder( BorderFactory.createLineBorder(new Color(0x71838d),1) );
+
+ JPanel namePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ namePanel.setBackground(Color.WHITE);
+ JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ //valuePanel.setLayout(new BoxLayout(valuePanel, BoxLayout.PAGE_AXIS));
+ valuePanel.setBackground(Color.WHITE);
+
+ PropertyJLabel name = new PropertyJLabel();
+ name.setForeground( new Color(0x405661) );
+ name.setFont( getFont( name, -1));
+ //name.setPackageName( pkgName );
+ name.setDefaultName( propComp.getDefaultName() );
+ name.setResourceId( propComp.getResourceId() );
+ name.setLocaleManager( mLocaleManager );
+ name.update();
+
+ namePanel.add( name );
+
+ DataType dataType = DataType.getDataType( propComp.getDataType() );
+
+ if( dataType == DataType.STRING_LIST ){
+ String[] values = propComp.getValue().split( propComp.getSeperator() );
+ String items = "<html>";
+ for(int i = 0; i < values.length;i++){
+ items += values[i] + "<br>";
+ }
+ JLabel value = new JLabel( items + "</html>" );
+ value.setFont( getFont(value, -1) );
+ value.setForeground( new Color(0x405661) );
+ valuePanel.add( value );
+ }else{
+ JLabel value = new JLabel( propComp.getLabel() );
+
+ value.setFont( getFont(value, -1) );
+ valuePanel.add( value );
+ value.setForeground( new Color(0x405661) );
+ if( propComp.getVisualType().equals("colorSelector") ){
+ ColourButton btn = new ColourButton();
+ btn.setOpaque(false);
+ btn.setColor( propComp.getValue() );
+ valuePanel.add( btn );
+ }
+ }
+ mainPanel.add(namePanel);
+ mainPanel.add(valuePanel);
+ return mainPanel;
+ }
+
+
+ private Color getColorFromHex(String color){
+ if( color.charAt(0) == '#' ){
+ color = color.substring(1);
+ }
+
+ if( color.length() != 6 ){
+ return new Color(0x405661);
+ }
+
+ try {
+ int red = Integer.parseInt( color.substring(0,2), 16 );
+ int green = Integer.parseInt( color.substring(2,4), 16 );
+ int blue = Integer.parseInt( color.substring(4,6), 16 );
+
+ return new Color(red, green, blue);
+ } catch (NumberFormatException ex) {return new Color(0x405661);}
+ }
+
+ private JLabel getLocalizedValue(TemplateProperty property, String value){
+
+ Enumeration e = property.getConstraints().elements();
+ while(e.hasMoreElements()){
+ TemplatePropertyConstraint con = (TemplatePropertyConstraint)e.nextElement();
+ if(con.getValue().equals(value)){
+ PropertyJLabel label = new PropertyJLabel();
+ label.setForeground( new Color(0x405661) );
+ label.setFont( getFont(label, -1) );
+ label.setResourceId( con.getResourceId() );
+ label.setDefaultName( value );
+ label.setLocaleManager(mLocaleManager);
+ label.update();
+ return label;
+ }
+ }
+
+ return null;
+ }
+
+ //
+ // ResourceIdPaths and Paths stored in profiles are stored in reverse
+ // order, we need to reverse the order.
+ // i.e. property;section;page;category;root_category
+ //
+ private String joinString(String[] string, int index){
+ StringBuffer buffer = new StringBuffer();
+ String result = null;
+ for(int i = index; i >= 0; i--){
+ buffer.append(string[i] + ";");
+ }
+ if( buffer.length() > 0 ){
+ result = buffer.substring(0, buffer.length()-1);
+ }else{
+ result = buffer.toString();
+ }
+ return result;
+ }
+
+ private Font getFont(JLabel label, int size){
+ Font font = label.getFont();
+ font = font.deriveFont( Font.BOLD, font.getSize() + size);
+
+ return font;
+ }
+
+
+ public void intervalAdded(ListDataEvent e) {
+ }
+
+ public void intervalRemoved(ListDataEvent e) {
+ }
+
+ public void contentsChanged(ListDataEvent e) {
+ buildPanel( ((PropertyJListModel)e.getSource()).elements() );
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/gui/TitledSectionJPanel.java b/src/com/sun/apoc/tools/profileeditor/gui/TitledSectionJPanel.java
new file mode 100644
index 0000000..5ba4961
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/gui/TitledSectionJPanel.java
@@ -0,0 +1,215 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.gui;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.templates.TemplateSection;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import javax.swing.BorderFactory;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.border.Border;
+
+/**
+ *
+ * @author cs202741
+ */
+public class TitledSectionJPanel extends JPanel{
+ final Color gradColor1 = new Color(0x495661);
+ final Color gradColor2 = new Color(0x71838d);
+ final Color background = new Color(0xbec7cc);
+
+ // Localization info
+ private String mResourceId = null;
+ private String mPackageName = null;
+ private String mDefaultName = null;
+ private LocaleManager mLocaleManager = null;
+
+ private GradientJPanel titlePanel = null;
+ private GradientJPanel footerPanel = null;
+ private JPanel contentPanel = null;
+
+ private String mName = null;
+
+ /** Creates a new instance of TitledSectionJPanel */
+ public TitledSectionJPanel(JLabel title) {
+ this();
+ title.setFont( getFont(title) );
+ title.setForeground( Color.WHITE );
+ titlePanel.add(title);
+ }
+
+ public TitledSectionJPanel(){
+ super(new BorderLayout() );
+ this.setBackground( Color.WHITE );
+ this.setBorder( BorderFactory.createEmptyBorder(20,20,5,20) );
+
+ JPanel container = new JPanel( new BorderLayout() );
+ container.setOpaque(false);
+
+ titlePanel = new GradientJPanel(gradColor1, gradColor2, GradientJPanel.ROUNDED_TOP, 20, 0);
+ titlePanel.setLayout( new FlowLayout(FlowLayout.LEFT) );
+
+ footerPanel = new GradientJPanel(gradColor2, gradColor1, GradientJPanel.ROUNDED_BOTTOM, 4, 0);
+ footerPanel.add(new JLabel(" "));
+ footerPanel.setGradientHeight(6);
+
+ contentPanel = new JPanel( new BorderLayout() );
+ contentPanel.setBackground( background );
+ Border border = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(gradColor1, 1),
+ BorderFactory.createEmptyBorder(10,10,10,10));
+
+ contentPanel.setBorder( border );
+
+ JPanel spacer = new JPanel();
+ spacer.setBackground(Color.WHITE);
+ contentPanel.add(spacer, BorderLayout.CENTER);
+
+ container.add(titlePanel, BorderLayout.PAGE_START);
+ container.add(contentPanel, BorderLayout.CENTER);
+ container.add(footerPanel, BorderLayout.PAGE_END);
+
+ this.add(container, BorderLayout.PAGE_START);
+ }
+
+ public void setContentPanel(JPanel panel, boolean leftAlign){
+
+ if( leftAlign ){
+ panel.setBackground( background );
+ contentPanel.add( panel, BorderLayout.LINE_START );
+ JPanel spacer = new JPanel();
+ spacer.setBackground( background );
+ contentPanel.add( spacer, BorderLayout.CENTER );
+ }else{
+ contentPanel.add( panel, BorderLayout.CENTER );
+ }
+ }
+
+ public void setTitleLabel(String resourceId, String defaultName, LocaleManager localeManager){
+ mResourceId = resourceId;
+ mDefaultName = defaultName;
+ mLocaleManager = localeManager;
+
+ titlePanel.removeAll();
+ titlePanel.add(getTitleLabel());
+ }
+
+ public void setTitleLabel(TemplateSection section, String packageName, LocaleManager localeManager){
+ mPackageName = packageName;
+ mResourceId = section.getResourceId();
+ mDefaultName = section.getDefaultName();
+ mLocaleManager = localeManager;
+
+ titlePanel.removeAll();
+ titlePanel.add( getTitleLabel(section, packageName, localeManager) );
+ }
+
+ public void setTitleLabel(TemplateSection section, String packageName, LocaleManager localeManager, String extra){
+ mPackageName = packageName;
+ mResourceId = section.getResourceId();
+ mDefaultName = section.getDefaultName();
+ mLocaleManager = localeManager;
+
+ titlePanel.removeAll();
+ titlePanel.add( getTitleLabel(section, packageName, localeManager) );
+
+ JLabel label = new JLabel(extra);
+ label.setFont( getFont(label) );
+ label.setForeground( Color.WHITE );
+
+ titlePanel.add( label );
+ }
+
+ private JLabel getTitleLabel(){
+ PropertyJLabel title = new PropertyJLabel();
+ title.setDefaultName(mDefaultName);
+ title.setResourceId(mResourceId);
+ title.setLocaleManager(mLocaleManager);
+ title.update();
+
+ title.setFont( getFont(title) );
+ title.setForeground( Color.WHITE );
+
+ return title;
+ }
+
+ private JLabel getTitleLabel(TemplateSection section, String packageName, LocaleManager localeManager){
+
+ PropertyJLabel title = new PropertyJLabel();
+ title.setDefaultName(section.getDefaultName());
+ title.setResourceId(section.getResourceId());
+ title.setPackageName(packageName);
+ title.setLocaleManager(localeManager);
+ title.update();
+
+ title.setFont( getFont(title) );
+ title.setForeground( Color.WHITE );
+
+ return title;
+ }
+
+ private Font getFont(JLabel label){
+ Font font = label.getFont();
+ font = font.deriveFont( Font.BOLD, font.getSize() + 2);
+
+ return font;
+ }
+
+ public void setName(String name){
+ mName = name;
+ }
+
+ public String getName(){
+ return mName;
+ }
+
+ public String toString(){
+ if( mLocaleManager != null ){
+ return mLocaleManager.getLocalizedName(mPackageName, mResourceId, mDefaultName);
+ } else if(mName == null){
+ return super.toString();
+ }else{
+ return mName;
+ }
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/packages/Package.java b/src/com/sun/apoc/tools/profileeditor/packages/Package.java
new file mode 100644
index 0000000..983251c
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/packages/Package.java
@@ -0,0 +1,162 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.packages;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.templates.TemplateCategory;
+import java.io.File;
+import java.io.FileFilter;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import org.xml.sax.SAXParseException;
+
+/**
+ *
+ * @author cs202741
+ */
+public class Package implements Comparable{
+
+ private String name;
+ private File packageDir, packageRoot;
+ private List templateList, templateDirs;
+ private LocaleManager mLocaleManager = null;
+ private String resourceJar = null;
+
+ /** Creates a new instance of Package */
+ public Package(String name, File packageDir, File packageRoot, LocaleManager aLocaleManager, ArrayList aPropertyList) {
+ this.name = name;
+ this.packageDir = packageDir;
+ this.packageRoot = packageRoot;
+ mLocaleManager = aLocaleManager;
+
+ templateList = new ArrayList();
+ templateDirs = getTemplateDirs( packageDir );
+ resourceJar = getResourceJar();
+ mLocaleManager.addPackageLocale( name, resourceJar );
+
+ Iterator it = templateDirs.iterator();
+
+ while( it.hasNext() ){
+ recurseFindTemplates( ((File)it.next()).toString(), aPropertyList );
+ }
+ }
+
+
+ private String recurseFindTemplates(String dirItem, ArrayList aPropertyList) {
+ File file;
+ String list[], result;
+
+ result = dirItem;
+
+ file = new File(dirItem);
+ if (file.isDirectory()) {
+ list = file.list();
+ for (int i = 0; i < list.length; i++)
+ result = result + "\n" + recurseFindTemplates(dirItem + File.separatorChar + list[i], aPropertyList);
+ }else{
+ Template template;
+ try {
+ String ext = file.getName().toLowerCase();
+ int r = ext.lastIndexOf(".xml");
+ if( r > 0){
+ template = new Template(file, name, packageRoot, resourceJar, mLocaleManager, aPropertyList);
+ templateList.add( template );
+ }
+ } catch (SAXParseException ex) {
+ System.err.println( ex.getMessage() );
+ }
+ }
+ return result;
+ }
+
+ public List getTemplateDirs(File dir){
+
+ File tempDir = new File( dir.getAbsolutePath() +
+ File.separator +
+ "templates" );
+
+ File[] tmp = tempDir.listFiles();
+
+ List list = new ArrayList();
+
+ for( int i = 0; i < tmp.length; i++){
+ if( tmp[i].isDirectory() ){
+ list.add( tmp[i] );
+ }
+ }
+
+ return list;
+ }
+
+ private String getResourceJar(){
+ File dir = new File( packageDir.toString() + "/lib" );
+ FileFilter fileFilter = new FileFilter() {
+ public boolean accept(File file) {
+ return file.toString().endsWith(".jar");
+ }
+ };
+ File[] files = dir.listFiles(fileFilter);
+
+ if( files != null ){
+ return files[0].toString();
+ }else
+ return null;
+ }
+
+ public String getName(){
+ return name;
+ }
+
+ public List getTemplates(){
+ return templateList;
+ }
+
+ public String toString(){
+ String result = "Package: " + name;
+
+ Iterator it = templateList.iterator();
+ while( it.hasNext() ){
+ result += ((Template)it.next()).toString();
+ }
+
+ return result;
+ }
+
+ public int compareTo(Object o) {
+ return name.compareTo(o.toString());
+ }
+} \ No newline at end of file
diff --git a/src/com/sun/apoc/tools/profileeditor/packages/PackageManager.java b/src/com/sun/apoc/tools/profileeditor/packages/PackageManager.java
new file mode 100644
index 0000000..ad20036
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/packages/PackageManager.java
@@ -0,0 +1,385 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.packages;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.LocalizedDefaultMutableTreeNode;
+import com.sun.apoc.tools.profileeditor.spi.StandaloneProfileManager;
+import com.sun.apoc.tools.profileeditor.PanelFactory;
+import com.sun.apoc.tools.profileeditor.templates.TemplateCategory;
+import com.sun.apoc.tools.profileeditor.templates.TemplatePage;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+import java.awt.BorderLayout;
+import java.awt.Frame;
+import java.awt.GraphicsEnvironment;
+import java.awt.Point;
+import java.awt.Rectangle;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Hashtable;
+import javax.swing.BorderFactory;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JTree;
+
+import javax.swing.tree.*;
+
+
+/**
+ *
+ * @author cs202741
+ */
+public class PackageManager {
+
+ private File packageDir;
+ private List packageList;
+ private Hashtable packageHash;
+ private DefaultMutableTreeNode rootNode;
+ private JFrame mProgressFrame;
+ private HashMap mTemplatePanels;
+ private StandaloneProfileManager mProfileModel;
+ private boolean mPackageOpen = false;
+
+ private ArrayList mPropertyList = null;
+ private HashMap mPropertyIndex = null;
+
+ private JProgressBar mProgressBar = null;
+
+ private LocaleManager mLocaleManager = null;
+
+
+ /** Creates a new instance of PackageTreeManager */
+ public PackageManager(File aDir, StandaloneProfileManager aProfileModel, LocaleManager aLocaleManager) {
+ packageDir = aDir;
+ mProfileModel = aProfileModel;
+ mLocaleManager = aLocaleManager;
+ }
+
+ public void initialize() throws FileNotFoundException{
+
+ try{
+ mPropertyList = new ArrayList();
+ packageList = getPackages( packageDir );
+ mTemplatePanels = new HashMap();
+ generatePackageHash();
+ createPropertyIndex();
+ }catch(FileNotFoundException e){
+ closeProgressDialog();
+ throw new FileNotFoundException();
+ }
+ }
+
+ public List getPackages(File dir) throws FileNotFoundException {
+ if( dir.exists() ){
+ File[] fileList = dir.listFiles();
+ List list = new ArrayList();
+
+
+ String[] tokens = dir.toString().split("_");
+
+ if( tokens[tokens.length-1].equalsIgnoreCase("pkg") ){
+ tokens = tokens[0].split("/");
+ list.add( new Package( tokens[tokens.length-1], dir, packageDir, mLocaleManager, mPropertyList ) );
+ }else if( dir.toString().toLowerCase().lastIndexOf(".xml") > 0){
+ list.add( new Package( dir.toString().substring(0,dir.toString().length()-4), dir, packageDir, mLocaleManager, mPropertyList ) );
+ }else if( dir.toString().startsWith("SUNW") ){
+ list.add( new Package( dir.toString(), dir, packageDir, mLocaleManager, mPropertyList ) );
+ }
+
+ showProgressDialog(fileList.length-1);
+
+ for( int i = 0; i < fileList.length; i++){
+ if( fileList[i].isDirectory() ){
+ tokens = fileList[i].toString().split("_");
+ if ( tokens[tokens.length-1].equalsIgnoreCase("pkg") ){
+ tokens = tokens[0].split("/");
+ list.add( new Package( tokens[tokens.length-1], fileList[i], packageDir, mLocaleManager, mPropertyList ) );
+ mProgressBar.setValue( i + 1);
+ }//if
+ }//if
+ }//for
+ if( list.size() == 0){
+ throw new FileNotFoundException( dir.toString() );
+ }
+
+ closeProgressDialog();
+ mPackageOpen = true;
+
+ Collections.sort( list );
+ return list;
+ }else
+ throw new FileNotFoundException( dir.toString() );
+ }
+
+
+ private void generatePackageHash(){
+
+ if( packageList != null ){
+ Hashtable packages = new Hashtable();
+ rootNode = new LocalizedDefaultMutableTreeNode();
+ rootNode.setUserObject("Templates");
+
+ Iterator pkgIt = packageList.iterator();
+ while( pkgIt.hasNext() ){
+ Package tmpPkg = (Package)pkgIt.next();
+
+ Iterator templateIt = tmpPkg.getTemplates().iterator();
+ while( templateIt.hasNext() ){
+
+ Template tmpTemplate = (Template)templateIt.next();
+ TemplateCategory category = tmpTemplate.getRootCategory();
+ String name = tmpTemplate.getName();
+
+ //DefaultMutableTreeNode baseNode = new DefaultMutableTreeNode( name );
+ Hashtable[] subCategories = null;
+
+ if( ! packages.containsKey(name) ){
+ subCategories = new Hashtable[4];
+ for(int i = 0; i < subCategories.length; i++){
+ subCategories[i] = new Hashtable();
+ }
+ packages.put( name, subCategories );
+ }
+
+ subCategories = (Hashtable[])packages.get( name );
+
+ rootNode.add( recursCreateTree( tmpPkg.getName(), subCategories, 0, name, category, tmpTemplate) );
+
+ }//while
+ }//while
+
+ }//if
+
+ }//generatePackageHash()
+
+
+
+ private DefaultMutableTreeNode recursCreateTree( String pkgName, Hashtable[] hash, int index, String previousName,
+ TemplateCategory category, Template template){
+
+ String name = category.getDefaultName();
+ String resourceID = category.getResourceId();
+
+ DefaultMutableTreeNode currentNode = getMatchingNode(hash[index], previousName+name );
+
+ if( currentNode == null ){
+ currentNode = new LocalizedDefaultMutableTreeNode( name, pkgName, category.getResourceId(),
+ category.getDefaultName(), mLocaleManager );
+ hash[index].put( previousName+name, currentNode );
+ }
+
+ if( category.hasSubCategories() ){
+ String[] keys = category.getKeys();
+
+ for(int i = 0; i < keys.length; i++){
+ category = category.getSubCategory( keys[i] );
+ currentNode.add( recursCreateTree( pkgName, hash, ++index, name, category, template) );
+ }
+ return currentNode;
+ }else{
+ template.setName( resourceID, category.getDefaultName() );
+ template.setPath( category.getPath() );
+ template.setTreeNode(currentNode);
+ template.setResourceIdPath( category.getResourceIdPath() );
+ currentNode.setUserObject(template);
+ return currentNode;
+ }
+ }//end recursCreateTree()
+
+
+ private void createPropertyIndex(){
+ mPropertyIndex = new HashMap();
+
+ Iterator it = mPropertyList.iterator();
+ while(it.hasNext()){
+ TemplateProperty property = (TemplateProperty)it.next();
+ mPropertyIndex.put( property.getDataPath(), property );
+ }
+ }
+
+ public Template getTemplateByProperty(String dataPath){
+ Iterator it = packageList.iterator();
+ while(it.hasNext()){
+ Package pkg = (Package)it.next();
+ List list = pkg.getTemplates();
+ Iterator temIt = list.iterator();
+ while(temIt.hasNext()){
+ Template template = (Template)temIt.next();
+ if( template.containsSet(dataPath) ){
+ return template;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void removeSets(){
+ Iterator it = packageList.iterator();
+ while(it.hasNext()){
+ Package pkg = (Package)it.next();
+ List list = pkg.getTemplates();
+ Iterator temIt = list.iterator();
+ while(temIt.hasNext()){
+ ((Template)temIt.next()).removeSets();
+ }
+ }
+ }
+
+ public TemplateProperty lookupProperty(String dataPath){
+ if( mPropertyIndex != null )
+ return (TemplateProperty)mPropertyIndex.get( dataPath );
+ else
+ return null;
+ }
+
+ public DefaultMutableTreeNode getMatchingNode(Hashtable hash, String name){
+ DefaultMutableTreeNode node = null;
+
+ Enumeration e = hash.keys();
+ while( e.hasMoreElements() ){
+ Object obj = e.nextElement();
+ String currName = (String)obj;
+
+ if( currName.equals( name ) ) {
+ DefaultMutableTreeNode currNode = (DefaultMutableTreeNode)hash.get(obj);
+ node = currNode;
+ break;
+ }
+ }
+ return node;
+ }//end getMatchingNode()
+
+
+ public JPanel getTemplatePanel(Template aTemplate, String aLocale, JTree aTree){
+ String name = aTemplate.getPath();
+ JPanel panel = null;
+
+ if( mTemplatePanels.containsKey( name ) ){
+ panel = (JPanel)mTemplatePanels.get( name );
+ }else{
+ panel = PanelFactory.getTemplatePanel( aTemplate, mProfileModel, aTree );
+ mTemplatePanels.put( name, panel );
+ }
+
+ return panel;
+ }
+
+ public HashMap getTemplatePanels(){
+ return mTemplatePanels;
+ }
+
+ public void clearTemplatePanels(){
+ mTemplatePanels.clear();
+ }
+
+ public DefaultMutableTreeNode getRootTreeNode(){
+ return rootNode;
+ }
+
+
+ public Hashtable getPackageHash(){
+ return packageHash;
+ }
+
+ public boolean isOpen(){
+ return mPackageOpen;
+ }
+
+
+ public String toString(){
+ String result = "";
+
+ Iterator it = packageList.iterator();
+ while( it.hasNext() ){
+ result += ((Package)it.next()).toString();
+ }
+ return result;
+ }
+
+
+ private void showProgressDialog(int length){
+ int WIDTH = 300;
+ int HEIGHT = 150;
+
+ mProgressFrame = new JFrame("Loading Templates...");
+ JPanel contentPanel = new JPanel(new BorderLayout());
+ contentPanel.setBorder( BorderFactory.createEmptyBorder( 30, 30, 30, 30) );
+
+ mProgressFrame.setContentPane( contentPanel );
+ mProgressFrame.setAlwaysOnTop(true);
+ mProgressBar = new JProgressBar( 0, length);
+ mProgressBar.setValue(0);
+ mProgressBar.setStringPainted(true);
+
+ contentPanel.add( new JLabel( "Please wait..." ), BorderLayout.PAGE_START );
+ contentPanel.add( mProgressBar, BorderLayout.CENTER );
+
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Point center = ge.getCenterPoint();
+ Rectangle bounds = ge.getMaximumWindowBounds();
+
+ int x = center.x - WIDTH/2, y = center.y - HEIGHT/2;
+ mProgressFrame.setBounds(x, y, WIDTH, HEIGHT);
+ if (WIDTH == bounds.width && HEIGHT == bounds.height){
+ mProgressFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
+ }
+ mProgressFrame.validate();
+
+ mProgressFrame.setVisible(true);
+ mProgressFrame.pack();
+ }
+
+
+ private void closeProgressDialog(){
+
+ if( mProgressFrame != null ){
+ mProgressFrame.setVisible(false);
+ mProgressFrame.dispose();
+ mProgressBar = null;
+ mProgressFrame = null;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com/sun/apoc/tools/profileeditor/packages/PackageNode.java b/src/com/sun/apoc/tools/profileeditor/packages/PackageNode.java
new file mode 100644
index 0000000..83a546d
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/packages/PackageNode.java
@@ -0,0 +1,67 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.packages;
+
+/**
+ *
+ * @author cs202741
+ */
+import java.util.Vector;
+
+public class PackageNode {
+ PackageNode parent;
+ Vector<PackageNode> children;
+ private String name;
+
+ public PackageNode(String name) {
+ this.name = name;
+ parent = null;
+ children = new Vector<PackageNode>();
+ }
+
+
+ public String toString() { return name; }
+ public String getName() { return name; }
+ public PackageNode getParent() { return parent; }
+ public int getChildCount() { return children.size(); }
+ public PackageNode getChildAt(int i) {
+ return (PackageNode)children.elementAt(i);
+ }
+ public int getIndexOfChild(PackageNode kid) {
+ return children.indexOf(kid);
+ }
+}
+
diff --git a/src/com/sun/apoc/tools/profileeditor/packages/Template.java b/src/com/sun/apoc/tools/profileeditor/packages/Template.java
new file mode 100644
index 0000000..5e77d2d
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/packages/Template.java
@@ -0,0 +1,191 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.packages;
+
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.gui.SetPanel;
+import com.sun.apoc.tools.profileeditor.templates.TemplateCategory;
+import com.sun.apoc.tools.profileeditor.templates.TemplatePage;
+import com.sun.apoc.tools.profileeditor.templates.TemplateParser;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.io.File;
+import java.util.Iterator;
+import javax.swing.tree.DefaultMutableTreeNode;
+import org.xml.sax.SAXParseException;
+
+/**
+ *
+ * @author cs202741
+ */
+public class Template {
+
+ private String mTemplateName, mPackageName;
+ private File templateFile, packageRoot;
+ private TemplateCategory templateRoot;
+
+ private DefaultMutableTreeNode mTreeNode = null;
+ private String mDataPath = null;
+ private String resourceJar = null;
+ private String mResourceIdPath = null;
+ private String mPath = null;
+ //private String mTemplatePath = null;
+ private LocaleManager mLocaleManager = null;
+ private HashMap mSetPropertyList = null;
+ private ArrayList<SetPanel> mSetPanels = null;
+
+ /** Creates a new instance of Template */
+ public Template(File templateFile, String aPackageName, File packageRoot, String aResourceJar,
+ LocaleManager aLocaleManager, ArrayList aPropertyList) throws SAXParseException {
+ this.templateFile = templateFile;
+ this.packageRoot = packageRoot;
+ this.resourceJar = aResourceJar;
+ mLocaleManager = aLocaleManager;
+ mPackageName = aPackageName;
+ mSetPanels = new ArrayList();
+
+ TemplateParser parser = new TemplateParser( templateFile, packageRoot, aPropertyList );
+ templateRoot = parser.getRootCategory();
+ mSetPropertyList = parser.getSetList();
+ parser = null;
+
+ String[] keys = templateRoot.getKeys();
+
+ templateRoot = templateRoot.getSubCategory(keys[0]);
+
+ mTemplateName = templateRoot.getDefaultName();
+
+ String pkg = packageRoot.getPath();
+ String path = templateFile.getPath();
+ }
+
+
+ public LocaleManager getLocaleManager(){
+ return mLocaleManager;
+ }
+
+ public TemplateCategory getRootCategory(){
+ return (templateRoot != null) ? templateRoot : null;
+ }
+
+ public String getPackageName(){
+ return mPackageName;
+ }
+
+
+ public void setName(String aResourceId, String aDefaultName){
+ String localeName = mLocaleManager.getLocalizedName( mPackageName, aResourceId, aDefaultName );
+ if( localeName == null ){
+ localeName = aResourceId;
+ }
+
+ this.mTemplateName = localeName;
+ }
+
+ public String getName(){
+ return mTemplateName;
+ }
+
+
+ public void setPath(String path){
+ mPath = path;
+ }
+
+
+ public String getPath(){
+ return mPath;
+ }
+
+ public void setResourceIdPath(String path){
+ mResourceIdPath = path;
+ }
+
+ public String getResourceIdPath(){
+ return mResourceIdPath;
+ }
+
+ public void setDataPath(String aDataPath){
+ mDataPath = aDataPath.substring( 0, aDataPath.lastIndexOf("/") );
+ }
+
+ public String getDataPath(){
+ return mDataPath;
+ }
+
+ public void setTreeNode(DefaultMutableTreeNode node){
+ mTreeNode = node;
+ }
+
+ public DefaultMutableTreeNode getTreeNode(){
+ return mTreeNode;
+ }
+
+ public File getTemplateFile(){
+ return templateFile;
+ }
+
+ public File getPackageRoot(){
+ return packageRoot;
+ }
+
+ public String getResourceJar(){
+ return resourceJar;
+ }
+
+ public boolean containsSet(String dataPath){
+ if( mSetPropertyList.get(dataPath) != null ){
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+ public void addSetPanel(SetPanel panel){
+ mSetPanels.add( panel );
+ }
+
+ public void removeSets(){
+ Iterator it = mSetPanels.iterator();
+ while(it.hasNext()){
+ ((SetPanel)it.next()).removeAllSets();
+ }
+ }
+
+ public String toString(){
+ return mTemplateName;
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/StandalonePolicyManager.java b/src/com/sun/apoc/tools/profileeditor/spi/StandalonePolicyManager.java
new file mode 100644
index 0000000..740a17e
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/StandalonePolicyManager.java
@@ -0,0 +1,274 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.spi;
+
+
+import com.sun.apoc.spi.SPIException;
+import java.util.HashMap ;
+import java.util.Map ;
+
+import com.sun.apoc.spi.environment.EnvironmentMgr ;
+import com.sun.apoc.spi.profiles.Profile;
+import com.sun.apoc.spi.profiles.ProfileProvider;
+
+
+/**
+ * Main access point to the policy management objects, basically maps to an
+ * instance of the meta-configuration file.
+ */
+public class StandalonePolicyManager {
+
+ private ProfileProvider mProvider = null;
+
+
+ /**
+ * Constructor from a hashtable providing values for the meta-configuration
+ * of the policy access (location of entity trees, storage of profiles and
+ * their assignments).
+ *
+ * @param aBootstrapInfo hashtable with bootstrap information
+ * @throws SPIException if an error occurs.
+ */
+
+ public StandalonePolicyManager(ProfileProvider aProvider) throws SPIException {
+ mProvider = aProvider;
+ }
+
+
+// public StandalonePolicyManager(Hashtable aBootstrapInfo) throws SPIException {
+// mEnvironment = new EnvironmentMgr(aBootstrapInfo) ;
+// mEnvironment.checkEnvironment();
+// String [] sources = mEnvironment.getSources() ;
+//
+// mSources = new PolicySource [sources.length] ;
+// for (int i = 0 ; i < sources.length ; ++ i) {
+// mSources [i] = new PolicySource(sources [i], mEnvironment) ;
+// mSourcesByName.put(sources [i], mSources [i]) ;
+// }
+// }
+
+ /**
+ * Returns the entity provider for a given source.
+ *
+ * @param aSource source name
+ * @return entity provider or null if it doesn't exist
+ */
+// public EntityTreeProvider getEntityProvider(String aSource) {
+// PolicySource source = (PolicySource)mSourcesByName.get(aSource) ;
+//
+// return source != null ? source.getEntityProvider() : null ;
+// }
+
+ /**
+ * Returns the assignment provider for a given source.
+ *
+ * @param aSource source name
+ * @return assignment provider or null if it doesn't exist
+ */
+// public AssignmentProvider getAssignmentProvider(String aSource) {
+// PolicySource source = (PolicySource)mSourcesByName.get(aSource) ;
+//
+// return source != null ? source.getAssignmentProvider() : null ;
+// }
+
+ /**
+ * Returns the profile provider for a given source.
+ *
+ * @param aSource source name
+ * @return profile provider or null if it doesn't exist
+ */
+ public ProfileProvider getProfileProvider(String aSource) {
+
+ return mProvider != null ? mProvider : null ;
+ }
+
+// /**
+// * Returns the root entity for a given source.
+// *
+// * @param aSource source name
+// * @return root entity or null if it doesn't exist
+// */
+// public Entity getRootEntity(String aSource) throws SPIException {
+// PolicySource source = (PolicySource)mSourcesByName.get(aSource) ;
+//
+// return source != null ? source.getRoot() : null ;
+// }
+
+// /**
+// * Returns the entity with given id for a given source.
+// *
+// * @param aSource source name
+// * @param aId entity id
+// * @return entity or null if it doesn't exist
+// */
+// public Entity getEntity(String aSource, String aId) throws SPIException {
+// PolicySource source = (PolicySource)mSourcesByName.get(aSource) ;
+//
+// return source != null ? source.getEntity(aId) : null ;
+// }
+
+// /**
+// * Returns the entity with given id from all sources.
+// *
+// * @param aId entity id
+// * @return entity or null if it doesn't exist
+// */
+// public Entity getEntity(String aId) throws SPIException {
+// Entity sEntity = null;
+// for (int i = 0 ; i < mSources.length && sEntity == null; ++ i) {
+// sEntity = getEntity(mSources[i].getName(), aId);
+// }
+//
+// return sEntity ;
+// }
+
+ /**
+ * Returns the profile with given id for a given source.
+ *
+ * @param aSource source name
+ * @param aId profile id
+ * @return profile or null if it doesn't exist
+ */
+ public Profile getProfile(String aSource, String aId) throws SPIException {
+ //PolicySource source = (PolicySource)mSourcesByName.get(aSource) ;
+ //ProfileProvider provider = source.getProfileProvider();
+ Profile profile = null;
+ if (mProvider != null) {
+ try {
+ profile = mProvider.getProfile(aId);
+// if (profile != null) {
+// if (!profile.getApplicability().getStringValue().equals(source.getName())) {
+// profile = null;
+// }
+// }
+ } catch (SPIException e) {
+ System.out.println(e);
+ }
+ }
+
+ System.out.println("StandPolicyManager: profile = " + profile);
+
+ return profile;
+ }
+
+ /**
+ * Returns the profile with given id from all sources.
+ *
+ * @param aId profile id
+ * @return profile or null if it doesn't exist
+ */
+ public Profile getProfile(String aId) throws SPIException {
+
+ Profile sProfile = getProfile("source", aId);
+
+ return sProfile ;
+ }
+
+ /**
+ * Returns all the <code>Profile</code>s.
+ *
+ * @return an Iterator over all the <code>Profile</code> objects
+ * @throws <code>SPIException</code> if error occurs
+ */
+// public Iterator getAllProfiles() throws SPIException {
+// ArrayList sProfileList = new ArrayList();
+// for (int i = 0 ; i < mSources.length; ++ i) {
+// ProfileProvider sProvider = mSources[i].getProfileProvider();
+// Iterator it = sProvider.getAllProfiles();
+// while (it.hasNext()) {
+// Profile sProfile = (Profile)it.next();
+// // if (!sProfileList.contains(sProfile)) {
+// sProfileList.add(sProfile);
+// // }
+// }
+// }
+// return sProfileList.iterator() ;
+// }
+
+ /**
+ * Returns the profile repository with given id for a given source.
+ *
+ * @param aSource source name
+ * @param aId profile repository id
+ * @return profile repository or null if it doesn't exist
+ */
+// public ProfileRepository getProfileRepository(String aSource, String aId) throws SPIException {
+// PolicySource source = (PolicySource)mSourcesByName.get(aSource) ;
+// ProfileProvider provider = source.getProfileProvider();
+// return provider != null ? provider.getProfileRepository(aId) : null ;
+// }
+
+ /**
+ * Returns the default profile repository for a given source.
+ *
+ * @param aSource source name
+ * @return default profile repository or null if it doesn't exist
+ */
+// public ProfileRepository getDefaultProfileRepository(String aSource) throws SPIException {
+// PolicySource source = (PolicySource)mSourcesByName.get(aSource) ;
+// ProfileProvider provider = source.getProfileProvider();
+// return provider != null ? provider.getDefaultProfileRepository() : null ;
+// }
+
+ /**
+ * Returns a copy of the environment table used to establish this object.
+ *
+ * @return <code>Hashtable</code> containing environmental settings
+ */
+// public Hashtable getEnvironment() throws SPIException {
+// return mEnvironment.getEnvironment();
+// }
+
+ /**
+ * Returns the array of policy source names used by this policy manager instance.
+ *
+ * @return <code>Hashtable</code> containing environmental settings
+ */
+// public String[] getSources() throws SPIException {
+// return mEnvironment.getSources();
+// }
+
+ /**
+ * Closes the sessions on the different providers
+ *
+ * @throws <code>SPIException</code> if error occurs
+ */
+// public void close() throws SPIException {
+// for (int i = 0 ; i < mSources.length ; ++ i) {
+// mSources[i].close();
+// }
+// }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/StandalonePolicyManagerHelper.java b/src/com/sun/apoc/tools/profileeditor/spi/StandalonePolicyManagerHelper.java
new file mode 100644
index 0000000..fe1c20b
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/StandalonePolicyManagerHelper.java
@@ -0,0 +1,424 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.spi;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+import java.net.URLEncoder;
+import java.net.URLDecoder;
+import java.io.UnsupportedEncodingException;
+
+import com.sun.apoc.spi.cfgtree.policynode.PolicyNode;
+import com.sun.apoc.spi.cfgtree.PolicyTree;
+import com.sun.apoc.spi.cfgtree.property.Property;
+import com.sun.apoc.spi.cfgtree.readwrite.ReadWritePolicyTreeConverterImpl;
+import com.sun.apoc.spi.cfgtree.readwrite.ReadWritePolicyTreeFactoryImpl;
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.policies.Policy;
+import com.sun.apoc.spi.profiles.Profile;
+
+/**
+ * A helper class containing convenience methods for common SPI operations
+ */
+public class StandalonePolicyManagerHelper {
+
+ public static final String SEPARATOR = "/";
+
+ private StandalonePolicyManager m_mgr = null;
+ private Profile m_pg = null;
+ private HashMap m_treeCache = new HashMap();
+ private HashMap m_definedProps = null;
+
+ public StandalonePolicyManagerHelper() {
+ }
+
+ public StandalonePolicyManagerHelper(StandalonePolicyManager mgr, Profile pg) {
+ initialize(mgr, pg);
+ }
+
+ /**
+ * Returns the PolicyMgrHelper object.
+ */
+ public StandalonePolicyManager getManager() {
+ return m_mgr;
+ }
+
+ /**
+ * Returns the current Profile object.
+ */
+ public Profile getPolicyGroup() {
+ return m_pg;
+ }
+
+ public void initialize(StandalonePolicyManager mgr, Profile pg) {
+ m_mgr = mgr;
+ m_pg = pg;
+ m_treeCache.clear();
+
+ }
+
+
+ /**
+ * Returns the Property from the backend specified by the path
+ * parameter.
+ *
+ * @param path - the dataPath defining the property to return
+ * @return an SPI Property object or null if it does not exist
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public Property getProperty(String path) throws SPIException {
+ String propertyName = decodePath(path.substring(path.lastIndexOf(SEPARATOR) + 1, path.length()));
+ String nodePath = path.substring(0, path.lastIndexOf(SEPARATOR));
+ PolicyNode node = getNode(nodePath);
+ if (node != null) {
+ return node.getProperty(propertyName);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Compares 2 Property objects for equality
+ *
+ * @param 2 SPI Property objects for comparisonthe dataPath defining the property to return
+ * @return true if the SPI Propertys are equal
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public boolean equalProperties(Property prop1, Property prop2) throws SPIException {
+ if ((prop1 == null) || (prop2 == null)) {
+ return false;
+ } else if (prop1.isProtected() != prop2.isProtected()) {
+ return false;
+ } else if (prop1.getValue() == null) {
+ if (prop2.getValue() != null) {
+ return false;
+ }
+ } else if (!prop1.getValue().equals(prop2.getValue())) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Creates the specified Property in the backend.
+ *
+ * @param path - the dataPath defining the property to create
+ * @return an SPI Property object
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public Property createProperty(String path) throws SPIException {
+ String propertyName = decodePath(path.substring(path.lastIndexOf(SEPARATOR) + 1, path.length()));
+ String nodePath = path.substring(0, path.lastIndexOf(SEPARATOR));
+ PolicyNode node = createNode(nodePath);
+ if (node != null) {
+ return node.addProperty(propertyName);
+ } else {
+ return null;
+ }
+ }
+
+
+ public Property createReplaceProperty(String path) throws SPIException {
+ String propertyName = decodePath(path.substring(path.lastIndexOf(SEPARATOR) + 1, path.length()));
+ String nodePath = path.substring(0, path.lastIndexOf(SEPARATOR));
+ PolicyNode node = createReplaceNode(nodePath);
+ if (node != null) {
+ return node.addProperty(propertyName);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Removes the specified Property from the backend.
+ *
+ * @param path - the dataPath defining the property to remove
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public void removeProperty(String path) throws SPIException {
+ String propertyName = decodePath(path.substring(path.lastIndexOf(SEPARATOR) + 1, path.length()));
+ String nodePath = path.substring(0, path.lastIndexOf(SEPARATOR));
+ PolicyNode node = getNode(nodePath);
+ if (node != null) {
+ node.removeProperty(propertyName);
+ }
+ }
+
+ /**
+ * Checks for the existance of the specified node in the backend.
+ *
+ * @param path - the dataPath defining the node to check for
+ * @return true if node exists in the backend
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public boolean nodeExists(String path) throws SPIException {
+ String policyId = path.substring(0, path.indexOf(SEPARATOR));
+ PolicyTree policyTree = getTree(policyId);
+ if (policyTree != null) {
+ return policyTree.nodeExists(path);
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the specified PolicyNode from the backend.
+ *
+ * @param path - the dataPath defining the PolicyNode to return
+ * @return an SPI PolicyNode object or null if it does not exist
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public PolicyNode getNode(String path) throws SPIException {
+ int pos = path.indexOf(SEPARATOR);
+ String policyId = path;
+ if (pos != -1) {
+ policyId = path.substring(0, path.indexOf(SEPARATOR));
+ }
+ PolicyTree policyTree = getTree(policyId);
+ if (policyTree != null) {
+ return policyTree.getNode(path);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Creates the specified PolicyNode in the backend.
+ *
+ * @param path - the dataPath defining the PolicyNode to create
+ * @return an SPI PolicyNode object
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public PolicyNode createNode(String path) throws SPIException {
+ return createNode(path, false);
+ }
+
+ /**
+ * Creates the specified PolicyNode in the backend. This node will have the oor:replace
+ * attribute as used by template set elements.
+ *
+ * @param path - the dataPath defining the PolicyNode to create
+ * @return an SPI PolicyNode object
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public PolicyNode createReplaceNode(String path) throws SPIException {
+ return createNode(path, true);
+ }
+
+ /**
+ * Creates the specified PolicyNode in the backend.
+ *
+ * @param path - the dataPath defining the PolicyNode to create
+ * @param replace - whether to add the oor:replace attribute to the node
+ * @return an SPI PolicyNode object
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public PolicyNode createNode(String path, boolean replace) throws SPIException {
+ int pos = path.indexOf(SEPARATOR);
+ String policyId = path;
+ if (pos != -1) {
+ policyId = path.substring(0, path.indexOf(SEPARATOR));
+ }
+ PolicyTree policyTree = getTree(policyId);
+ if (policyTree != null) {
+ if (replace) {
+ return policyTree.createReplaceNode(path);
+ } else {
+ return policyTree.createNode(path);
+ }
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Writes all newly created/edited PolicyNodes/Propertys to the backend.
+ *
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public void flushAllChanges() throws SPIException {
+ Iterator it = m_treeCache.keySet().iterator();
+ while (it.hasNext()) {
+ PolicyTree policyTree = getTree((String) it.next());
+ if (policyTree.hasBeenModified()) {
+ ReadWritePolicyTreeConverterImpl converter = new ReadWritePolicyTreeConverterImpl();
+ Policy policy = converter.getPolicy(policyTree);
+ getPolicyGroup().storePolicy(policy);
+ }
+ }
+ }
+
+ /**
+ * Removes from the cache any PolicyNodes/Propertys objects which were created/edited since the last
+ * call to flushAllChanges().
+ */
+ public void resetAllChanges() {
+ m_treeCache.clear();
+ }
+
+ /**
+ * Returns the specified PolicyTree object.
+ *
+ * @param policyId - the policy path defining the PolicyTree to return
+ * @return an SPI PolicyTree object
+ * @throws <code>SPIException</code> if error occurs
+ */
+ public PolicyTree getTree(String policyId) throws SPIException {
+ PolicyTree policyTree = null;
+
+ if (m_treeCache.containsKey(policyId)) {
+ policyTree = (PolicyTree) m_treeCache.get(policyId);
+ } else {
+ ReadWritePolicyTreeFactoryImpl factory = new ReadWritePolicyTreeFactoryImpl();
+ Policy policy = null;
+ if (getPolicyGroup() != null) {
+ policy = getPolicyGroup().getPolicy(policyId);
+ }
+ if (policy == null) {
+ policy = new Policy(policyId, m_pg.getId(), null);
+ }
+ Vector policies = new Vector();
+ policies.add(policy);
+ policyTree = factory.getPolicyTree(policies.iterator());
+ m_treeCache.put(policyId, policyTree);
+ }
+ return policyTree;
+ }
+
+
+
+ //
+ //
+ //
+ public HashMap getAllDefinedProperties(Profile profile)
+ throws SPIException {
+
+ m_definedProps = new HashMap();
+
+ Iterator policyIds = profile.getPolicies();
+
+ while (policyIds.hasNext()) {
+ String policyId = ((Policy)policyIds.next()).getId();
+ PolicyTree tree = getTree(policyId, profile);
+ recursiveGetProperties(tree, "");
+ }
+ return m_definedProps;
+ }
+
+
+
+ public void recursiveGetProperties(PolicyTree policyTree, String nodePath)
+ throws SPIException {
+ PolicyNode node = null;
+ if (nodePath.length() == 0) {
+ node = policyTree.getRootNode(); } else {
+ String pathSoFar = policyTree.getRootNode().getAbsolutePath() + nodePath + "/";
+ node = policyTree.getNode(pathSoFar);
+ }
+ //String encodedSlash = Toolbox2.encode("/");
+
+ String[] propNames = node.getPropertyNames();
+ String[] childNames = node.getChildrenNames();
+ if (propNames != null && propNames.length != 0) {
+ for (int i = 0; i < propNames.length; i++) {
+ //String dataPath = policyTree.getRootNode().getAbsolutePath() + nodePath + "/" + propNames[i].replaceAll("/", encodedSlash);
+ String dataPath = policyTree.getRootNode().getAbsolutePath() + nodePath + "/" + propNames[i];
+ m_definedProps.put(dataPath, node.getProperty(propNames[i]));
+ }
+ }
+ if (childNames != null && childNames.length != 0) {
+ for (int j = 0; j < childNames.length; j++) {
+ recursiveGetProperties(policyTree, nodePath + "/" + childNames[j]);
+ }
+ }
+ }
+
+ public PolicyTree getTree(String policyId, Profile profile) throws SPIException {
+ PolicyTree policyTree = null;
+ if (m_treeCache.containsKey(policyId)) {
+ policyTree = (PolicyTree) m_treeCache.get(policyId);
+ } else {
+ ReadWritePolicyTreeFactoryImpl factory = new ReadWritePolicyTreeFactoryImpl();
+ Policy policy = null;
+ if (profile != null) {
+ policy = profile.getPolicy(policyId);
+ }
+ if (policy == null) {
+ policy = new Policy(policyId, profile.getId(), null);
+ }
+ Vector policies = new Vector();
+ policies.add(policy);
+ policyTree = factory.getPolicyTree(policies.iterator());
+ m_treeCache.put(policyId, policyTree);
+ }
+ return policyTree;
+ }
+
+
+
+
+
+
+ // The below methods are just helpers to implement the enconding
+ // decoding of path elements. A similar functionality is already available
+ // within the SPI - but not public API yet.
+ public static String decodePath(String pathElement) throws SPIException {
+ try {
+ if (pathElement.indexOf('%') == -1) {
+ return pathElement;
+ } else {
+ return URLDecoder.decode(pathElement, "UTF-8");
+ }
+ } catch (UnsupportedEncodingException ex) {
+ throw new SPIException(ex);
+ }
+ }
+
+
+ public static String encodePath(String pathElement) throws SPIException {
+ try {
+ if (pathElement.indexOf('/') != -1) {
+ return URLEncoder.encode(pathElement, "UTF-8");
+ } else {
+ return pathElement;
+ }
+ } catch (UnsupportedEncodingException ex) {
+ throw new SPIException(ex);
+ }
+ }
+}
+
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfile.java b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfile.java
new file mode 100644
index 0000000..d64b72f
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfile.java
@@ -0,0 +1,633 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.spi;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.zip.ZipException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import com.sun.apoc.spi.IllegalReadException;
+import com.sun.apoc.spi.IllegalWriteException;
+import com.sun.apoc.spi.PolicySource;
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.policies.Policy;
+import com.sun.apoc.spi.policies.PolicyInfo;
+import com.sun.apoc.spi.profiles.Applicability;
+import com.sun.apoc.spi.profiles.InvalidPriorityException;
+import com.sun.apoc.spi.profiles.Profile;
+import com.sun.apoc.spi.profiles.ProfileRepository;
+import com.sun.apoc.spi.profiles.ProfileStreamException;
+import com.sun.apoc.spi.profiles.ProfileZipException;
+
+import com.sun.apoc.tools.profileeditor.spi.ZipProfileReadWrite;
+
+/**
+ *
+ * @author cs202741
+ */
+public class StandaloneProfile implements Profile{
+
+ // field variables
+ private ProfileRepository mRepository;
+ private PolicySource mPolicySource;
+ private String mDisplayName;
+ private Map mPolicyCache;
+ private URL mProfileURL;
+ private String mComment;
+ private String mAuthor;
+ private int mPriority;
+ private String mId;
+ private long mLastModified;
+
+ private Applicability mApplicability;
+
+ public static Profile loadProfile( String aId, ProfileRepository aRepository,
+ PolicySource aPolicySource ) throws SPIException {
+
+ Applicability aApplicability = Applicability.USER;
+ String displayName = null;
+ String author = "";
+ String comment = "";
+ int priority = 0;
+ Profile profile;
+ URL profileURL;
+
+ profile = null;
+ profileURL = null;
+
+ profileURL = getProfileURL( aId, aRepository );
+ /*
+ metaData = getMetaData( profileURL );
+ if ( metaData.containsKey( DISPLAYNAME ) ) {
+ displayName = (String) metaData.get( DISPLAYNAME );
+ }
+
+ if ( metaData.containsKey( COMMENT ) ) {
+ comment = (String) metaData.get( COMMENT );
+ }
+
+ if ( metaData.containsKey( APPLICABILITY ) ) {
+ String applicabilityStr = (String) metaData.get( APPLICABILITY );
+ applicability = Applicability.getApplicability( applicabilityStr );
+ }
+ if ( metaData.containsKey( PRIORITY ) ) {
+ String priorityStr = (String) metaData.get( PRIORITY );
+ priority = new Integer( priorityStr ).intValue();
+ }
+
+ if ( metaData.containsKey( AUTHOR ) ) {
+ author = (String)metaData.get( AUTHOR );
+ }
+ */
+ profile = new StandaloneProfile( aId, aRepository, displayName, comment, aApplicability,
+ priority, profileURL, author, true );
+
+ return profile;
+ }
+
+ public static Profile createNewProfile( ProfileRepository aRepository,
+ String aDisplayName, Applicability aApplicability, int aPriority ) throws SPIException {
+ URL profileURL;
+ String author;
+ Profile profile = null;
+
+ if ( aRepository.isReadOnly() ) {
+ throw new IllegalWriteException();
+ }
+
+ profileURL = getProfileURL( aRepository.getId(), aRepository );
+
+ author = "Author, Test";
+
+ profile = new StandaloneProfile( aRepository.getId(), aRepository, aDisplayName, "",
+ aApplicability, aPriority, profileURL, author, false );
+
+ ((StandaloneProfile)profile).writeProfile();
+
+ return profile;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#setPriority(int)
+ */
+ public void setPriority(int aPriority) throws SPIException {
+// if (((StandaloneProfileRepositoryImpl)mRepository).priorityExists( aPriority ) ) {
+// throw new InvalidPriorityException(
+// InvalidPriorityException.USED_PRIORITY_KEY, aPriority);
+// }
+
+ mPriority = aPriority;
+ writeProfile();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#setDisplayName(java.lang.String)
+ */
+ public void setDisplayName(String aDisplayName) throws SPIException {
+ if (aDisplayName == null) {
+ throw new IllegalArgumentException();
+ }
+ if ( mRepository.isReadOnly() ) {
+ throw new IllegalWriteException();
+ }
+ mDisplayName = aDisplayName;
+ writeProfile();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#storePolicy(com.sun.apoc.spi.policies.Policy)
+ */
+ public void storePolicy(Policy aPolicy) throws SPIException {
+ if (aPolicy == null) {
+ throw new IllegalArgumentException();
+ }
+ if ( mRepository.isReadOnly() ) {
+ throw new IllegalWriteException();
+ }
+
+ String id = aPolicy.getId();
+
+ if ( mPolicyCache.containsKey( id ) ) {
+ mPolicyCache.remove( id );
+ }
+
+ if ( aPolicy.getData() != null) {
+ Policy policy = aPolicy;
+ if ( aPolicy.getProfileId() == null ) {
+ /* #6283807# policies created with no profileId should get one when
+ * they are stored
+ */
+ policy = new Policy(aPolicy.getId(), this.getId(), aPolicy.getData(), aPolicy.getLastModified());
+ }
+ mPolicyCache.put( id , policy );
+ }
+ writeProfile();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#destroyPolicy(com.sun.apoc.spi.policies.Policy)
+ */
+ public void destroyPolicy(Policy aPolicy) throws SPIException {
+ if ( mRepository.isReadOnly() ) {
+ throw new IllegalWriteException();
+ }
+
+ String id = aPolicy.getId();
+
+ if (mPolicyCache.containsKey( id )) {
+ mPolicyCache.remove( id );
+ }
+
+ writeProfile();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#hasPolicies()
+ */
+ public boolean hasPolicies() throws SPIException {
+ return ( mPolicyCache.size() != 0 );
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getPolicies()
+ */
+ public Iterator getPolicies() throws SPIException {
+ return mPolicyCache.values().iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getPolicies(java.util.ArrayList)
+ */
+ public Iterator getPolicies(ArrayList aPolicyIdList) throws SPIException {
+ LinkedList policyList = new LinkedList();
+ Iterator it = aPolicyIdList.iterator();
+ String policyId;
+
+ while ( it.hasNext() ) {
+ policyId = (String) it.next();
+ if ( mPolicyCache.containsKey( policyId ) ) {
+ policyList.add( mPolicyCache.get( policyId ));
+ }
+ }
+
+ return policyList.iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getPolicy(java.lang.String)
+ */
+ public Policy getPolicy(String aId) throws SPIException {
+ if (aId == null) {
+ throw new IllegalArgumentException();
+ }
+ Policy policy = null;
+
+ if ( mPolicyCache.containsKey( aId )) {
+ policy = (Policy)mPolicyCache.get( aId);
+ }
+
+ return policy;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#hasAssignedEntities()
+ */
+ public boolean hasAssignedEntities() throws SPIException {
+ return mPolicySource.getAssignmentProvider().getAssignedEntities( this ).hasNext();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getAssignedEntities()
+ */
+ public Iterator getAssignedEntities() throws SPIException {
+ return mPolicySource.getAssignmentProvider().getAssignedEntities( this );
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#setApplicability(com.sun.apoc.spi.profiles.Applicability)
+ */
+ public void setApplicability(Applicability aApplicability)
+ throws SPIException {
+ if (aApplicability == null) {
+ throw new IllegalArgumentException();
+ }
+ if ( mRepository.isReadOnly() ) {
+ throw new IllegalWriteException();
+ }
+
+ mApplicability = aApplicability;
+
+ writeProfile();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#setComment(java.lang.String)
+ */
+ public void setComment(String aComment) throws SPIException {
+ if (aComment == null) {
+ throw new IllegalArgumentException();
+ }
+ if ( mRepository.isReadOnly() ) {
+ throw new IllegalWriteException();
+ }
+
+ mComment = aComment;
+ writeProfile();
+ }
+
+ public void setAuthor(String author) throws SPIException {
+ if(author == null){
+ author = new String("");
+ }
+ mAuthor = author;
+ writeProfile();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getAuthor()
+ */
+ public String getAuthor() throws SPIException {
+ if (mAuthor == null) {
+ return new String("");
+ }
+ return mAuthor;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object aProfile) {
+ Profile profile;
+
+ profile = (Profile)aProfile;
+ return mId.equals( profile.getId() );
+ }
+
+ private StandaloneProfile( String aId, ProfileRepository aRepository, String aDisplayName,
+ String aComment, Applicability aApplicability, int aPriority, URL aProfileURL,
+ String author, boolean aStored ) throws SPIException {
+ mApplicability = aApplicability;
+ mDisplayName = aDisplayName;
+ mRepository = aRepository;
+ mProfileURL = aProfileURL;
+ mPriority = aPriority;
+ mComment = aComment;
+ mAuthor = author;
+ mId = aId;
+
+ mPolicyCache = (Map)Collections.synchronizedMap( new HashMap() );
+
+ if ( aStored ) {
+ readPolicy(); // sets the lastModified from the zip entries
+ } else {
+ mLastModified = System.currentTimeMillis();
+ }
+ }
+
+ private void readPolicy() throws SPIException {
+ ZipInputStream input = null;
+ try {
+ input = new ZipInputStream(mProfileURL.openStream());
+ // first try to read the meta configuration data
+ Properties metaData = ZipProfileReadWrite.readMetaData(input);
+ Iterator it = null;
+ if (metaData != null) {
+ // then try to load the policy data
+ it = ZipProfileReadWrite.readPolicies(input);
+ } else {
+ // if meta data entry does not exist, we assume the old
+ // profile/policy format
+ it = ZipProfileReadWrite.readOldPoliciesFormat(input);
+ // if 'it' contains no data that means it is either an old
+ // format source but with no policies in it or that the source
+ // doesn't have the required format (new or old)
+ // in both cases, raise an exception.
+ if (!it.hasNext()) {
+ input.close();
+ throw new ProfileStreamException(ProfileStreamException.EMPTY_STREAM_KEY);
+ }
+ }
+ input.close();
+
+ // store the policies
+ Policy policy;
+ mLastModified = 0L;
+ while(it.hasNext()) {
+ policy = (Policy)it.next();
+ mPolicyCache.put( policy.getId(), new Policy( policy.getId(), mId, policy.getData(), policy.getLastModified()) );
+ // Although the last modified should be defined in setMetaData
+ // it is possible that some profiles exists without the
+ // lastModified tag in the metadata - SunITOps pre FCS APOC 2.0
+ // deployments - The following if calcualtes the lastModified
+ // bit
+ if ( mLastModified < policy.getLastModified() ) {
+ mLastModified = policy.getLastModified();
+ }
+ }
+
+ // update the meta data
+ setMetaData(metaData);
+ } catch (ZipException ze) {
+ try {
+ input.close();
+ } catch (Exception ignored) {}
+ throw new ProfileZipException(ze);
+ } catch (IOException ioe) {
+ try {
+ input.close();
+ } catch (Exception ignored) {}
+ //throw new ProfileStreamException(
+ // ProfileStreamException.ERROR_STREAM_KEY, ioe);
+ throw new SPIException();
+ }
+ }
+
+
+ private void writeProfile() throws SPIException {
+ FileOutputStream destFile = null;
+
+ if ( mRepository.isReadOnly() ) {
+ throw new IllegalWriteException();
+ }
+ try {
+ // create the profile repository
+ //((StandaloneProfileRepositoryImpl)mRepository).createStorage();
+ destFile = new FileOutputStream( mProfileURL.getPath() );
+ } catch (FileNotFoundException e) {
+ throw new IllegalWriteException(
+ IllegalWriteException.FILE_WRITE_KEY, e);
+ }
+
+ // Write data to the file
+ ZipOutputStream output = new ZipOutputStream(destFile);
+ try {
+ mLastModified = System.currentTimeMillis();
+ ZipProfileReadWrite.writeMetaData(this, output);
+ ZipProfileReadWrite.writePolicies(this, output);
+ output.close();
+ destFile.close();
+ } catch (ZipException ze) {
+ try {
+ output.close();
+ destFile.close();
+ } catch (Exception ignored) {}
+ throw new ProfileZipException(ze);
+
+ } catch (IOException ioe) {
+ try {
+ output.close();
+ destFile.close();
+ } catch (Exception ignored) {}
+ throw new ProfileStreamException(
+ ProfileStreamException.ERROR_STREAM_KEY, ioe);
+ }
+ }
+
+ private void setMetaData(Properties aMetaData ) {
+ if ( aMetaData != null ) {
+ if ( aMetaData.containsKey( ZipProfileReadWrite.DISPLAY_NAME ) ) {
+ mDisplayName = (String) aMetaData.get( ZipProfileReadWrite.DISPLAY_NAME );
+ }
+
+ if ( aMetaData.containsKey( ZipProfileReadWrite.COMMENT ) ) {
+ mComment = (String) aMetaData.get( ZipProfileReadWrite.COMMENT );
+ }
+
+ if ( aMetaData.containsKey( ZipProfileReadWrite.APPLICABILITY ) ) {
+
+ }
+ if ( aMetaData.containsKey( ZipProfileReadWrite.PRIORITY ) ) {
+ String priorityStr = (String) aMetaData.get( ZipProfileReadWrite.PRIORITY );
+ mPriority = new Integer( priorityStr ).intValue();
+ }
+
+ if ( aMetaData.containsKey( ZipProfileReadWrite.AUTHOR ) ) {
+ mAuthor = (String)aMetaData.get( ZipProfileReadWrite.AUTHOR );
+ }
+ if ( aMetaData.containsKey( ZipProfileReadWrite.LAST_MODIFIED )) {
+ mLastModified = Long.parseLong((String)aMetaData.get( ZipProfileReadWrite.LAST_MODIFIED ));
+ }
+ }
+ }
+
+ protected static URL getProfileURL( String aId, ProfileRepository aRepository )
+ throws SPIException {
+ StringBuffer profileURL;
+ String idSplit[];
+
+ profileURL = new StringBuffer( ((StandaloneProfileRepositoryImpl)aRepository).getLocation() );
+
+ if( !profileURL.substring( profileURL.length()-4, profileURL.length() ).equalsIgnoreCase(".zip") ){
+ profileURL.append( ".zip" );
+ }
+
+ URL url = null;
+ try {
+ url = new URL( profileURL.toString() );
+ } catch (MalformedURLException mue) {
+ throw new IllegalReadException(
+ IllegalReadException.FILE_READ_KEY, mue);
+ }
+ return url;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getId()
+ */
+ public String getId() {
+ return mId;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getDisplayName()
+ */
+ public String getDisplayName() {
+ if (mDisplayName == null) {
+ return new String("");
+ }
+ return mDisplayName;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getPriority()
+ */
+ public int getPriority() {
+ return mPriority;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getLastModified()
+ */
+ public long getLastModified() throws SPIException {
+ return mLastModified;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getApplicability()
+ */
+ public Applicability getApplicability() {
+ return mApplicability;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getComment()
+ */
+ public String getComment() throws SPIException {
+ if (mComment == null) {
+ return new String("");
+ }
+ return mComment;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getProfileRepository()
+ */
+ public ProfileRepository getProfileRepository() {
+ return mRepository;
+ }
+
+ static protected String createId( String aId, String aRepId ) {
+ StringBuffer id;
+
+ id = new StringBuffer( aRepId );
+ id.append( "-");
+ id.append( aId);
+
+ return id.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getPolicies(java.util.Iterator)
+ */
+ public Iterator getPolicies(Iterator aPolicyIdList) throws SPIException {
+ if (aPolicyIdList == null) {
+ throw new IllegalArgumentException();
+ }
+ List policies;
+ String id;
+
+ policies = new LinkedList();
+ while ( aPolicyIdList.hasNext() ) {
+ id = (String)aPolicyIdList.next();
+ if ( mPolicyCache.containsKey( id ) ) {
+ policies.add( mPolicyCache.get( id ) );
+ }
+ }
+ return policies.iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.Profile#getPolicyInfos(java.util.Iterator)
+ */
+ public Iterator getPolicyInfos(Iterator aPolicyIdList) throws SPIException {
+ if (aPolicyIdList == null) {
+ throw new IllegalArgumentException();
+ }
+ PolicyInfo policyInfo;
+ List policiesInfo;
+ Policy policy;
+ String id;
+
+ policiesInfo = new LinkedList();
+ while ( aPolicyIdList.hasNext() ) {
+ id = (String)aPolicyIdList.next();
+ if ( mPolicyCache.containsKey( id ) ) {
+ policy = (Policy)mPolicyCache.get( id );
+ policyInfo = new PolicyInfo(id, mId, policy.getLastModified() );
+ policiesInfo.add( policyInfo);
+ }
+ }
+
+ return policiesInfo.iterator();
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileComparator.java b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileComparator.java
new file mode 100644
index 0000000..ee94421
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileComparator.java
@@ -0,0 +1,87 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.spi;
+
+import java.util.Comparator;
+
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.entities.Entity;
+import com.sun.apoc.spi.profiles.Profile;
+
+
+/**
+ *
+ * @author cs202741
+ */
+public class StandaloneProfileComparator implements Comparator {
+
+ public int compare(Object aProfile1, Object aProfile2) {
+ int profDepth1;
+ int profDepth2;
+ Profile profile1 = (Profile)aProfile1;
+ Profile profile2 = (Profile)aProfile2;
+
+ if (profile1 == null) { return profile2 == null ? 0 : -1 ; }
+ if (profile2 == null) { return 1 ; }
+
+ profDepth1 = getProfileDepth(profile1);
+ profDepth2 = getProfileDepth(profile2);
+ if (profDepth1 != profDepth2 ) {
+ return profDepth1 - profDepth2;
+ }
+
+ if (profile1.getPriority() != profile2.getPriority()) {
+ return profile1.getPriority() - profile2.getPriority() ;
+ }
+ return profile1.getId().compareTo(profile2.getId());
+ }
+
+ private int getProfileDepth(Profile aProfile) {
+ int depth = 0;
+ try {
+ Entity entity = aProfile.getProfileRepository().getEntity();
+
+ while (entity != null ) {
+ depth++;
+ entity = entity.getParent();
+ }
+ } catch (SPIException e) {
+ // should not happend
+ }
+ return depth;
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileManager.java b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileManager.java
new file mode 100644
index 0000000..26fa57d
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileManager.java
@@ -0,0 +1,392 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.spi;
+
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.cfgtree.DataType;
+import com.sun.apoc.spi.cfgtree.property.Property;
+import com.sun.apoc.spi.cfgtree.property.ReadWritePropertyImpl;
+import com.sun.apoc.spi.profiles.Applicability;
+import com.sun.apoc.spi.profiles.Profile;
+import com.sun.apoc.spi.profiles.ProfileRepository;
+import com.sun.apoc.tools.profileeditor.LocaleManager;
+import com.sun.apoc.tools.profileeditor.PropertyComponentDummy;
+import com.sun.apoc.tools.profileeditor.gui.PropertyJListModel;
+import com.sun.apoc.tools.profileeditor.gui.PropertyComponent;
+import com.sun.apoc.tools.profileeditor.packages.PackageManager;
+import com.sun.apoc.tools.profileeditor.packages.Template;
+import com.sun.apoc.tools.profileeditor.templates.TemplateProperty;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import javax.swing.JTree;
+
+/**
+ *
+ * @author cs202741
+ */
+public class StandaloneProfileManager {
+ private StandaloneProfileProviderImpl mProfileProvider = null;
+ private StandalonePolicyManagerHelper mManagerHelper = null;
+ private PropertyJListModel mListModel = null;
+ private StandaloneProfile mProfile = null;
+
+ private File mProfileFile = null;
+
+
+ /** Creates a new instance of StandaloneProfileModel */
+ public StandaloneProfileManager(PropertyJListModel listModel) {
+ mListModel = listModel;
+ }
+
+ public void createProfile(String aName, String aUrl) throws SPIException{
+
+ mProfileProvider = new StandaloneProfileProviderImpl( aUrl );
+ mProfileProvider.open();
+
+ ProfileRepository repos = mProfileProvider.getProfileRepository( aName );
+ mProfile = (StandaloneProfile)((StandaloneProfileRepositoryImpl)repos).createTheProfile( aName, Applicability.USER, 1);
+
+ StandalonePolicyManager mgr = new StandalonePolicyManager(mProfileProvider);
+
+ if( mProfile != null){
+ mManagerHelper = new StandalonePolicyManagerHelper(mgr, mProfile);
+ mProfileFile = new File( aUrl + File.separator + aName );
+ }
+ }
+
+
+ public void openProfile(String aName, String aUrl, PackageManager aPackageManager,
+ LocaleManager aLocaleManager, JTree aTree) throws SPIException{
+
+ mProfileProvider = new StandaloneProfileProviderImpl( aUrl );
+
+ ProfileRepository repos = mProfileProvider.getProfileRepository( aName );
+ mProfile = (StandaloneProfile)((StandaloneProfileRepositoryImpl)repos).getProfile(aName);
+
+ StandalonePolicyManager mgr = new StandalonePolicyManager(mProfileProvider);
+
+ if( mProfile != null){
+ mManagerHelper = new StandalonePolicyManagerHelper(mgr, mProfile);
+
+ HashMap aProperties = mManagerHelper.getAllDefinedProperties(mProfile);
+
+ loadProperties(aProperties, aPackageManager, aLocaleManager, aTree);
+
+ mProfileFile = new File( aUrl + File.separator + aName );
+ }
+ }
+
+
+ private void loadProperties(HashMap aProperties, PackageManager aPackageManager,
+ LocaleManager aLocaleManager, JTree aTree) throws SPIException{
+
+ if( aProperties != null ){
+ ArrayList list = new ArrayList();
+ HashMap templateHash = new HashMap();
+
+ Set set = aProperties.keySet();
+ Iterator it = set.iterator();
+ while(it.hasNext()){
+ String key = (String)it.next();
+ TemplateProperty property = aPackageManager.lookupProperty( key );
+
+ // Chop of the last bit of path and check again,
+ // maybe its a 'Set'.
+ String setName = "";
+ Template template = null;
+ if( property == null ){
+ String propName = key.substring( key.lastIndexOf("/") );
+ String path = "./$queriedId" + propName;
+ property = aPackageManager.lookupProperty( path );
+ if(property != null ){
+ setName = key.substring(0, key.length()-propName.length());
+ setName = setName.substring( setName.lastIndexOf("/") + 1 );
+
+ template = aPackageManager.getTemplateByProperty(path);
+ if( template != null ){
+ templateHash.put( template.getName(), template );
+ }
+ }
+ }
+
+ if( property != null ){
+ ReadWritePropertyImpl prop = (ReadWritePropertyImpl)aProperties.get(key);
+ PropertyComponentDummy propComp = new PropertyComponentDummy( key, prop);
+ propComp.cloneTemplateProperty( property );
+ propComp.setPath( setName + ";" + property.getPath() );
+ propComp.setResourceIdPath( setName + ";" + property.getResourceIdPath() );
+ propComp.setDataPath( key );
+ propComp.setProfileModel( this );
+ propComp.setLocaleManager( aLocaleManager );
+ propComp.setTemplateProperty( property );
+ list.add( propComp );
+
+ template = aPackageManager.getTemplateByProperty(key);
+ if( template != null ){
+ templateHash.put( template.getName(), template );
+ }
+
+ deleteExistingProperty(key);
+
+ System.out.println("Loading Property: " + key);
+ }else{
+ System.out.println("Could not load Property: " + key + ", is its package loaded?");
+ }
+ }
+ if( list.size() > 0 ){
+ mListModel.addAll( list );
+ }
+ //
+ // Force a redraw of
+ Collection c = templateHash.values();
+ Iterator tempIt = c.iterator();
+ while( tempIt.hasNext() ){
+ aPackageManager.getTemplatePanel( (Template)tempIt.next(), "en", aTree);
+ }
+ }// if
+ }
+
+
+ private void deleteExistingProperty(String dataPath){
+ PropertyComponent propComp = mListModel.existsByDataPath(dataPath);
+ if( propComp != null ){
+ System.out.println("Deleting Existing Property: " + dataPath);
+ mListModel.removeItem( propComp );
+ }
+ }
+
+
+ public void setDisplayName(String name){
+ if( mProfile != null ){
+ try {
+ mProfile.setDisplayName(name);
+ } catch (SPIException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ public String getDisplayName(){
+ if( mProfile != null ){
+ return mProfile.getDisplayName();
+ }else{
+ return "";
+ }
+ }
+
+
+ public void setComment(String comment){
+ if( mProfile != null ){
+ try {
+ mProfile.setComment(comment);
+ } catch (SPIException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+
+ public String getComment(){
+ String comment = "";
+ if( mProfile != null ){
+ try {
+ comment = mProfile.getComment();
+ } catch (SPIException ex) {
+ System.err.println("Could not get comment!");
+ comment = "";
+ }
+ }else {
+ comment = "";
+ }
+
+ return comment;
+ }
+
+
+ public void setAuthor(String author){
+ if(mProfile != null ){
+ try {
+ mProfile.setAuthor(author);
+ } catch (SPIException ex) {
+ System.err.println("Could not set Author to '" + author + "'!");
+ }
+ }
+ }
+
+
+ public String getAuthor(){
+ String author = "";
+ if(mProfile != null){
+ try {
+ author = mProfile.getAuthor();
+ } catch (SPIException ex) {
+ System.err.println("Could not get author!");
+ }
+ }
+
+ return author;
+ }
+
+
+ public void setApplicability(Applicability applicability){
+ if(mProfile != null){
+ try {
+ mProfile.setApplicability(applicability);
+ } catch (SPIException ex) {
+ System.err.println("Could not set Applicability!");
+ }
+ }
+ }
+
+
+ public Applicability getApplicability(){
+ Applicability applicability = Applicability.USER;
+
+ if(mProfile != null){
+ applicability = mProfile.getApplicability();
+ }
+
+ return applicability;
+ }
+
+
+ public void setPriority(int priority){
+ if(mProfile != null){
+ try {
+ mProfile.setPriority(priority);
+ } catch (SPIException ex) {
+ System.err.println("Could not set Priority!");
+ }
+ }
+ }
+
+
+ public int getPriority(){
+ int priority = 1;
+ if(mProfile != null){
+ priority = mProfile.getPriority();
+ }
+
+ return priority;
+ }
+
+
+ public void destroyProfile() throws SPIException{
+ if( mManagerHelper != null ){
+ mManagerHelper.resetAllChanges();
+ mManagerHelper = null;
+ }
+ mProfileProvider = null;
+ mProfile = null;
+ mProfileFile = null;
+ }
+
+
+ public boolean exists(){
+ return mManagerHelper != null;
+ }
+
+ public File getProfileFile(){
+ return mProfileFile;
+ }
+
+
+ public void createProperty(PropertyComponent aComponent){
+
+ if( mManagerHelper != null ){
+ try {
+ String path = aComponent.getDataPath();
+
+ Property prop = null;
+ if(aComponent.isSetProperty()){
+ prop = mManagerHelper.createReplaceProperty(path);
+ }else{
+ prop = mManagerHelper.createProperty(path);
+ }
+
+
+ DataType dataType = DataType.getDataType( aComponent.getDataType() );
+ String oldValue = aComponent.getValue();
+ String newValue = oldValue;
+
+ if( dataType == DataType.BOOLEAN && oldValue.startsWith( "Enabled" ) ){
+ newValue = "true";
+ }else if ( dataType == DataType.BOOLEAN && oldValue.startsWith( "Disabled" ) ){
+ newValue = "false";
+ }else if( dataType == DataType.STRING_LIST ){
+ prop.setSeparator( aComponent.getSeperator() );
+ }
+
+ prop.put( newValue, dataType );
+ System.out.println("SAVING PROPERTY: " + aComponent.getDataPath() );
+ } catch (SPIException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ }//end createProperty()
+
+ public void removeProperty(PropertyComponent aComponent){
+ if( mManagerHelper != null ){
+ try {
+ mManagerHelper.removeProperty( aComponent.getDataPath() );
+ } catch (SPIException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+
+
+ public void writeChanges(){
+ if(mManagerHelper != null ){
+ try {
+ mManagerHelper.flushAllChanges();
+ } catch (SPIException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+
+
+ public PropertyJListModel getListModel(){
+ return mListModel;
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileProviderImpl.java b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileProviderImpl.java
new file mode 100644
index 0000000..fa1da03
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileProviderImpl.java
@@ -0,0 +1,329 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.spi;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.sun.apoc.spi.IllegalReadException;
+import com.sun.apoc.spi.OpenConnectionException;
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.entities.Entity;
+import com.sun.apoc.spi.environment.EnvironmentConstants;
+import com.sun.apoc.spi.environment.InvalidParameterException;
+import com.sun.apoc.spi.environment.MissingParameterException;
+import com.sun.apoc.spi.file.entities.FileEntity;
+import com.sun.apoc.spi.ldap.entities.LdapEntity;
+import com.sun.apoc.spi.profiles.Applicability;
+import com.sun.apoc.spi.profiles.Profile;
+import com.sun.apoc.spi.profiles.ProfileComparatorProvider;
+import com.sun.apoc.spi.profiles.ProfileProvider;
+import com.sun.apoc.spi.profiles.ProfileRepository;
+
+/**
+ *
+ * @author cs202741
+ */
+public class StandaloneProfileProviderImpl implements ProfileProvider, ProfileComparatorProvider
+{
+ private static final String DEFAULT_REP_CONTAINER = "";
+
+ private boolean mRemoteRepository;
+ private URL mLocation;
+
+ public StandaloneProfileProviderImpl(String aUrl) throws SPIException
+ {
+ if ( (aUrl == null) || (aUrl.length() == 0)) {
+ throw new MissingParameterException("domain "+EnvironmentConstants.URL_KEY);
+ }
+ StringBuffer location;
+ location = new StringBuffer(aUrl);
+ if ( location.charAt(location.length() - 1) != '/' ) {
+ location.append('/');
+ }
+ // if (!aPolicySource.getEnvironment().containsKey(EnvironmentConstants.PROFILE_PREFIX+EnvironmentConstants.URL_KEY)) {
+ if(!(location.toString().endsWith(DEFAULT_REP_CONTAINER + "/"))) {
+ location.append(DEFAULT_REP_CONTAINER).append('/');
+ }
+
+ try {
+ mLocation = new URL( location.toString() );
+ } catch ( MalformedURLException e ) {
+ throw new InvalidParameterException(
+ "domain "+EnvironmentConstants.URL_KEY,
+ location.toString());
+ }
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.apoc.spi.profiles.ProfileProvider#getDefaultProfileRepository()
+ */
+ public ProfileRepository getDefaultProfileRepository() throws SPIException
+ {
+ return getProfileRepository(StandaloneProfileRepositoryImpl.DEFAULT_ID);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.apoc.spi.profiles.ProfileProvider#getProfileRepository(java.lang.String)
+ */
+ public ProfileRepository getProfileRepository(String aId) throws SPIException
+ {
+ ProfileRepository repository = null;
+ URL profRepositoryURL;
+
+ try {
+ profRepositoryURL = new URL(mLocation, aId );
+ } catch ( MalformedURLException e ) {
+ throw new IllegalReadException(
+ IllegalReadException.FILE_READ_KEY, e);
+ }
+
+ repository = new StandaloneProfileRepositoryImpl(aId, profRepositoryURL );
+
+ return repository;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.apoc.spi.profiles.ProfileProvider#getProfile(java.lang.String)
+ */
+ public Profile getProfile(String aId) throws SPIException
+ {
+ // The Repository id in with a profile is stored is part of the profile
+ // id.
+ Profile profile = null;
+ String[] ids;
+ ids = aId.split("-");
+
+ ProfileRepository repository = getProfileRepository(ids[0]);
+
+ profile = repository.getProfile(aId);
+
+ return profile;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.apoc.spi.profiles.ProfileProvider#open()
+ */
+ public void open() throws SPIException
+ {
+ File file;
+ // checks if the repository exists
+ if ( mLocation.getProtocol().equals(EnvironmentConstants.FILE_URL_PROTOCOL) ) {
+ mRemoteRepository = false;
+ try {
+ file = new File( new URI(mLocation.toString()));
+ if ( !file.exists() ) {
+ throw new IllegalReadException(IllegalReadException.FILE_NAME_READ_KEY, file.getAbsolutePath());
+ } else if ( !file.isDirectory() ) {
+ throw new InvalidParameterException(
+ "profile "+EnvironmentConstants.URL_KEY,
+ mLocation.toString());
+ }
+ } catch ( URISyntaxException e ) {
+ // Should not happend
+ throw new InvalidParameterException(
+ "profile "+EnvironmentConstants.URL_KEY,
+ mLocation.toString());
+ }
+ } else {
+ mRemoteRepository = true;
+ try {
+ mLocation.openStream();
+ } catch (IOException e) {
+ // could not connect to the repository
+ throw new OpenConnectionException(
+ mLocation.toString(), e);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.apoc.spi.profiles.ProfileProvider#close()
+ */
+ public void close() throws SPIException
+ {
+ // Nothing to do
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileProvider#getAllProfiles()
+ */
+ public Iterator getAllProfiles() throws SPIException {
+ ProfileRepository repository;
+ Iterator profFromRep;
+ List profiles;
+ String id;
+ File file;
+
+ if ( mRemoteRepository ) {
+ // Operation not allowed in a remote repository
+ throw new UnsupportedOperationException();
+ }
+
+ profiles = new LinkedList();
+ try {
+ File profileReps[];
+ file = new File( new URI(mLocation.toString()));
+ profileReps = file.listFiles();
+ // Get profiles from each profile repository
+ for ( int i = 0; i < profileReps.length; i++ ) {
+ if ( profileReps[i].isDirectory() ) {
+ id = getRepIdFromFile( profileReps[i] );
+ if ( id != null ) {
+ repository = getProfileRepository( id );
+ //profFromRep = repository.getProfiles(Applicability.getApplicability(mPolicySource.getName()));
+ profFromRep = repository.getProfiles( Applicability.HOST );
+ addProfiles( profiles, profFromRep );
+ }
+ }
+ }
+ } catch ( URISyntaxException e ) {
+ throw new IllegalReadException(
+ IllegalReadException.FILE_READ_KEY, e);
+ }
+
+ return profiles.iterator();
+ }
+
+ public Iterator getAllProfiles(Entity startingEntity) throws SPIException {
+ List profiles = new LinkedList();;
+
+ if ( mRemoteRepository ) {
+ // Operation not allowed in a remote repository
+ throw new UnsupportedOperationException();
+ }
+
+ profiles = getAllProfilesInSubEntity(startingEntity);
+
+ return profiles.iterator();
+ }
+
+ private List getAllProfilesInSubEntity (Entity entity) throws SPIException {
+ List profiles = new LinkedList();
+ ProfileRepository repository;
+ Iterator profFromRep;
+ String id;
+ try {
+ File profileReps[];
+ File file = new File( new URI(mLocation.toString()));
+ profileReps = file.listFiles();
+ // Get profiles from each profile repository
+ for ( int i = 0; i < profileReps.length; i++ ) {
+ if ( profileReps[i].isDirectory() ) {
+ id = getRepIdFromFile( profileReps[i] );
+ if (( id != null ) && (isRepIdInSubEntity(id, entity))) {
+ repository = getProfileRepository( id );
+ //profFromRep = repository.getProfiles(Applicability.getApplicability(mPolicySource.getName()));
+ profFromRep = repository.getProfiles( Applicability.HOST );
+ addProfiles( profiles, profFromRep );
+ }
+ }
+ }
+ } catch ( URISyntaxException e ) {
+ throw new IllegalReadException(
+ IllegalReadException.FILE_READ_KEY, e);
+ }
+ return profiles;
+ }
+
+ public Comparator getProfileComparator() {
+ return new StandaloneProfileComparator();
+ }
+
+ private static void addProfiles(List aProfileList, Iterator aProfilesToAdd ) {
+
+ while ( aProfilesToAdd.hasNext() ) {
+ aProfileList.add((Profile)aProfilesToAdd.next() );
+ }
+ }
+
+ private static String getRepIdFromFile( File aFile ) throws SPIException {
+ String repId;
+ String id = null;
+
+ repId = aFile.getName();
+ if ( repId.startsWith(StandaloneProfileRepositoryImpl.PREFIX ) ) {
+ try {
+ id = URLDecoder.decode(repId.substring(
+ StandaloneProfileRepositoryImpl.PREFIX.length() ),
+ System.getProperty("file.encoding"));
+ } catch (UnsupportedEncodingException e) {
+ // Shouldn't happend
+ throw new IllegalReadException(
+ IllegalReadException.FILE_READ_KEY, e);
+ }
+ }
+
+ return id;
+ }
+
+ private static boolean isRepIdInSubEntity (String repositoryId, Entity entity)
+ throws SPIException {
+ boolean result = false;
+ String entityRepositoryId = entity.getProfileRepository().getId();
+ if (entity instanceof LdapEntity) {
+ result = repositoryId.endsWith(entityRepositoryId);
+ }
+ else if (entity instanceof FileEntity) {
+ result = repositoryId.startsWith(entityRepositoryId+FileEntity.ENTITY_SEPARATOR)
+ || repositoryId.equals(entityRepositoryId);
+ }
+ return result;
+ }
+} \ No newline at end of file
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileProviderImplTest.java b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileProviderImplTest.java
new file mode 100644
index 0000000..236d82c
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileProviderImplTest.java
@@ -0,0 +1,89 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.spi;
+
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.cfgtree.property.Property;
+import com.sun.apoc.spi.profiles.Profile;
+import com.sun.apoc.spi.profiles.ProfileRepository;
+
+/**
+ *
+ * @author cs202741
+ */
+public class StandaloneProfileProviderImplTest {
+
+ static StandaloneProfileProviderImpl mProfileProvider;
+ static String mUrl = "file:///home/cs202741/Documents/java/TemplateRenderer";
+
+ /** Creates a new instance of StandaloneProfileProviderImplTest */
+ public StandaloneProfileProviderImplTest() {
+ }
+
+ public static void main(String[] args){
+
+
+ try{
+ mProfileProvider = new StandaloneProfileProviderImpl( mUrl );
+ mProfileProvider.open();
+
+ ProfileRepository repos = mProfileProvider.getProfileRepository("MyProfile");
+ Profile profile = ((StandaloneProfileRepositoryImpl)repos).createTheProfile( "Profile1", null, 1);
+
+ StandalonePolicyManager mgr = new StandalonePolicyManager(mProfileProvider);
+
+ //Profile profile = mgr.getProfile(StandaloneProfileRepositoryImpl.DEFAULT_ID);
+
+ if( profile != null){
+ StandalonePolicyManagerHelper mgrHelper = new StandalonePolicyManagerHelper(mgr, profile);
+ Property prop = mgrHelper.createProperty("org.openoffice.Office.Draw/Layout/Display/Contour");
+ prop.putString("Test String1");
+ prop = mgrHelper.createProperty("org.openoffice.Office.Draw/Layout/Display/Contour2");
+
+ String[] strings = { "christian", "peter" };
+ prop.putStringList( strings );
+ mgrHelper.flushAllChanges();
+ }else
+ System.out.println("profile=null");
+
+ }catch(SPIException e){ System.out.println( e ); }
+
+
+
+ }
+
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileRepositoryImpl.java b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileRepositoryImpl.java
new file mode 100644
index 0000000..ec3e59f
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/StandaloneProfileRepositoryImpl.java
@@ -0,0 +1,347 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.spi;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.TreeSet;
+
+import com.sun.apoc.spi.IllegalReadException;
+import com.sun.apoc.spi.IllegalWriteException;
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.entities.Entity;
+import com.sun.apoc.spi.profiles.Applicability;
+import com.sun.apoc.spi.profiles.Profile;
+import com.sun.apoc.spi.profiles.ProfileRepositoryImpl;
+
+/**
+ *
+ * @author cs202741
+ */
+public class StandaloneProfileRepositoryImpl extends ProfileRepositoryImpl {
+
+ public final static String PREFIX = "PROFILE_REPOSITORY_";
+ public final static String DEFAULT_ID = "default";
+
+ private File mFile;
+ boolean mReadOnly;
+ boolean mRemote;
+ URL mRootLocation;
+
+ /** Creates a new instance of StandaloneProfileRepositoryImpl */
+ public StandaloneProfileRepositoryImpl(String aId, URL aRootPath ) throws SPIException {
+ mId = aId;
+ mRootLocation = aRootPath;
+
+ mReadOnly = true;
+ if ( !aRootPath.getProtocol().equals("file") ) {
+ mRemote = true;
+ } else {
+ mRemote = false;
+ try {
+ mFile = new File( new URI( mRootLocation.toString() ) );
+ } catch (URISyntaxException e) {
+ throw new IllegalReadException(
+ IllegalReadException.FILE_NAME_READ_KEY,
+ mRootLocation.toString(), e);
+ }
+
+ mReadOnly = isRepositoryReadOnly();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepositoryImpl#findProfile(java.lang.String, com.sun.apoc.spi.profiles.Applicability)
+ */
+ public Profile findProfile( String aDisplayName ) throws SPIException
+ {
+ List profileList;
+ Profile profile;
+ Profile actual;
+ Iterator it;
+
+ if ( mRemote ) {
+ throw new UnsupportedOperationException();
+ }
+ profileList = loadAllProfiles();
+ profile = null;
+ it = profileList.iterator();
+ while ( it.hasNext() ) {
+ actual = (Profile) it.next();
+ if ( actual.getDisplayName().equals(aDisplayName) ) {
+ profile = actual;
+ }
+ }
+
+ return profile;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepository#getProfilePriorities(com.sun.apoc.spi.profiles.Applicability)
+ */
+ public Iterator getProfilePriorities(Applicability aApplicability)
+ throws SPIException
+ {
+ List selectedProfileList;
+ List profileList;
+ Profile profile;
+ Iterator it;
+
+ profile = null;
+ if ( mRemote ) {
+ throw new UnsupportedOperationException();
+ }
+ profileList = loadAllProfiles();
+ selectedProfileList = new LinkedList();
+ it = profileList.iterator();
+ while ( it.hasNext() )
+ {
+ profile = (Profile)it.next();
+ if ( profile.getApplicability() == aApplicability )
+ {
+ selectedProfileList.add( profile );
+ }
+ }
+
+ return selectedProfileList.iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepository#createProfile(java.lang.String, int, com.sun.apoc.spi.profiles.Applicability)
+ */
+ protected Profile createTheProfile(String aDisplayName, Applicability aApplicability, int aPriority) throws SPIException {
+ Profile profile;
+
+ if ( mReadOnly ) {
+ throw new IllegalWriteException();
+ }
+
+ profile = StandaloneProfile.createNewProfile( this, aDisplayName, aApplicability, aPriority );
+ return profile;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepository#destroyProfile(com.sun.apoc.spi.profiles.Profile)
+ */
+ public void deleteProfile(Profile aProfile) throws SPIException
+ {
+ String profileId;
+ profileId = aProfile.getId();
+
+ if ( mReadOnly ) {
+ throw new IllegalWriteException();
+ }
+
+ try {
+ URI fileURI;
+ File file;
+ // get the FileName
+ fileURI = new URI( StandaloneProfile.getProfileURL(profileId, this).toString() );
+
+ file = new File( fileURI.getPath() );
+ if ( !file.delete() )
+ {
+ // Can not delete the profile
+ throw new IllegalWriteException(
+ IllegalWriteException.FILE_WRITE_KEY);
+ }
+ } catch (URISyntaxException e) {
+ throw new IllegalWriteException(
+ IllegalWriteException.FILE_WRITE_KEY, e);
+ }
+
+ aProfile = null;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepository#getProfile(java.lang.String)
+ */
+ public Profile getProfile(String aId) throws SPIException
+ {
+ return StandaloneProfile.loadProfile(aId, this, mPolicySource);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepository#getProfiles(com.sun.apoc.spi.profiles.Applicability)
+ */
+ protected TreeSet getTheProfiles(Applicability aApplicability)
+ throws SPIException
+ {
+ Iterator it;
+ TreeSet profileApplicableList;
+ List profileList;
+ Profile profile;
+
+
+ if ( mRemote ) {
+ throw new UnsupportedOperationException();
+ }
+ profileApplicableList = new TreeSet(new StandaloneProfileComparator());
+ profileList = loadAllProfiles();
+ it = profileList.iterator();
+ while ( it.hasNext() )
+ {
+ profile = (Profile) it.next();
+ if ( aApplicability.equals( Applicability.ALL ) ) {
+ profileApplicableList.add( profile );
+ } else if ( profile.getApplicability().equals( aApplicability ) ) {
+ profileApplicableList.add( profile );
+ }
+ }
+
+ return profileApplicableList;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepository#getId()
+ */
+ public String getId()
+ {
+ return mId;
+ }
+
+ private List readProfileList() throws SPIException {
+ List profileIdList;
+ String[] fileList;
+ String id;
+ int end;
+
+ profileIdList = new LinkedList();
+
+ // Read the contents file and add the profile URLs to the profile list
+ String profileName;
+ fileList = mFile.list();
+ for ( int i = 0 ; i < fileList.length; i++) {
+ profileName = fileList[i];
+ // get the ID of the profile
+ end = profileName.lastIndexOf(".zip");
+ if ( end == -1 ) { continue; } // TODO log this
+ id = profileName.substring(0, end);
+ profileIdList.add( id );
+ }
+
+ return profileIdList;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepository#isReadOnly()
+ */
+ public boolean isReadOnly() throws SPIException
+ {
+ return mReadOnly;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.apoc.spi.profiles.ProfileRepository#getEntity()
+ */
+ public Entity getEntity() throws SPIException
+ {
+ Entity entity = mPolicySource.getEntityProvider().getEntity(mId);
+
+ return entity;
+ }
+
+ protected String getLocation()
+ {
+ return mRootLocation.toString();
+ }
+
+ protected boolean priorityExists( int aPriority ) throws SPIException {
+ Iterator profiles = getProfiles(Applicability.ALL );
+
+ while ( profiles.hasNext() ) {
+ if ( ( (Profile)profiles.next()).getPriority() == aPriority ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected void createStorage() {
+ if ( !mFile.exists() ) {
+ mFile.mkdirs();
+ }
+ }
+
+ private List loadAllProfiles() throws SPIException
+ {
+ List profileIdList;
+ List profilesList;
+ String profileId;
+ Profile profile;
+ Iterator it;
+ String id;
+
+ profilesList = new LinkedList();
+ if ( mFile.exists() ) {
+ // only read the profiles if the directory exists
+ profileIdList = readProfileList();
+ it = profileIdList.iterator();
+ while( it.hasNext() )
+ {
+ id = (String)it.next();
+ profileId = StandaloneProfile.createId( id, mId );
+ profile = getProfile( profileId );
+ profilesList.add( profile );
+ }
+ }
+ return profilesList;
+ }
+
+ private boolean isRepositoryReadOnly()
+ {
+ File parent;
+ parent = mFile;
+
+ do {
+ if (parent.exists() ) {
+ return !parent.canWrite();
+ }
+ } while ( (parent = parent.getParentFile() ) != null );
+
+ /* should not happend */
+ return false;
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/spi/ZipProfileReadWrite.java b/src/com/sun/apoc/tools/profileeditor/spi/ZipProfileReadWrite.java
new file mode 100644
index 0000000..c547d45
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/spi/ZipProfileReadWrite.java
@@ -0,0 +1,287 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+
+package com.sun.apoc.tools.profileeditor.spi;
+
+/**
+ *
+ * @author cs202741
+ */
+
+import com.sun.apoc.spi.profiles.Profile;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import com.sun.apoc.spi.SPIException;
+import com.sun.apoc.spi.policies.Policy;
+
+
+/**
+ * Implementation of the Profile read/write in ZIP file format.
+ *
+ * Policies are stored as xml files where each file represents one single
+ * component. The content of each file is the XML-bob of the policy. In
+ * addition, the first entry of each zip file corresponds to the meta
+ * configuration data such as display name, applicability, etc.
+ *
+ * In APOC 1.x versions the format of the zip file was slightly different. Here
+ * policies are stored in a tree structure where each item of the
+ * component name is a subdirectory and the policy itself is stored
+ * in a file named after the last item. The whole tree is then zipped
+ * into a single file. The tree structure is identical to the one found
+ * in the registry/data repositories in an office installation.
+ *
+ * As an example, if the profile contains org.openoffice.Inet and
+ * org.openoffice.Office.Common, the ZIP file will contain two entries
+ * (old format):
+ * - org/openoffice/Inet.xcu (containing the policy data) and
+ * - org/openoffice/Office/Common.xcu (containing the policy data)
+ *
+ * Or using the new format it will contain:
+ * - META-INF/general.properties (containing the meta configuration data)
+ * - org.openoffice.Inet.xml (containing the policy data) and
+ * - org.openoffice.Office.Common.xml (containing the policy data)
+ */
+public class ZipProfileReadWrite {
+ /**
+ * The current product version
+ */
+ public static final String PRODUCT_VERSION = "2.0";
+
+ /**
+ * Constants for accessing/storing the meta configuration data
+ */
+ public static final String APOC_VERSION = "ApocVersion";
+ public static final String DISPLAY_NAME = "DisplayName";
+ public static final String COMMENT = "Comment";
+ public static final String APPLICABILITY = "Applicability";
+ public static final String PRIORITY = "Priority";
+ public static final String AUTHOR = "Author";
+ public static final String LAST_MODIFIED = "LastModified";
+
+ /**
+ * The zip file entry for storing the meta configuration data
+ */
+ public static final String META_INF_ENTRY = "META-INF/general.properties";
+
+ /**
+ * Suffix appended to entries holding policy data.
+ */
+ public static final String ENTRY_SUFFIX = ".xml";
+
+ /**
+ * Encoding of the policy data in the entries.
+ */
+ public static final String ENTRY_ENCODING = "UTF-8";
+
+ /**
+ * Component items separator as a character.
+ */
+ public static final char COMPONENT_SEPARATOR = '.';
+
+ /**
+ * Entry components separator.
+ */
+ public static final char ENTRY_SEPARATOR = '/';
+
+ /**
+ * Old suffix appended to entries holding policy data.
+ */
+ public static final String OLD_ENTRY_SUFFIX = ".xcu";
+
+
+
+ /**
+ * Writes the meta configuration data of a given profile to a stream.
+ *
+ * @param aProfile profile identifier
+ * @param aOutput stream for exported data
+ * @throws SPIException if an error occurs.
+ */
+ public static void writeMetaData(Profile aProfile,
+ ZipOutputStream aOutput) throws IOException, SPIException {
+ // collect all the meta data information
+ Properties metaData = new Properties();
+ metaData.put(APOC_VERSION, PRODUCT_VERSION);
+ metaData.put(DISPLAY_NAME, aProfile.getDisplayName());
+ metaData.put(COMMENT, aProfile.getComment());
+ metaData.put(AUTHOR, aProfile.getAuthor());
+ metaData.put(PRIORITY, new Integer(aProfile.getPriority()).toString());
+ metaData.put(APPLICABILITY, aProfile.getApplicability().getStringValue());
+ metaData.put(LAST_MODIFIED, Long.toString(aProfile.getLastModified()));
+ // create new zip entry
+ ZipEntry entry = new ZipEntry(META_INF_ENTRY);
+ aOutput.putNextEntry(entry);
+
+ // store the meta data information
+ metaData.store(aOutput, null);
+ aOutput.closeEntry();
+ }
+
+ /**
+ * Actual export of policies from the specified profile.
+ * The policy names are transformed into ZIP entry names and the
+ * policy data becomes the content of the entry.
+ *
+ * @param aProfile profile identifier
+ * @param aOutput stream to export the data to
+ * @throws SPIException if an IO error occurs.
+ * @throws ProfileZipException if an error occurs
+ * @throws ProfileStreamException if an error occurs
+ */
+ public static void writePolicies(Profile aProfile, ZipOutputStream aOutput)
+ throws IOException, SPIException {
+ Iterator it = aProfile.getPolicies();
+ while (it.hasNext()) {
+ Policy policy = (Policy) it.next();
+ StringBuffer buffer = new StringBuffer(policy.getId());
+ buffer.append(ENTRY_SUFFIX);
+
+ // create new zip entry for each policy
+ ZipEntry entry = new ZipEntry(buffer.toString());
+ entry.setTime(policy.getLastModified());
+ aOutput.putNextEntry(entry);
+
+ // and store the content of the policy
+ byte[] data = policy.getData().getBytes(ENTRY_ENCODING);
+ aOutput.write(data, 0, data.length);
+ aOutput.closeEntry();
+ }
+ }
+
+ /**
+ * Reads the meta configuration data from a stream.
+ *
+ * @param aInput stream for inported data
+ */
+ public static Properties readMetaData(ZipInputStream aInput)
+ throws IOException {
+ Properties metaData = null;
+ ZipEntry entry = aInput.getNextEntry();
+ if (entry != null) {
+ if (entry.getName().equals(META_INF_ENTRY)) {
+ metaData = new Properties();
+ metaData.load(aInput);
+ aInput.closeEntry();
+ }
+ }
+ return metaData;
+ }
+
+ /**
+ * Reads the policies from a stream.
+ *
+ * @param aInput stream for inported data
+ */
+ public static Iterator readPolicies(ZipInputStream aInput)
+ throws IOException {
+ ArrayList policies = new ArrayList();
+ ZipEntry entry = aInput.getNextEntry();
+ while (entry != null) {
+ // determine policy name
+ String name = entry.getName();
+ int pos = name.indexOf(ENTRY_SUFFIX);
+ if (pos > 0) {
+ name = name.substring(0, pos);
+
+ // retrieve policy data
+ byte[] buffer = new byte[1024] ;
+ StringBuffer data = new StringBuffer();
+ while (aInput.available() != 0) {
+ int bytesRead = aInput.read(buffer, 0, buffer.length);
+ if (bytesRead > 0) {
+ data.append(new String(buffer, 0, bytesRead, ENTRY_ENCODING));
+ }
+ }
+ Policy policy = new Policy(name, data.toString(), entry.getTime());
+ policies.add(policy);
+ }
+
+ aInput.closeEntry() ;
+ entry = aInput.getNextEntry() ;
+ }
+ return policies.iterator();
+ }
+
+
+ /**
+ * Actual import of policy data (old format) from a ZIP file.
+ *
+ * Note: in that case, the first ZipEntry has already been read
+ * before this method is called by importProfile
+ * (in readMetaConfigurationData) but it will always be a directory
+ * because every policy is stored in at least one-level deep directory
+ * and directories are skipped by this method so no useful data is lost.
+ *
+ * @param aInput stream containing the zipped data
+ * @throws SPIException if an IO error occurs.
+ * @throws ProfileZipException if an error occurs
+ * @throws ProfileStreamException if an error occurs
+ */
+ public static Iterator readOldPoliciesFormat(ZipInputStream aInput)
+ throws IOException {
+ ArrayList policies = new ArrayList();
+ ZipEntry entry = aInput.getNextEntry() ;
+ while (entry != null) {
+ if (!entry.isDirectory()) {
+ String name = entry.getName() ;
+ int usefulSize = name.length() - OLD_ENTRY_SUFFIX.length();
+ if (!(usefulSize <= 0 ||
+ !name.substring(usefulSize).equals(OLD_ENTRY_SUFFIX))) {
+ name = name.substring(0, usefulSize).replace(ENTRY_SEPARATOR,
+ COMPONENT_SEPARATOR);
+ byte [] buffer = new byte[1024] ;
+ StringBuffer data = new StringBuffer();
+ while (aInput.available() != 0) {
+ int bytesRead = aInput.read(buffer, 0, buffer.length);
+ if (bytesRead > 0) {
+ data.append(new String(buffer, 0, bytesRead, ENTRY_ENCODING));
+ }
+ }
+ Policy policy = new Policy(name, data.toString());
+ policies.add(policy);
+ }
+ }
+ aInput.closeEntry() ;
+ entry = aInput.getNextEntry() ;
+ }
+ return policies.iterator();
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/LocalizedElement.java b/src/com/sun/apoc/tools/profileeditor/templates/LocalizedElement.java
new file mode 100644
index 0000000..da60bb3
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/LocalizedElement.java
@@ -0,0 +1,44 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+public interface LocalizedElement {
+
+ String getDefaultName();
+
+ String getResourceBundle();
+
+ String getResourceId();
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/NarratedElement.java b/src/com/sun/apoc/tools/profileeditor/templates/NarratedElement.java
new file mode 100644
index 0000000..03a7713
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/NarratedElement.java
@@ -0,0 +1,42 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+public interface NarratedElement {
+
+ public String getDescriptionId();
+
+ public void setDescriptionId(String resourceId);
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplateActionHandler.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplateActionHandler.java
new file mode 100644
index 0000000..e5ed9c7
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplateActionHandler.java
@@ -0,0 +1,79 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+public class TemplateActionHandler {
+
+ private String m_name = null;
+ private String m_classname = null;
+ private String m_packageDir = null;
+
+ public TemplateActionHandler(String name, String classname, String packageDir) {
+ m_name = name ;
+ m_classname = classname ;
+ m_packageDir = packageDir ;
+ }
+
+ public String getName() {
+ return m_name;
+ }
+
+ public String getClassName() {
+ return m_classname;
+ }
+
+ public String getPackageDir() {
+ return m_packageDir;
+ }
+
+ public Object getClassInstance() {
+ Object object = null;
+// try {
+// ActionHandlerClassLoader loader = new ActionHandlerClassLoader();
+// loader.setPackageDir(m_packageDir);
+// Class classDefinition = loader.findClass(m_classname);
+// object = classDefinition.newInstance();
+// } catch (ClassNotFoundException e) {
+// System.out.println("getClassInstance(): " + e);
+// } catch (InstantiationException e) {
+// System.out.println("getClassInstance(): " + e);
+// } catch (IllegalAccessException e) {
+// System.out.println("getClassInstance(): " + e);
+// }
+ return object;
+ }
+}
+
+
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplateCategory.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplateCategory.java
new file mode 100644
index 0000000..2e0939c
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplateCategory.java
@@ -0,0 +1,148 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+import java.util.HashMap;
+
+public class TemplateCategory extends TemplateElement
+ implements NarratedElement {
+ protected boolean isLeaf;
+
+ private HashMap m_subCategories = null;
+ private String m_descriptionId = null;
+ private TemplateCategory m_parent = null;
+ private int m_numSubCategories;
+
+
+ public TemplateCategory(String defaultName, String scope, String resourceId,
+ String resourceBundle, TemplateCategory parent) {
+
+ super(defaultName, scope, resourceId, resourceBundle);
+ m_parent = parent;
+ m_numSubCategories = 0;
+ isLeaf = false;
+ }
+
+
+ public boolean hasSubCategories() {
+ return m_subCategories != null;
+ }
+
+
+ public HashMap getSubCategories() {
+ return m_subCategories;
+ }
+
+
+ public TemplateCategory getSubCategory(String name) {
+ if (m_subCategories != null) {
+ return (TemplateCategory) m_subCategories.get(name);
+ } else {
+ return null;
+ }
+ }
+
+
+ void addSubCategory(TemplateCategory category) {
+ if (m_subCategories == null) {
+ m_subCategories = new HashMap();
+ }
+ if (!m_subCategories.containsKey(category.getDefaultName())) {
+ m_subCategories.put(category.getDefaultName(), category);
+ m_numSubCategories++;
+ }
+ }
+
+
+ public String getDescriptionId() {
+ return m_descriptionId;
+ }
+
+
+ public void setDescriptionId(String resourceId) {
+ m_descriptionId = resourceId;
+ }
+
+
+ public TemplateCategory getParent() {
+ return m_parent;
+ }
+
+ public int getSize(){
+ return m_numSubCategories;
+ }
+
+
+ public String[] getKeys(){
+ Object[] tmpKeys = m_subCategories.keySet().toArray();
+ String[] keys = new String[tmpKeys.length];
+
+ for(int i = 0; i < tmpKeys.length; i++)
+ keys[i] = (String)tmpKeys[i];
+
+ return keys;
+ }
+
+
+ public String getPath() {
+ StringBuffer path = new StringBuffer();
+ for (TemplateCategory category = this; category != null; category = category.getParent()) {
+ path.append( category.getDefaultName() + ";" );
+ }
+ return path.toString();
+ }
+
+ public String getResourceIdPath() {
+ StringBuffer path = new StringBuffer();
+ for (TemplateCategory category = this; category != null; category = category.getParent()) {
+ path.append( category.getResourceId() + ";" );
+ }
+ return path.toString();
+ }
+
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(super.toString());
+ buffer.append(getDefaultName());
+ buffer.append(" (");
+ buffer.append(getResourceId());
+ buffer.append(", ");
+ buffer.append(getResourceBundle());
+ buffer.append(") ");
+ return buffer.toString();
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplateElement.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplateElement.java
new file mode 100644
index 0000000..85aafff
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplateElement.java
@@ -0,0 +1,124 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+public abstract class TemplateElement implements LocalizedElement {
+
+ public static final String GLOBAL = "global";
+ public static final String USER = "user";
+ public static final String HOST = "host";
+
+ public static final byte USER_SCOPE = 1;
+ public static final byte HOST_SCOPE = 2;
+ public static final byte GLOBAL_SCOPE = 3;
+
+ private String m_defaultName = null;
+ private String m_resourceBundle = null;
+ private String m_resourceId = null;
+ private byte m_scope = GLOBAL_SCOPE;
+
+
+ public TemplateElement(String defaultName, String scope, String resourceId,
+ String resourceBundle) {
+ m_defaultName = defaultName;
+ if (resourceId != null) {
+ m_resourceId = resourceId;
+ } else {
+ m_resourceId = defaultName;
+ }
+ m_resourceBundle = resourceBundle;
+ setScope(scope);
+ }
+
+
+ protected void setScope(String scope) {
+ if (scope != null) {
+ if (scope.indexOf(USER) != -1) {
+ m_scope = USER_SCOPE;
+ } else if (scope.indexOf(HOST) != -1) {
+ m_scope = HOST_SCOPE;
+ }
+ }
+ }
+
+
+ public final String getDefaultName() {
+ return m_defaultName;
+ }
+
+
+ public final String getResourceBundle() {
+ return m_resourceBundle;
+ }
+
+
+ public final String getResourceId() {
+ return m_resourceId;
+ }
+
+
+ public final boolean hasUserScope() {
+ return (m_scope & USER_SCOPE) != 0;
+ }
+
+
+ public final boolean hasHostScope() {
+ return (m_scope & HOST_SCOPE) != 0;
+ }
+
+
+ public final boolean hasGlobalScope() {
+ return (m_scope & GLOBAL_SCOPE) != 0;
+ }
+
+
+ public final boolean isInScope(byte scope) {
+ return (m_scope & scope) != 0;
+ }
+
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(super.toString());
+ buffer.append(" - ");
+ buffer.append(getDefaultName());
+ buffer.append(" (");
+ buffer.append(getResourceId());
+ buffer.append(", ");
+ buffer.append(getResourceBundle());
+ buffer.append(") ");
+ return buffer.toString();
+ }
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplatePage.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplatePage.java
new file mode 100644
index 0000000..98f5e58
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplatePage.java
@@ -0,0 +1,188 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+
+public class TemplatePage extends TemplateCategory {
+
+ private List m_sections = null;
+ private List m_xmlHandlers = null;
+ private List m_actionHandlers = null;
+ private HashMap m_index = null;
+ private HashMap m_xmlHandler_index = null;
+ private HashMap m_actionHandler_index = null;
+ private String m_dataPath = null;
+ private String m_helpFile = null;
+ private String m_packageName = null;
+
+
+ public TemplatePage(String defaultName, String scope, String resourceId,
+ String resourceBundle, TemplateCategory parent) {
+ super(defaultName, scope, resourceId, resourceBundle, parent);
+ isLeaf = true;
+ }
+
+ public TemplatePage(String defaultName, String scope, String resourceId,
+ String resourceBundle, String helpFile, TemplateCategory parent) {
+ super(defaultName, scope, resourceId, resourceBundle, parent);
+ m_helpFile = helpFile;
+ }
+
+ public TemplatePage(String defaultName, String scope, String resourceId,
+ String resourceBundle, String helpFile, TemplateCategory parent,
+ String templatePackage) {
+ super(defaultName, scope, resourceId, resourceBundle, parent);
+ m_helpFile = helpFile;
+ m_packageName = templatePackage;
+ }
+
+ public List getSections() {
+ return m_sections;
+ }
+
+
+ public TemplateSection getSection(int index) {
+ return (TemplateSection) m_sections.get(index);
+ }
+
+
+ public TemplateSection getSection(String name) {
+ return (TemplateSection) m_index.get(name);
+ }
+
+ public TemplateXMLHandler getXMLHandler(int index) {
+ return (TemplateXMLHandler) m_xmlHandlers.get(index);
+ }
+
+ public TemplateXMLHandler getXMLHandler(String name) {
+ return (TemplateXMLHandler) m_xmlHandler_index.get(name);
+ }
+
+ public TemplateActionHandler getActionHandler(int index) {
+ return (TemplateActionHandler) m_actionHandlers.get(index);
+ }
+
+ public TemplateActionHandler getActionHandler(String name) {
+ return (TemplateActionHandler) m_actionHandler_index.get(name);
+ }
+
+ public int getSectionIndex(String name) {
+ Iterator it = m_sections.iterator();
+ int result = 0;
+ while (it.hasNext()) {
+ TemplateSection section = (TemplateSection) it.next();
+ if (section.getDefaultName().equals(name)) {
+ return result;
+ }
+ result++;
+ }
+ return -1;
+ }
+
+
+ void addSection(TemplateSection section) {
+ if (m_sections == null) {
+ m_sections = new LinkedList();
+ m_index = new HashMap();
+ }
+ m_sections.add(section);
+ m_index.put(section.getDefaultName(), section);
+ }
+
+ public void addXMLHandler(TemplateXMLHandler handler) {
+ if (m_xmlHandlers == null) {
+ m_xmlHandlers = new LinkedList();
+ m_xmlHandler_index = new HashMap();
+ }
+ m_xmlHandlers.add(handler);
+ m_xmlHandler_index.put(handler.getName(), handler);
+ }
+
+ public void addActionHandler(TemplateActionHandler handler) {
+ if (m_actionHandlers == null) {
+ m_actionHandlers = new LinkedList();
+ m_actionHandler_index = new HashMap();
+ }
+ m_actionHandlers.add(handler);
+ m_actionHandler_index.put(handler.getName(), handler);
+ }
+
+ public String getDataPath() {
+ return m_dataPath;
+ }
+
+
+ public void setDataPath(String path) {
+ m_dataPath = path;
+ }
+
+ public String getHelpFile() {
+ return m_helpFile;
+ }
+
+
+ public String getTemplatePackageName() {
+ return m_packageName;
+ }
+
+
+ public boolean hasVisibleContent(byte scope) {
+ Iterator it = getSections().iterator();
+ while (it.hasNext()) {
+ TemplateSection section = (TemplateSection) it.next();
+ if (section.isInScope(scope)) {
+ if (section.hasVisibleContent(scope)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ public boolean getAllowsChildren(){
+ return false;
+ }
+
+}
+
+
+
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplateParser.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplateParser.java
new file mode 100644
index 0000000..dfd29e3
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplateParser.java
@@ -0,0 +1,650 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+
+import org.xml.sax.*;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+
+public class TemplateParser
+{
+ public boolean debug = false;
+
+
+ public static final String TEMPLATE_PATH_SEPARATOR = "/";
+ public static final String SET_PREFIX = "SET_";
+ public static final String SET_INDEX_SEPARATOR = "|";
+
+ public static final String DEFAULT_PACKAGE_DIR = "/packages";
+ public static final String DEFAULT_TEMPLATE_DIR = File.separator + "templates" + File.separator;
+
+ public static final String TEMPLATE_EXTENSION = ".xml";
+ public static final String JAR_EXTENSION = ".jar";
+ public static final String PROPERTIES_EXTENSION = ".properties";
+ public static final String ROOT_CATEGORY_NAME = "Policies";
+
+ private Writer out;
+ private String m_currentElement = null;
+ private File m_DTDLocation;
+ private TemplateCategory m_templateRoot = null;
+ private Locator m_locator = null;
+
+ private ArrayList mPropertyList = null;
+ private HashMap mSetList = null;
+
+
+ public TemplateParser(File template, File packageRoot, ArrayList aPropertyList) throws SAXParseException
+ {
+ m_DTDLocation = new File( packageRoot.getPath()
+ // + File.separator + ".."
+ + File.separator + "dtd"
+ + File.separator + "policytemplate.dtd" );
+
+ mSetList = new HashMap();
+ mPropertyList = aPropertyList;
+ parseTemplate(template);
+ }
+
+
+ private void parseTemplate(File template) throws SAXParseException
+ {
+ m_templateRoot = new TemplatePage(ROOT_CATEGORY_NAME, null,
+ "APOC.policies.root", null, null);
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(true);
+ try {
+ out = new OutputStreamWriter(System.out, "UTF8");
+
+ SAXParser saxParser = factory.newSAXParser();
+ saxParser.parse( template, new TemplateHandler(m_templateRoot, template.getName()) );
+ }catch( ClassCastException e){
+ String error = "XML ERROR in file: '" + m_locator.getSystemId() +
+ "', on LINE: " + m_locator.getLineNumber() +
+ "\n INFO: The element type \"" + m_currentElement +
+ "\" must be terminated by the matching end-tag \"</" + m_currentElement + ">\".\n";
+ throw new SAXParseException(error, m_locator);
+ }catch (SAXParseException spe) {
+ String error = "XML ERROR in file: '" + spe.getSystemId() +
+ "', on LINE: " + spe.getLineNumber() +
+ "\n INFO: " + spe.getMessage() + "\n";
+ throw new SAXParseException(error, m_locator);
+ } catch (SAXException sxe) {
+ Exception x = sxe;
+ if (sxe.getException() != null){
+ x = sxe.getException();
+ }
+ x.printStackTrace();
+
+ } catch (ParserConfigurationException pce) {
+ pce.printStackTrace();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }//end parseTemplate
+
+
+ public TemplateCategory getRootCategory(){
+ return m_templateRoot;
+ }
+
+ public HashMap getSetList(){
+ return mSetList;
+ }
+
+ public ArrayList getPropertyList(){
+ return mPropertyList;
+ }
+
+
+
+
+ class TemplateHandler extends DefaultHandler {
+
+ public static final String CATEGORY_TAG = "category";
+ public static final String PAGE_TAG = "page";
+ public static final String SECTION_TAG = "section";
+ public static final String SET_TAG = "set";
+ public static final String PROPERTY_TAG = "property";
+ public static final String RES_IMPORT_TAG = "resImport";
+ public static final String HELP_IMPORT_TAG = "helpImport";
+ public static final String INLINE_HELP_TAG = "inlineHelp";
+ public static final String ENUMERATION_TAG = "enumeration";
+ public static final String VALUE_TAG = "value";
+ public static final String VISUAL_TAG = "visual";
+ public static final String CHECKBOX_TAG = "checkBox";
+ public static final String CHOOSER_TAG = "chooser";
+ public static final String RES_ID_ATTR = "apt:resId";
+ public static final String LABEL_ATTR = "apt:label";
+ public static final String NAME_ATTR = "apt:name";
+ public static final String PACKAGE_ATTR = "apt:packagePath";
+ public static final String FILE_ATTR = "apt:filePath";
+ public static final String VISUAL_TYPE_ATTR = "apt:visualType";
+ public static final String VISUAL_TYPE_ATTR2= "apt:type";
+ public static final String DATA_PATH_ATTR = "apt:dataPath";
+ public static final String VALUE_ATTR = "oor:value";
+ public static final String SEPARATOR_ATTR = "oor:separator";
+ public static final String TYPE_ATTR = "oor:type";
+ public static final String SCOPE_ATTR = "apt:scope";
+ public static final String STORE_ATTR = "apt:storeDefault";
+ public static final String INLINE_HELP_ATTR = "apt:inlineHelp";
+ public static final String ONLINE_HELP_ATTR = "apt:onlineHelp";
+ public static final String LABEL_POST_ATTR = "apt:labelPost";
+ public static final String NIL_ATTR = "xsi:nil";
+ public static final String EXTRA_HTML_ATTR = "apt:extraHtml";
+ public static final String CHOOSER_PATH_ATTR= "apt:dataPath";
+ public static final String EXTENDS_CHOOSER_ATTR= "apt:extendsChooser";
+ public static final String LABEL_POPUP_ATTR = "apt:labelPopup";
+ public static final String XML_HANDLER_TAG = "xmlHandler";
+ public static final String ACTION_HANDLER_TAG= "actionHandler";
+ public static final String EVENT_TAG = "event";
+ public static final String ACTION_TAG = "action";
+ public static final String WHEN_TAG = "when";
+ public static final String OTHERWISE_TAG = "otherwise";
+ public static final String COMMAND_TAG = "command";
+ public static final String XML_HANDLER_ATTR = "apt:xmlHandler";
+ public static final String ACTION_HANDLER_ATTR = "apt:actionHandler";
+ public static final String HANDLER_TYPE_ATTR= "apt:type";
+ public static final String TEST_ATTR = "apt:test";
+ public static final String CLASS_ATTR = "apt:class";
+
+ public static final String TEMPLATE_SYSTEM_ID = "policytemplate.dtd";
+
+ private String m_packageName = null;
+ private String m_resourceBundle = null;
+ private String m_helpFile = null;
+ private StringBuffer m_buffer = null;
+ private LinkedList m_context = null;
+
+ private String latestCategoryPath = null;
+ private String latestCategoryResourceIdPath = null;
+ private String latestSectionPath = null;
+ private String latestSectionResourceIdPath = null;
+
+ private String chooserPath = "/";
+
+ private boolean inSet = false;
+
+ private int indentLevel = 0;
+
+
+ public TemplateHandler(TemplateCategory templateRoot,
+ String packageName) {
+ m_buffer = new StringBuffer();
+ m_context = new LinkedList();
+ m_context.add(templateRoot);
+ m_packageName = packageName;
+ }
+
+
+ protected Object getCurrentContext() {
+ return (m_context.getLast());
+ }
+
+
+ public void startElement(String uri, String localName,
+ String qName, Attributes attr) throws SAXException, ClassCastException{
+
+ indentLevel++;
+ nl(); emit("ELEMENT: ");
+ String eName = localName; // element name
+ if ("".equals(eName)){
+ eName = qName; // namespaceAware = false
+ }
+ emit("<"+eName);
+ if (attr != null) {
+ for (int i = 0; i < attr.getLength(); i++) {
+ String aName = attr.getLocalName(i); // Attr name
+ if ("".equals(aName)) aName = attr.getQName(i);
+ nl();
+ emit(" ATTR: ");
+ emit(aName);
+ emit("\t\"");
+ emit(attr.getValue(i));
+ emit("\"");
+ }
+ }
+ if (attr.getLength() > 0) nl();
+ emit(">");
+
+ m_currentElement = qName;
+ if (qName.equals(CATEGORY_TAG)) {
+ String name = attr.getValue(NAME_ATTR);
+ chooserPath += "/" + name;
+ TemplateCategory template = (TemplateCategory) getCurrentContext();
+ TemplateCategory subCategory = template.getSubCategory(name);
+ if (subCategory == null) {
+ String label = attr.getValue(RES_ID_ATTR);
+ if (label == null) {
+ label = attr.getValue(LABEL_ATTR);
+ }
+ subCategory = new TemplatePage(name,
+ attr.getValue(SCOPE_ATTR),
+ label,
+ m_resourceBundle, template);
+ subCategory.setDescriptionId(attr.getValue(INLINE_HELP_ATTR));
+ template.addSubCategory(subCategory);
+ }
+ m_context.add(subCategory);
+ } else if (qName.equals(PAGE_TAG)){
+ String name = attr.getValue(NAME_ATTR);
+ chooserPath += "/" + name;
+ if (getCurrentContext() instanceof TemplateSet) {
+ TemplateSet set = (TemplateSet) getCurrentContext();
+ String label = attr.getValue(RES_ID_ATTR);
+ if (label == null) {
+ label = attr.getValue(LABEL_ATTR);
+ }
+ if (attr.getValue(ONLINE_HELP_ATTR) != null) {
+ m_helpFile = attr.getValue(ONLINE_HELP_ATTR);
+ }
+ TemplatePage page = new TemplatePage(name,
+ attr.getValue(SCOPE_ATTR),
+ label,
+ m_resourceBundle, m_helpFile,
+ null,
+ m_packageName);
+ page.setDataPath(set.getDataPath());
+ page.setDescriptionId(attr.getValue(INLINE_HELP_ATTR));
+ set.setPage(page);
+ m_context.add(page);
+
+ // Added so loaded Policies can get Path
+ //latestCategoryPath = page.getPath();
+ //latestCategoryResourceIdPath = page.getResourceIdPath();
+ } else {
+ TemplateCategory template = (TemplateCategory) getCurrentContext();
+ TemplateCategory subCategory = template.getSubCategory(name);
+ if (subCategory == null) {
+ String label = attr.getValue(RES_ID_ATTR);
+ if (label == null) {
+ label = attr.getValue(LABEL_ATTR);
+ }
+ if (attr.getValue(ONLINE_HELP_ATTR) != null) {
+ m_helpFile = attr.getValue(ONLINE_HELP_ATTR);
+ }
+ subCategory = new TemplatePage(name,
+ attr.getValue(SCOPE_ATTR),
+ label,
+ m_resourceBundle, m_helpFile,
+ template,
+ m_packageName);
+ subCategory.setDescriptionId(attr.getValue(INLINE_HELP_ATTR));
+ template.addSubCategory(subCategory);
+ }
+ m_context.add(subCategory);
+
+ // Added so loaded policies can lookup paths
+ latestCategoryPath = subCategory.getPath();
+ latestCategoryResourceIdPath = subCategory.getResourceIdPath();
+ }
+
+ } else if (qName.equals(SECTION_TAG)) {
+ String label = attr.getValue(RES_ID_ATTR);
+ if (label == null) {
+ label = attr.getValue(LABEL_ATTR);
+ }
+ TemplateSection section = new TemplateSection(
+ attr.getValue(NAME_ATTR),
+
+ attr.getValue(SCOPE_ATTR),
+ label,
+ m_resourceBundle);
+ TemplatePage page = (TemplatePage) getCurrentContext();
+ page.addSection(section);
+ m_context.add(section);
+ chooserPath += "/" + attr.getValue(NAME_ATTR);
+
+ if( inSet ){
+ latestSectionPath = section.getDefaultName() + ";" + latestSectionPath;
+ latestSectionResourceIdPath = section.getResourceId() + ";" + latestSectionResourceIdPath;
+ }else{
+ latestSectionPath = section.getDefaultName() + ";" + latestCategoryPath;
+ latestSectionResourceIdPath = section.getResourceId() + ";" + latestCategoryResourceIdPath;
+ }
+ section.setPath(latestSectionPath);
+ section.setResourceIdPath(latestSectionResourceIdPath);
+
+ } else if (qName.equals(XML_HANDLER_TAG)) {
+ String label = attr.getValue(NAME_ATTR);
+ TemplateXMLHandler handler = new TemplateXMLHandler(label);
+ TemplatePage page = (TemplatePage) getCurrentContext();
+ page.addXMLHandler(handler);
+ m_context.add(handler);
+
+ } else if (qName.equals(ACTION_HANDLER_TAG)) {
+ String name = attr.getValue(NAME_ATTR);
+ String classname = attr.getValue(CLASS_ATTR);
+ String packageDir = m_packageName;
+ TemplateActionHandler handler = new TemplateActionHandler(name, classname, packageDir);
+ TemplatePage page = (TemplatePage) getCurrentContext();
+ page.addActionHandler(handler);
+ m_context.add(handler);
+
+ } else if (qName.equals(SET_TAG)) {
+ String label = attr.getValue(RES_ID_ATTR);
+ if (label == null) {
+ label = attr.getValue(LABEL_ATTR);
+ }
+ TemplateSet set = new TemplateSet(attr.getValue(NAME_ATTR),
+ attr.getValue(SCOPE_ATTR),
+ label,
+ m_resourceBundle,
+ attr.getValue(DATA_PATH_ATTR),
+ attr.getValue(LABEL_POPUP_ATTR));
+
+
+ inSet = true;
+ latestSectionPath = set.getDefaultName() + ";" + latestCategoryPath;
+ latestSectionResourceIdPath = set.getResourceId() + ";" + latestCategoryResourceIdPath;
+
+ set.setPath(latestSectionPath);
+ set.setResourceIdPath(latestSectionResourceIdPath);
+
+ TemplatePage page = (TemplatePage) getCurrentContext();
+ page.addSection(set);
+ m_context.add(set);
+ } else if (qName.equals(PROPERTY_TAG)) {
+ String label = attr.getValue(RES_ID_ATTR);
+ if (label == null) {
+ label = attr.getValue(LABEL_ATTR);
+ }
+ TemplateProperty property = new TemplateProperty(
+ attr.getValue(NAME_ATTR),
+ attr.getValue(SCOPE_ATTR),
+ label,
+ m_resourceBundle,
+ attr.getValue(DATA_PATH_ATTR),
+ attr.getValue(VISUAL_TYPE_ATTR),
+ attr.getValue(TYPE_ATTR),
+ attr.getValue(STORE_ATTR),
+ attr.getValue(XML_HANDLER_ATTR),
+ attr.getValue(ACTION_HANDLER_ATTR),
+ attr.getValue(EXTRA_HTML_ATTR));
+
+ property.setDescriptionId(attr.getValue(INLINE_HELP_ATTR));
+ property.setChooserPath(chooserPath);
+
+ // Added so loaded policies can lookup paths
+ property.setPath( latestSectionPath );
+ property.setResourceIdPath( latestSectionResourceIdPath );
+
+ TemplateSection section = (TemplateSection) getCurrentContext();
+ section.addProperty(property);
+ m_context.add(property);
+ mPropertyList.add( property );
+
+ if( inSet ){
+ mSetList.put(property.getDataPath(), property);
+ }
+
+ } else if (qName.equals(VISUAL_TAG)) {
+ TemplateProperty property = (TemplateProperty) getCurrentContext();
+ property.setVisualType(attr.getValue(VISUAL_TYPE_ATTR2));
+
+ } else if (qName.equals(CHECKBOX_TAG)) {
+ TemplateProperty property = (TemplateProperty) getCurrentContext();
+ property.setVisualType(TemplateProperty.CHECKBOX);
+ //#b5055105# support for localization of label
+ String label = attr.getValue(LABEL_POST_ATTR);
+ property.setLabelPost(label);
+
+ } else if (qName.equals(CHOOSER_TAG)) {
+ TemplateProperty property = (TemplateProperty) getCurrentContext();
+ property.setVisualType(TemplateProperty.CHOOSER);
+ property.setExtendsChooser(attr.getValue(EXTENDS_CHOOSER_ATTR));
+ property.setChooserPath(attr.getValue(CHOOSER_PATH_ATTR));
+ property.setLabelPopup(attr.getValue(LABEL_POPUP_ATTR));
+
+ } else if (qName.equals(RES_IMPORT_TAG)) {
+ m_resourceBundle = attr.getValue(PACKAGE_ATTR);
+
+ } else if (qName.equals(HELP_IMPORT_TAG)) {
+ m_helpFile = attr.getValue(FILE_ATTR);
+
+ } else if (qName.equals(INLINE_HELP_TAG)) {
+ NarratedElement element = (NarratedElement) getCurrentContext();
+ element.setDescriptionId(attr.getValue(RES_ID_ATTR));
+
+ } else if (qName.equals(ENUMERATION_TAG)) {
+ TemplateProperty property = (TemplateProperty) getCurrentContext();
+ String label = attr.getValue(RES_ID_ATTR);
+ if (label == null) {
+ label = attr.getValue(LABEL_ATTR);
+ }
+ property.addConstraint(attr.getValue(VALUE_ATTR), label);
+
+ } else if (qName.equals(VALUE_TAG)) {
+ TemplateProperty property = (TemplateProperty) getCurrentContext();
+ String separator = attr.getValue(SEPARATOR_ATTR);
+ property.setSeparator(separator);
+ property.setDefaultNilValue(attr.getValue(NIL_ATTR));
+ m_buffer.setLength(0);
+
+ } else if (qName.equals(ACTION_TAG)) {
+ m_context.add(ACTION_TAG) ;
+
+ } else if (qName.equals(EVENT_TAG)) {
+ TemplateXMLHandler handler = (TemplateXMLHandler) getCurrentContext();
+ handler.addType(attr.getValue(HANDLER_TYPE_ATTR));
+
+ } else if (qName.equals(WHEN_TAG)) {
+ TemplateXMLHandler handler = (TemplateXMLHandler) m_context.get(m_context.size() - 2);
+ handler.addTest(attr.getValue(TEST_ATTR));
+ handler.addNewCommandList() ;
+ m_context.add(WHEN_TAG) ;
+
+ } else if (qName.equals(OTHERWISE_TAG)) {
+ m_context.add(OTHERWISE_TAG) ;
+
+ } else if (qName.equals(COMMAND_TAG)) {
+ m_buffer.setLength(0);
+ }
+ }
+
+
+ public void characters(char[] chars, int start, int len)
+ throws SAXException {
+ m_buffer.append(chars, start, len);
+ }
+
+
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
+
+ nl();
+ emit("END_ELM: ");
+ emit("</"+localName+">");
+ indentLevel--;
+
+ if ( qName.equals(OTHERWISE_TAG)
+ || qName.equals(WHEN_TAG)
+ || qName.equals(ACTION_TAG)
+ || qName.equals(XML_HANDLER_TAG)
+ || qName.equals(ACTION_HANDLER_TAG)) {
+
+ m_context.removeLast();
+ } else if (qName.equals(PROPERTY_TAG)
+ || qName.equals(SECTION_TAG)
+ || qName.equals(PAGE_TAG)
+ || qName.equals(CATEGORY_TAG)){
+
+ m_context.removeLast();
+ int index = chooserPath.lastIndexOf("/");
+ if( index > 0 ){
+ chooserPath = chooserPath.substring(0, index);
+ }
+ } else if ( qName.equals(SET_TAG) ) {
+ inSet = false;
+ m_context.removeLast();
+ } else if (qName.equals(VALUE_TAG)) {
+
+ TemplateProperty property = (TemplateProperty) getCurrentContext();
+ if (!property.hasDefaultNilValue()) {
+ property.setDefaultValue(m_buffer.toString());
+ }
+ m_buffer.setLength(0);
+
+ } else if (qName.equals(COMMAND_TAG)) {
+ if(((String)getCurrentContext()).equals(ACTION_TAG)) {
+ TemplateXMLHandler handler = (TemplateXMLHandler) m_context.get(m_context.size() - 2) ;
+ handler.addCommand(m_buffer.toString());
+ m_buffer.setLength(0);
+ }
+ else if(((String)getCurrentContext()).equals(WHEN_TAG)) {
+ TemplateXMLHandler handler = (TemplateXMLHandler) m_context.get(m_context.size() - 3) ;
+ handler.addWhenCommand(m_buffer.toString());
+ m_buffer.setLength(0);
+ }
+ else if(((String)getCurrentContext()).equals(OTHERWISE_TAG)) {
+ TemplateXMLHandler handler = (TemplateXMLHandler) m_context.get(m_context.size() - 3) ;
+ handler.addOtherwiseCommand(m_buffer.toString());
+ m_buffer.setLength(0);
+ }
+ }
+ }
+
+
+ public void setDocumentLocator(Locator l)
+ {
+ m_locator = l;
+ System.out.println("Loading Template: " + l.getSystemId() );
+ }
+
+
+ public InputSource resolveEntity (String publicId, String systemId) throws SAXParseException {
+ if ((systemId.endsWith(TEMPLATE_SYSTEM_ID)) && (m_DTDLocation != null)) {
+ try {
+ if( m_DTDLocation.exists() ){
+ FileInputStream stream = new FileInputStream(m_DTDLocation);
+ return new InputSource(stream);
+ }
+
+ File dtd = new File(TEMPLATE_SYSTEM_ID);
+ if( dtd.exists() ){
+ FileInputStream stream = new FileInputStream(dtd);
+ return new InputSource(stream);
+ }else{
+ throw new FileNotFoundException();
+ }
+ } catch (FileNotFoundException e) {
+ String error = "Could not load " + TEMPLATE_SYSTEM_ID + "!" +
+ "\nPlease make sure it is located in the program working directory" +
+ "\nor in the root directory of the packages.";
+ throw new SAXParseException(error, m_locator);
+ }
+ } else {
+ return null;
+ }
+ }
+
+
+
+ //===========================================================
+ // SAX ErrorHandler methods
+ //===========================================================
+
+ public void fatalError (SAXParseException e)
+ throws SAXException
+ {
+ throw e;
+ }
+
+ // treat validation errors as fatal
+ public void error(SAXParseException e)
+ throws SAXParseException
+ {
+ String error = "XML ERROR in file: '" + e.getSystemId() +
+ "', on LINE: " + e.getLineNumber() +
+ "\n INFO: " + e.getMessage() + "\n";
+ System.err.println(error);
+ }
+
+ // dump warnings too
+ public void warning(SAXParseException err)
+ throws SAXParseException
+ {
+ // System.out.println("** Warning"
+ // + ", line " + err.getLineNumber()
+ // + ", uri " + err.getSystemId());
+ // System.out.println(" " + err.getMessage());
+ }
+
+ //===========================================================
+ // Utility Methods ...
+ //===========================================================
+
+ // Wrap I/O exceptions in SAX exceptions, to
+ // suit handler signature requirements
+ private void emit(String s)
+ throws SAXException
+ {
+ if(debug){
+ try {
+ out.write(s);
+ out.flush();
+ } catch (IOException e) {
+ throw new SAXException("I/O error", e);
+ }
+ }
+ }
+
+ // Start a new line
+ // and indent the next line appropriately
+ private void nl()
+ throws SAXException
+ {
+ if(debug){
+ String lineEnd = System.getProperty("line.separator");
+ try {
+ out.write(lineEnd);
+ //for (int i=0; i < indentLevel; i++) out.write(indentString);
+ } catch (IOException e) {
+ throw new SAXException("I/O error", e);
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplateProperty.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplateProperty.java
new file mode 100644
index 0000000..324e981
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplateProperty.java
@@ -0,0 +1,270 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+
+import java.util.Vector;
+
+public class TemplateProperty extends TemplateElement
+ implements NarratedElement {
+
+ public static final String CHECKBOX = "checkBox";
+ public static final String RADIOBUTTONS = "radioButtons";
+ public static final String COMBOBOX = "comboBox";
+ public static final String LISTBOX = "listBox";
+ public static final String PASSWORD = "password";
+ public static final String TEXTAREA = "textArea";
+ public static final String TEXTFIELD = "textField";
+ public static final String CUSTOM = "customRenderer";
+ public static final String HIDDEN = "hidden";
+ public static final String STRING_LIST = "stringList";
+ public static final String COLOR_CHOOSER = "colorSelector";
+ public static final String CHOOSER = "chooser";
+
+
+
+ private String m_dataPath = null;
+ private String m_visualType = null;
+ private String m_type = null;
+ private String m_defaultValue = null;
+ private String m_descriptionId = null;
+ private String m_extraHtml = null;
+ private String m_extraData = null;
+ private String m_xmlHandler = null;
+ private String m_actionHandler = null;
+ private String m_chooserPath = null;
+ private String m_extendsChooser = null;
+ private String m_labelPopup = null;
+ private Vector m_constraints = null;
+ private String m_labelPost = null;
+ private String m_separator = null;
+ private String m_path = null;
+ private String m_resourceIdPath = null;
+
+ private boolean m_autostore = false;
+ private boolean m_defaultNilValue = false;
+
+
+ public TemplateProperty(String defaultName, String scope, String resourceId,
+ String resourceBundle, String dataPath, String visualType,
+ String type, String autostore, String xmlHandler, String actionHandler, String extraHtml) {
+ super(defaultName, scope, resourceId, resourceBundle);
+
+ m_dataPath = dataPath;
+ m_extraHtml = extraHtml;
+ m_xmlHandler = xmlHandler ;
+ m_actionHandler = actionHandler ;
+ m_type = type;
+ if (visualType == null) {
+ m_visualType = TEXTFIELD;
+ } else {
+ m_visualType = visualType;
+ }
+ if ((autostore != null) && (autostore.indexOf("true") != -1)) {
+ m_autostore = true;
+ }
+ }
+
+ public String getPath(){
+ return m_path;
+ }
+
+ public void setPath(String path){
+ m_path = path;
+ }
+
+ public String getResourceIdPath(){
+ return m_resourceIdPath;
+ }
+
+ public void setResourceIdPath(String resourceIdPath){
+ m_resourceIdPath = resourceIdPath;
+ }
+
+ public boolean isAutoStored() {
+ return m_autostore;
+ }
+
+
+ public String getDataPath() {
+ return m_dataPath;
+ }
+
+
+ public String getExtraHtml() {
+ return m_extraHtml;
+ }
+
+ public String getChooserPath() {
+ return m_chooserPath;
+ }
+
+ public String getExtendsChooser() {
+ return m_extendsChooser;
+ }
+
+ public String getLabelPopup() {
+ return m_labelPopup;
+ }
+
+ public String getLabelPost() {
+ return m_labelPost;
+ }
+
+ public String getXmlHandler() {
+ return m_xmlHandler;
+ }
+
+ public String getActionHandler() {
+ return m_actionHandler;
+ }
+
+ public String getDataType() {
+ return m_type;
+ }
+
+ public String getSeparator() {
+ String separator = m_separator;
+ if(m_separator == null) {
+ separator = " ";
+ }
+ return separator;
+ }
+
+ public String getVisualType() {
+ return m_visualType;
+ }
+
+
+ public void setVisualType(String visualType) {
+ m_visualType = visualType;
+ }
+
+
+ public String getDescriptionId() {
+ return m_descriptionId;
+ }
+
+
+ public void setDescriptionId(String resourceId) {
+ m_descriptionId = resourceId;
+ }
+
+ public void setSeparator(String separator) {
+ m_separator = separator;
+ }
+
+ public void addConstraint(String value) {
+ if (m_constraints == null) {
+ m_constraints = new Vector();
+ }
+ m_constraints.add(new TemplatePropertyConstraint(value, null));
+ }
+
+ public void addConstraint(String value, String resId) {
+ if (m_constraints == null) {
+ m_constraints = new Vector();
+ }
+ m_constraints.add(new TemplatePropertyConstraint(value, resId));
+ }
+
+
+ public Vector getConstraints() {
+ return m_constraints;
+ }
+
+
+ public void setDefaultValue(String value) {
+ m_defaultValue = value;
+ m_defaultNilValue = false;
+ }
+
+
+ public void setDefaultNilValue(String isNilValue) {
+ if ((isNilValue != null) && (isNilValue.indexOf("true") != -1)) {
+ m_defaultNilValue = true;
+ m_defaultValue = null;
+ }
+ }
+
+
+ public String getDefaultValue() {
+ return m_defaultValue;
+ }
+
+
+ public boolean hasDefaultNilValue() {
+ return m_defaultNilValue;
+ }
+
+
+ public String getExtraData() {
+ return m_extraData;
+ }
+
+
+ public void setExtraData(String extraData) {
+ m_extraData = extraData;
+ }
+
+ public void setChooserPath(String chooserPath) {
+ m_chooserPath = chooserPath;
+ }
+
+ public void setExtendsChooser(String extendsChooser) {
+ m_extendsChooser = extendsChooser;
+ }
+
+ public void setLabelPopup(String labelPopup) {
+ m_labelPopup = labelPopup;
+ }
+
+ public void setLabelPost(String labelPost) {
+ m_labelPost = labelPost;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(super.toString());
+ buffer.append(", ");
+ buffer.append(getVisualType());
+ buffer.append(", ");
+ buffer.append(getDataPath());
+ buffer.append(") ");
+ return buffer.toString();
+ }
+}
+
+
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplatePropertyConstraint.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplatePropertyConstraint.java
new file mode 100644
index 0000000..6d7a232
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplatePropertyConstraint.java
@@ -0,0 +1,56 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+public class TemplatePropertyConstraint {
+
+ private String m_value = null;
+ private String m_resId = null;
+
+ public TemplatePropertyConstraint(String value, String resId) {
+ m_value = value;
+ m_resId = resId;
+ }
+
+
+ public String getValue() {
+ return m_value;
+ }
+
+ public String getResourceId() {
+ return m_resId;
+ }
+}
+
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplateSection.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplateSection.java
new file mode 100644
index 0000000..a0edbbb
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplateSection.java
@@ -0,0 +1,104 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+
+public class TemplateSection extends TemplateElement {
+
+ private List m_properties = null;
+ private String mPath = null;
+ private String mResourceIdPath = null;
+
+
+ public TemplateSection(String defaultName, String scope, String resourceId,
+ String resourceBundle) {
+ super(defaultName, scope, resourceId, resourceBundle);
+ }
+
+
+ public List getProperties() {
+ return m_properties;
+ }
+
+
+ public TemplateProperty getProperty(int index) {
+ return (TemplateProperty) m_properties.get(index);
+ }
+
+
+ void addProperty(TemplateProperty property) {
+ if (m_properties == null) {
+ m_properties = new ArrayList();
+ }
+ m_properties.add(property);
+ }
+
+
+ public void setPath(String path){
+ mPath = path;
+ }
+
+ public String getPath(){
+ return mPath;
+ }
+
+ public void setResourceIdPath(String resourceIdPath){
+ mResourceIdPath = resourceIdPath;
+ }
+
+ public String getResourceIdPath(){
+ return mResourceIdPath;
+ }
+
+ boolean hasVisibleContent(byte scope) {
+ Iterator it = getProperties().iterator();
+ while (it.hasNext()) {
+ TemplateProperty property = (TemplateProperty) it.next();
+ if (property.isInScope(scope)) {
+ if (!property.getVisualType().equals("hidden")) {
+ return true;
+ } else if (!property.isAutoStored()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
+
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplateSet.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplateSet.java
new file mode 100644
index 0000000..e39508b
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplateSet.java
@@ -0,0 +1,73 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+
+public class TemplateSet extends TemplateSection {
+
+ private TemplatePage m_page = null;
+ private String m_dataPath = null;
+ private String m_labelPopup = null;
+
+ public TemplateSet(String defaultName, String scope, String resourceId,
+ String resourceBundle, String dataPath, String labelPopup) {
+ super(defaultName, scope, resourceId, resourceBundle);
+ m_dataPath = dataPath;
+ m_labelPopup = labelPopup;
+ }
+
+ public void setPage(TemplatePage page) {
+ m_page = page;
+ }
+
+ public TemplatePage getPage() {
+ return m_page;
+ }
+
+ public String getDataPath() {
+ return m_dataPath;
+ }
+
+ public String getLabelPopup() {
+ return m_labelPopup;
+ }
+
+ public boolean isSection(){
+ return false;
+ }
+
+}
+
+
diff --git a/src/com/sun/apoc/tools/profileeditor/templates/TemplateXMLHandler.java b/src/com/sun/apoc/tools/profileeditor/templates/TemplateXMLHandler.java
new file mode 100644
index 0000000..960d368
--- /dev/null
+++ b/src/com/sun/apoc/tools/profileeditor/templates/TemplateXMLHandler.java
@@ -0,0 +1,136 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either
+ * the GNU General Public License Version 2 only ("GPL") or
+ * the Common Development and Distribution License("CDDL")
+ * (collectively, the "License"). You may not use this file
+ * except in compliance with the License. You can obtain a copy
+ * of the License at www.sun.com/CDDL or at COPYRIGHT. See the
+ * License for the specific language governing permissions and
+ * limitations under the License. When distributing the software,
+ * include this License Header Notice in each file and include
+ * the License file at /legal/license.txt. If applicable, add the
+ * following below the License Header, with the fields enclosed
+ * by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by
+ * only the CDDL or only the GPL Version 2, indicate your
+ * decision by adding "[Contributor] elects to include this
+ * software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice
+ * of license, a recipient has the option to distribute your
+ * version of this file under either the CDDL, the GPL Version
+ * 2 or to extend the choice of license to its licensees as
+ * provided above. However, if you add GPL Version 2 code and
+ * therefore, elected the GPL Version 2 license, then the
+ * option applies only if the new code is made subject to such
+ * option by the copyright holder.
+ */
+package com.sun.apoc.tools.profileeditor.templates;
+
+import java.util.List;
+import java.util.ArrayList;
+
+
+
+public class TemplateXMLHandler {
+
+ private String m_name = null ;
+ private String m_type = null ;
+ private List m_tests = null ;
+ private List m_commands = null ;
+ private List m_whenCommands = null ;
+ private List m_otherCommands = null ;
+
+ public TemplateXMLHandler(String name) {
+ m_name = name ;
+ }
+
+ public void addType(String type) {
+ m_type = type ;
+ }
+
+ public void addTest(String test) {
+ if (m_tests == null) {
+ m_tests = new ArrayList();
+ }
+ m_tests.add(test);
+ }
+
+ public void addCommand(String command) {
+ if (m_commands == null) {
+ m_commands = new ArrayList();
+ }
+ m_commands.add(command);
+ }
+
+ public void addNewCommandList() {
+ if (m_whenCommands == null) {
+ m_whenCommands = new ArrayList();
+ }
+ m_whenCommands.add(new ArrayList()) ;
+ }
+
+ public void addWhenCommand(String command) {
+ if (m_whenCommands == null) {
+ m_whenCommands = new ArrayList();
+ }
+ ((ArrayList)m_whenCommands.get(m_whenCommands.size()-1)).add(command) ;
+ }
+
+ public void addOtherwiseCommand(String command) {
+ if (m_otherCommands == null) {
+ m_otherCommands = new ArrayList();
+ }
+ m_otherCommands.add(command);
+ }
+
+ public String getName() {
+ return m_name ;
+ }
+
+ public String getType() {
+ return m_type ;
+ }
+
+ public List getTests() {
+ return m_tests ;
+ }
+
+ public String getTest(int index) {
+ return (String) m_tests.get(index);
+ }
+
+ public List getCommands() {
+ return m_commands;
+ }
+
+ public String getCommand(int index) {
+ return (String) m_commands.get(index);
+ }
+
+ public List getWhenCommandLists() {
+ return m_whenCommands;
+ }
+
+ public List getWhenCommandList(int index) {
+ return (List
+ ) m_whenCommands.get(index);
+ }
+
+ public List getOtherwiseCommands() {
+ return m_otherCommands;
+ }
+
+ public String getOtherwiseCommand(int index) {
+ return (String) m_otherCommands.get(index);
+ }
+}
+
+
diff --git a/src/profile-editor.in b/src/profile-editor.in
new file mode 100755
index 0000000..b0a21e8
--- /dev/null
+++ b/src/profile-editor.in
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+JAVA=@JAVA@
+
+$JAVA -jar @APOCDIR@/apoc_peditor.jar com.sun.apoc.tools.profileeditor.ProfileEditor