You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by GitBox <gi...@apache.org> on 2017/11/05 18:39:58 UTC
[GitHub] matthiasblaesing closed pull request #234: [NETBEANS-68] Remove SwingX dependency
matthiasblaesing closed pull request #234: [NETBEANS-68] Remove SwingX dependency
URL: https://github.com/apache/incubator-netbeans/pull/234
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/libs.swingx/external/binaries-list b/db.dataview/external/binaries-list
similarity index 92%
rename from libs.swingx/external/binaries-list
rename to db.dataview/external/binaries-list
index 363a97132..8c842a683 100644
--- a/libs.swingx/external/binaries-list
+++ b/db.dataview/external/binaries-list
@@ -14,4 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-C0D8A3265D194CC886BAFD585117B6465FD97DCE swingx-all-1.6.4.jar
+
+DD0034398D593AA3588C6773FAAC429BBD9AEA0E com.h2database:h2:1.4.196
\ No newline at end of file
diff --git a/db.dataview/external/h2-1.4.196-license.txt b/db.dataview/external/h2-1.4.196-license.txt
new file mode 100644
index 000000000..4430447e1
--- /dev/null
+++ b/db.dataview/external/h2-1.4.196-license.txt
@@ -0,0 +1,256 @@
+Name: H2 Database Engine
+Version: 1.4.196
+License: EPL-v10
+Description: The H2 Database Enginge is a pure java database, that can be used in embedded and server mode.
+Origin: http://h2database.com
+
+Summary and License FAQ
+
+H2 is dual licensed and available under the MPL 2.0 (Mozilla Public License Version 2.0) or under the EPL 1.0 (Eclipse Public License). There is a license FAQ for both the MPL and the EPL.
+
+ You can use H2 for free.
+ You can integrate it into your applications (including in commercial applications) and distribute it.
+ Files containing only your code are not covered by this license (it is 'commercial friendly').
+ Modifications to the H2 source code must be published.
+ You don't need to provide the source code of H2 if you did not modify anything.
+ If you distribute a binary that includes H2, you need to add a disclaimer of liability - see the example below.
+
+However, nobody is allowed to rename H2, modify it a little, and sell it as a database engine without telling the customers it is in fact H2. This happened to HSQLDB: a company called 'bungisoft' copied HSQLDB, renamed it to 'RedBase', and tried to sell it, hiding the fact that it was in fact just HSQLDB. It seems 'bungisoft' does not exist any more, but you can use the Wayback Machine and visit old web pages of http://www.bungisoft.com.
+
+About porting the source code to another language (for example C# or C++): converted source code (even if done manually) stays under the same copyright and license as the original code. The copyright of the ported source code does not (automatically) go to the person who ported the code.
+
+If you distribute a binary that includes H2, you need to add the license and a disclaimer of liability (as you should do for your own code). You should add a disclaimer for each open source library you use. For example, add a file 3rdparty_license.txt in the directory where the jar files are, and list all open source libraries, each one with its license and disclaimer. For H2, a simple solution is to copy the following text below. You may also include a copy of the complete license.
+
+This software contains unmodified binary redistributions for
+H2 database engine (http://www.h2database.com/),
+which is dual licensed and available under the MPL 2.0
+(Mozilla Public License) or under the EPL 1.0 (Eclipse Public License).
+An original copy of the license agreement can be found at:
+http://www.h2database.com/html/license.html
+
+Mozilla Public License Version 2.0
+1. Definitions
+
+1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
+
+1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution" means Covered Software of a particular Contributor.
+
+1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses" means
+
+a. that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
+
+b. that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
+
+1.6. "Executable Form" means any form of the work other than Source Code Form.
+
+1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
+
+1.8. "License" means this document.
+
+1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
+
+1.10. "Modifications" means any of the following:
+
+a. any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
+
+b. any new file in Source Code Form that contains any Covered Software.
+
+1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
+
+1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
+
+1.13. "Source Code Form" means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that 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 and Conditions
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+ under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
+
+ under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
+
+ for any code that a Contributor has removed from Covered Software; or
+
+ for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
+
+ under Patent Claims infringed by Covered Software in the absence of its Contributions.
+
+This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
+3. Responsibilities
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form.
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+ such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
+
+ You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
+3.4. Notices
+
+You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
+3.5. Application of Additional Terms
+
+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 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 every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
+4. Inability to Comply Due to Statute or Regulation
+
+If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
+5. Termination
+
+5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
+6. Disclaimer of Warranty
+
+Covered Software is provided under this License on an "as is" basis, without warranty of any kind, either expressed, implied, or statutory, 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 any 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 under this License except under this disclaimer.
+7. Limitation of Liability
+
+Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, 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 party's 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. Litigation
+
+Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims.
+9. Miscellaneous
+
+This License represents the complete agreement concerning the 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. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
+10. Versions of the License
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
+10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
+Exhibit A - Source Code Form License Notice
+
+This Source Code Form is subject to the terms of the Mozilla
+Public License, v. 2.0. If a copy of the MPL was not distributed
+with this file, you can obtain one at http://mozilla.org/MPL/2.0
+
+If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+
+This Source Code Form is "Incompatible With Secondary Licenses",
+as defined by the Mozilla Public License, v. 2.0.
+
+Eclipse Public License - Version 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+Export Control Classification Number (ECCN)
+
+As far as we know, the U.S. Export Control Classification Number (ECCN) for this software is 5D002. However, for legal reasons, we can make no warranty that this information is correct. For details, see also the Apache Software Foundation Export Classifications page.
\ No newline at end of file
diff --git a/db.dataview/external/h2-1.4.196-notice.txt b/db.dataview/external/h2-1.4.196-notice.txt
new file mode 100644
index 000000000..7bb941925
--- /dev/null
+++ b/db.dataview/external/h2-1.4.196-notice.txt
@@ -0,0 +1,6 @@
+This software contains unmodified binary redistributions for
+H2 database engine (http://www.h2database.com/),
+which is dual licensed and available under the MPL 2.0
+(Mozilla Public License) or under the EPL 1.0 (Eclipse Public License).
+An original copy of the license agreement can be found at:
+http://www.h2database.com/html/license.html
\ No newline at end of file
diff --git a/db.dataview/nbproject/project.properties b/db.dataview/nbproject/project.properties
index 45580ea72..ca2a7a199 100644
--- a/db.dataview/nbproject/project.properties
+++ b/db.dataview/nbproject/project.properties
@@ -14,10 +14,10 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-javac.source=1.7
+javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
test.unit.cp.extra=\
- ${basedir}/test/unit/data/etc/axiondb.jar
+ ${basedir}/external/h2-1.4.196.jar
test.config.stableBTD.includes=**/*Test.class
test.config.stableBTD.excludes=\
diff --git a/db.dataview/nbproject/project.xml b/db.dataview/nbproject/project.xml
index 32920fa4b..f3e1182e2 100644
--- a/db.dataview/nbproject/project.xml
+++ b/db.dataview/nbproject/project.xml
@@ -43,15 +43,6 @@
</run-dependency>
</dependency>
<dependency>
- <code-name-base>org.netbeans.libs.swingx</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.15</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
<code-name-base>org.netbeans.modules.db</code-name-base>
<build-prerequisite/>
<compile-dependency/>
@@ -149,6 +140,10 @@
<compile-dependency/>
</test-dependency>
<test-dependency>
+ <code-name-base>org.netbeans.modules.dbapi</code-name-base>
+ <compile-dependency/>
+ </test-dependency>
+ <test-dependency>
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
<recursive/>
<compile-dependency/>
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/images/preferences-desktop.png b/db.dataview/src/org/netbeans/modules/db/dataview/images/preferences-desktop.png
new file mode 100644
index 000000000..68f916c9d
Binary files /dev/null and b/db.dataview/src/org/netbeans/modules/db/dataview/images/preferences-desktop.png differ
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java b/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
index 05dc5de2b..94d40e8cc 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
@@ -29,18 +29,14 @@
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.sql.Blob;
-import java.sql.Clob;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.swing.JComponent;
+import javax.swing.JCheckBox;
import javax.swing.JMenuItem;
+import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
-import javax.swing.RowFilter;
-import javax.swing.SortOrder;
-import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
@@ -49,11 +45,9 @@
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
-import org.jdesktop.swingx.renderer.JRendererCheckBox;
import org.netbeans.modules.db.dataview.meta.DBColumn;
import org.netbeans.modules.db.dataview.meta.DBException;
import org.netbeans.modules.db.dataview.meta.DBTable;
-import org.netbeans.modules.db.dataview.table.ResultSetCellRenderer;
import org.netbeans.modules.db.dataview.table.ResultSetJXTable;
import org.netbeans.modules.db.dataview.util.ColorHelper;
import org.openide.DialogDisplayer;
@@ -86,9 +80,6 @@ public DataViewTableUI(DataViewUI dataviewUI, DataViewActionHandler handler, Dat
this.dataviewUI = dataviewUI;
this.handler = handler;
- // Make sure sorting can be disabled by taking unsorted into the sort order cycle
- this.setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED);
-
TableSelectionListener listener = new TableSelectionListener(this);
this.getSelectionModel().addListSelectionListener(listener);
this.getColumnModel().getSelectionModel().addListSelectionListener(listener);
@@ -104,13 +95,11 @@ public void setModel(TableModel dataModel) {
throw new IllegalArgumentException("DataViewTableUI only supports"
+ " instances of DataViewTableUIModel");
}
- RowFilter<?, ?> oldFilter = getRowFilter();
if (getModel() != null) {
getModel().removeTableModelListener(dataChangedListener); // Remove ChangeListener on replace
}
super.setModel(dataModel);
dataModel.addTableModelListener(dataChangedListener); // Add new change listener
- setRowFilter((RowFilter) oldFilter);
if (dataviewUI != null) {
dataviewUI.handleColumnUpdated();
}
@@ -126,18 +115,31 @@ protected TableModel createDefaultDataModel() {
return new DataViewTableUIModel(new DBColumn[0]);
}
+ private static int borderThickness = 2;
+ private static Color selectedForeground = ColorHelper.getTablecellEditedSelectedForeground();
+ private static Color unselectedForeground = ColorHelper.getTablecellEditedUnselectedForeground();
+ private static final JPanel checkboxReplacement = new JPanel(new BorderLayout());
+
@Override
- public TableCellRenderer getCellRenderer(int row, int column) {
- try {
- if (getModel().hasUpdates(
- convertRowIndexToModel(row),
- convertColumnIndexToModel(column))) {
- return new UpdatedResultSetCellRenderer();
+ public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
+ Component c = super.prepareRenderer(renderer, row, column);
+ if (getModel().hasUpdates(
+ convertRowIndexToModel(row),
+ convertColumnIndexToModel(column))) {
+
+ Color color = isCellSelected(row, column) ? selectedForeground : unselectedForeground;
+
+ if (c instanceof JCheckBox) {
+ checkboxReplacement.removeAll();
+ checkboxReplacement.setBorder(new LineBorder(color, borderThickness));
+ checkboxReplacement.add(c);
+ return checkboxReplacement;
+ } else {
+ c.setForeground(color);
+ return c;
}
- } catch (IndexOutOfBoundsException ex) {
- // Swallow it, caused by pack from JXTable - Bug #228753
}
- return super.getCellRenderer(row, column);
+ return c;
}
@Override
@@ -145,42 +147,6 @@ protected KeyListener createControKeyListener() {
return new Control0KeyListener();
}
- private static class UpdatedResultSetCellRenderer extends ResultSetCellRenderer {
-
- static int borderThickness = 1;
- static Color selectedForeground;
- static Color unselectedForeground;
- private final JComponent holder = new JComponent() {};
-
- static {
- selectedForeground = ColorHelper.getTablecellEditedSelectedForeground();
- unselectedForeground = ColorHelper.getTablecellEditedUnselectedForeground();
- }
-
- public UpdatedResultSetCellRenderer() {
- holder.setLayout(new BorderLayout());
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- assert (table.getModel() instanceof DataViewTableUIModel) : "Assuming usage with DataViewTableUIModel";
-
- Color color = isSelected ? selectedForeground : unselectedForeground;
-
- if (c instanceof JRendererCheckBox) {
- holder.removeAll();
- holder.setBorder(new LineBorder(color, borderThickness));
- holder.add(c);
- return holder;
- } else {
- c.setForeground(color);
- }
- return c;
- }
- }
-
private class Control0KeyListener implements KeyListener {
public Control0KeyListener() {
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewUI.java b/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewUI.java
index cb48c755f..2007eb1b3 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewUI.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewUI.java
@@ -20,7 +20,12 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
import java.awt.Insets;
+import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
@@ -32,21 +37,26 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.net.URL;
+import java.util.Set;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
+import javax.swing.DefaultRowSorter;
import javax.swing.ImageIcon;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
+import javax.swing.JSeparator;
+import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JToolBar;
+import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
-import org.jdesktop.swingx.JXButton;
-import org.jdesktop.swingx.JXLabel;
-import org.jdesktop.swingx.JXPanel;
import org.netbeans.modules.db.dataview.table.JXTableRowHeader;
import org.netbeans.modules.db.dataview.table.MultiColPatternFilter;
import org.netbeans.modules.db.dataview.table.ResultSetJXTable;
@@ -61,25 +71,25 @@
@NbBundle.Messages({
"LBL_fetched_rows=Fetched Rows:"
})
-class DataViewUI extends JXPanel {
-
- private JXButton commit;
- private JXButton refreshButton;
- private JXButton truncateButton;
-
- private JXButton deleteRow;
- private JXButton insert;
+class DataViewUI extends JPanel {
+ private static final String IMG_PREFIX = "/org/netbeans/modules/db/dataview/images/"; // NOI18N
+
+ private final JButton[] editButtons = new JButton[5];
+ private final DataViewTableUI dataPanel;
+ private final JScrollPane dataPanelScrollPane;
+ private final DataViewPageContext pageContext;
+ private final DataViewActionHandler actionHandler;
+
+ private JButton commit;
+ private JButton refreshButton;
+ private JButton truncateButton;
+ private JButton deleteRow;
+ private JButton insert;
private JTextField refreshField;
private JTextField matchBoxField;
- private JXLabel fetchedRowsLabel;
- private JXLabel limitRow;
- private JXButton[] editButtons = new JXButton[5];
- private DataViewTableUI dataPanel;
- private JScrollPane dataPanelScrollPane;
- private final DataViewPageContext pageContext;
- private JXButton cancel;
- private DataViewActionHandler actionHandler;
- private String imgPrefix = "/org/netbeans/modules/db/dataview/images/"; // NOI18N
+ private JLabel fetchedRowsLabel;
+ private JLabel limitRow;
+ private JButton cancel;
private final PropertyChangeListener pageContextListener =
new PropertyChangeListener() {
@@ -121,7 +131,85 @@ public void mouseExited(MouseEvent evt) {
protected void showPopup(MouseEvent evt) {
}
};
+
+ private final ActionListener columnVisibilityToggler = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JCheckBox source = (JCheckBox) e.getSource();
+ int index = Integer.parseInt(e.getActionCommand());
+ Set<Integer> currentVisibleColumns = dataPanel.getVisibleColumns();
+ if (source.isSelected()) {
+ currentVisibleColumns.add(index);
+ } else {
+ currentVisibleColumns.remove(index);
+ }
+ dataPanel.setVisibleColumns(currentVisibleColumns);
+ }
+ };
+
+ private final ActionListener fitColumnWidthToggler = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (((JCheckBox) e.getSource()).isSelected()) {
+ dataPanel.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
+ } else {
+ dataPanel.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+ }
+ }
+ };
+
+ private final ActionListener popupActionListener = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JButton button = (JButton) e.getSource();
+ JCheckBox firstEntry = null;
+ JPopupMenu popupMenu = new JPopupMenu();
+
+ JPanel menuPanel = new JPanel();
+ menuPanel.setFocusCycleRoot(true);
+ popupMenu.add(menuPanel);
+ menuPanel.setLayout(new GridBagLayout());
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.anchor = GridBagConstraints.BASELINE_LEADING;
+ constraints.weightx = 1;
+ constraints.gridx = 0;
+
+ Set<Integer> visibleColumns = dataPanel.getVisibleColumns();
+ DataViewTableUIModel dvtm = dataPanel.getModel();
+
+ for(int i = 0; i < dvtm.getColumnCount(); i++) {
+ JCheckBox columnEntry = new JCheckBox(dvtm.getColumnName(i));
+ columnEntry.setActionCommand(Integer.toString(i));
+ columnEntry.setSelected(visibleColumns.contains(i));
+ columnEntry.addActionListener(columnVisibilityToggler);
+ constraints.gridy += 1;
+ menuPanel.add(columnEntry, constraints);
+ if(firstEntry == null) {
+ firstEntry = columnEntry;
+ }
+ }
+
+ constraints.gridy += 1;
+ menuPanel.add(new JSeparator(), constraints);
+
+ JCheckBox checkboxItem = new JCheckBox("Fit column width");
+ checkboxItem.setSelected(dataPanel.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF);
+ checkboxItem.addActionListener(fitColumnWidthToggler);
+
+ constraints.gridy += 1;
+ menuPanel.add(checkboxItem, constraints);
+
+ popupMenu.show(button, 0, button.getHeight());
+ if(firstEntry == null) {
+ checkboxItem.requestFocus();
+ } else {
+ firstEntry.requestFocus();
+ }
+ }
+ };
+ @SuppressWarnings("OverridableMethodCallInConstructor")
DataViewUI(DataView dataView, DataViewPageContext pageContext, boolean nbOutputComponent) {
assert SwingUtilities.isEventDispatchThread() : "Must be called from AWT thread"; //NOI18N
@@ -143,9 +231,28 @@ protected void showPopup(MouseEvent evt) {
//add resultset data panel
dataPanel = new DataViewTableUI(this, actionHandler, dataView, pageContext);
dataPanelScrollPane = new JScrollPane(dataPanel);
+ dataPanelScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ dataPanelScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JXTableRowHeader rowHeader = new JXTableRowHeader(dataPanel);
dataPanelScrollPane.setRowHeaderView(rowHeader);
dataPanelScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, rowHeader.getTableHeader());
+
+ URL url = getClass().getResource(IMG_PREFIX + "preferences-desktop.png"); // NOI18N
+ ImageIcon icon = new ImageIcon(url);
+ JButton cornerButton = new JButton() {
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ int iconSize = Math.min(getWidth(), getHeight());
+ Graphics2D g2d = (Graphics2D) g;
+ g2d.setColor(getBackground());
+ g2d.fillRect(0, 0, getWidth(), getHeight());
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.drawImage(icon.getImage(), (getWidth() - iconSize) / 2, (getHeight() - iconSize) / 2, iconSize, iconSize, null);
+ }
+ };
+ cornerButton.addActionListener(popupActionListener);
+ dataPanelScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, cornerButton);
this.add(dataPanelScrollPane, BorderLayout.CENTER);
dataPanel.revalidate();
@@ -280,14 +387,6 @@ public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
if (src.equals(refreshButton)) {
actionHandler.refreshActionPerformed();
-// } else if (src.equals(first)) {
-// actionHandler.firstActionPerformed();
-// } else if (src.equals(last)) {
-// actionHandler.lastActionPerformed();
-// } else if (src.equals(next)) {
-// actionHandler.nextActionPerformed();
-// } else if (src.equals(previous)) {
-// actionHandler.previousActionPerformed();
} else if (src.equals(refreshField)) {
actionHandler.updateActionPerformed();
} else if (src.equals(commit)) {
@@ -333,8 +432,8 @@ private void initToolbarWest(JToolBar toolbar, ActionListener outputListener, bo
toolbar.addSeparator(new Dimension(10, 10));
//add refresh button
- URL url = getClass().getResource(imgPrefix + "refresh.png"); // NOI18N
- refreshButton = new JXButton(new ImageIcon(url));
+ URL url = getClass().getResource(IMG_PREFIX + "refresh.png"); // NOI18N
+ refreshButton = new JButton(new ImageIcon(url));
refreshButton.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_refresh"));
refreshButton.addActionListener(outputListener);
processButton(refreshButton);
@@ -342,7 +441,7 @@ private void initToolbarWest(JToolBar toolbar, ActionListener outputListener, bo
toolbar.add(refreshButton);
//add limit row label
- limitRow = new JXLabel(NbBundle.getMessage(DataViewUI.class, "LBL_max_rows"));
+ limitRow = new JLabel(NbBundle.getMessage(DataViewUI.class, "LBL_max_rows"));
limitRow.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8));
toolbar.add(limitRow);
@@ -360,11 +459,11 @@ public void focusGained(FocusEvent e) {
toolbar.add(refreshField);
toolbar.addSeparator(new Dimension(10, 10));
- JXLabel fetchedRowsNameLabel = new JXLabel(NbBundle.getMessage(DataViewUI.class, "LBL_fetched_rows"));
+ JLabel fetchedRowsNameLabel = new JLabel(NbBundle.getMessage(DataViewUI.class, "LBL_fetched_rows"));
fetchedRowsNameLabel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(DataViewUI.class, "LBL_fetched_rows"));
fetchedRowsNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
toolbar.add(fetchedRowsNameLabel);
- fetchedRowsLabel = new JXLabel();
+ fetchedRowsLabel = new JLabel();
toolbar.add(fetchedRowsLabel);
toolbar.addSeparator(new Dimension(10, 10));
@@ -372,7 +471,7 @@ public void focusGained(FocusEvent e) {
private void initToolbarEast(JToolBar toolbar) {
// match box labble
- JXLabel matchBoxRow = new JXLabel(NbBundle.getMessage(DataViewUI.class, "LBL_matchbox"));
+ JLabel matchBoxRow = new JLabel(NbBundle.getMessage(DataViewUI.class, "LBL_matchbox"));
matchBoxRow.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8));
toolbar.add(matchBoxRow);
@@ -411,14 +510,14 @@ private void processKeyEvents() {
{
MultiColPatternFilter filterP = new MultiColPatternFilter(rows);
filterP.setFilterStr(matchBoxField.getText(), LITERAL_FIND);
- table.setRowFilter(filterP);
+ ((DefaultRowSorter) table.getRowSorter()).setRowFilter(filterP);
}
}
private void initVerticalToolbar(ActionListener outputListener) {
- URL url = getClass().getResource(imgPrefix + "row_add.png"); // NOI18N
- insert = new JXButton(new ImageIcon(url));
+ URL url = getClass().getResource(IMG_PREFIX + "row_add.png"); // NOI18N
+ insert = new JButton(new ImageIcon(url));
insert.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_insert")+" (Alt+I)");
insert.setMnemonic('I');
insert.addActionListener(outputListener);
@@ -426,24 +525,24 @@ private void initVerticalToolbar(ActionListener outputListener) {
processButton(insert);
editButtons[0] = insert;
- url = getClass().getResource(imgPrefix + "row_delete.png"); // NOI18N
- deleteRow = new JXButton(new ImageIcon(url));
+ url = getClass().getResource(IMG_PREFIX + "row_delete.png"); // NOI18N
+ deleteRow = new JButton(new ImageIcon(url));
deleteRow.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_deleterow"));
deleteRow.addActionListener(outputListener);
deleteRow.setEnabled(false);
processButton(deleteRow);
editButtons[1] = deleteRow;
- url = getClass().getResource(imgPrefix + "row_commit.png"); // NOI18N
- commit = new JXButton(new ImageIcon(url));
+ url = getClass().getResource(IMG_PREFIX + "row_commit.png"); // NOI18N
+ commit = new JButton(new ImageIcon(url));
commit.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_commit_all"));
commit.addActionListener(outputListener);
commit.setEnabled(false);
processButton(commit);
editButtons[2] = commit;
- url = getClass().getResource(imgPrefix + "cancel_edits.png"); // NOI18N
- cancel = new JXButton(new ImageIcon(url));
+ url = getClass().getResource(IMG_PREFIX + "cancel_edits.png"); // NOI18N
+ cancel = new JButton(new ImageIcon(url));
cancel.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_cancel_edits_all"));
cancel.addActionListener(outputListener);
cancel.setEnabled(false);
@@ -451,8 +550,8 @@ private void initVerticalToolbar(ActionListener outputListener) {
editButtons[3] = cancel;
//add truncate button
- url = getClass().getResource(imgPrefix + "table_truncate.png"); // NOI18N
- truncateButton = new JXButton(new ImageIcon(url));
+ url = getClass().getResource(IMG_PREFIX + "table_truncate.png"); // NOI18N
+ truncateButton = new JButton(new ImageIcon(url));
truncateButton.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_truncate_table")+" (Alt+T)");
truncateButton.setMnemonic('T');
truncateButton.addActionListener(outputListener);
@@ -463,7 +562,7 @@ private void initVerticalToolbar(ActionListener outputListener) {
private JPanel initializeMainPanel(boolean nbOutputComponent) {
- JXPanel panel = new JXPanel();
+ JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/output/InsertRecordTableUI.java b/db.dataview/src/org/netbeans/modules/db/dataview/output/InsertRecordTableUI.java
index 5b7a9a7be..ea9d05ed8 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/output/InsertRecordTableUI.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/output/InsertRecordTableUI.java
@@ -21,8 +21,8 @@
import org.netbeans.modules.db.dataview.table.ResultSetJXTable;
import java.sql.Types;
import java.util.Arrays;
+import javax.swing.JTable;
import javax.swing.table.TableModel;
-import org.jdesktop.swingx.JXTable;
import org.netbeans.modules.db.dataview.meta.DBColumn;
/**
@@ -36,9 +36,9 @@
public void setModel(TableModel dataModel) {
super.setModel(dataModel);
if (dataModel.getColumnCount() < 7) {
- setAutoResizeMode(JXTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
+ setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
} else {
- setHorizontalScrollEnabled(true);
+ setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
}
}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/CellFocusCustomRenderer.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/CellFocusCustomRenderer.java
index a753b91f4..70e62e596 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/CellFocusCustomRenderer.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/CellFocusCustomRenderer.java
@@ -22,7 +22,6 @@
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
-import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer;
import org.netbeans.modules.db.dataview.util.ColorHelper;
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableDecorator.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableDecorator.java
index eb0eebbea..bb6688340 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableDecorator.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableDecorator.java
@@ -19,21 +19,22 @@
package org.netbeans.modules.db.dataview.table;
import java.awt.Color;
+import java.awt.Component;
import java.awt.Graphics;
import java.awt.Rectangle;
+import javax.swing.JTable;
import javax.swing.ListSelectionModel;
-import javax.swing.UIManager;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
-import org.jdesktop.swingx.JXTable;
import org.netbeans.modules.db.dataview.util.ColorHelper;
/**
*
* @author Ahimanikya Satapathy
*/
-public class JXTableDecorator extends JXTable {
+public class JXTableDecorator extends JTable {
public static final Color ROW_COLOR = ColorHelper.getTableBackground();
public static final Color ALTERNATE_ROW_COLOR = ColorHelper.getTableAltbackground();
@@ -105,4 +106,23 @@ protected void drawVerticalLines(Graphics g, final int rowCount, final int heigh
protected Color backgroundColorForRow(int row) {
return (row % 2 == 0) ? ResultSetJXTable.ROW_COLOR : ResultSetJXTable.ALTERNATE_ROW_COLOR;
}
+
+ @Override
+ public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
+ boolean selected = false;
+ for(int i: getSelectedRows()) {
+ if(row == i) {
+ selected = true;
+ break;
+ }
+ }
+ Component c = super.prepareRenderer(renderer, row, column);
+ if(selected) {
+ c.setBackground(getSelectionBackground());
+ } else {
+ c.setBackground(backgroundColorForRow(row));
+ }
+ return c;
+ }
+
}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableRowHeader.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableRowHeader.java
index 894c852aa..860004710 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableRowHeader.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/JXTableRowHeader.java
@@ -19,18 +19,19 @@
package org.netbeans.modules.db.dataview.table;
import java.awt.*;
+import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashSet;
import java.util.Set;
+import javax.swing.DefaultRowSorter;
import javax.swing.Icon;
import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.RowSorter;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-import javax.swing.border.CompoundBorder;
import javax.swing.event.RowSorterEvent;
import javax.swing.event.RowSorterListener;
import javax.swing.event.TableModelEvent;
@@ -40,11 +41,6 @@
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.border.IconBorder;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-import org.jdesktop.swingx.renderer.DefaultTableRenderer;
-import org.jdesktop.swingx.table.TableColumnExt;
import org.netbeans.modules.db.dataview.output.DataViewTableUIModel;
/**
@@ -60,11 +56,8 @@
private static class InternalTableColumnModel extends DefaultTableColumnModel {
public InternalTableColumnModel() {
- TableColumnExt col = new TableColumnExt(0, 75);
- col.setEditable(false);
+ TableColumn col = new TableColumn(0, 75);
col.setHeaderValue("#");
- col.setToolTipText("Row number");
- col.setSortable(false);
addColumn(col);
}
}
@@ -77,7 +70,7 @@ public InternalTableColumnModel() {
private TableModel backingTableModel;
private RowSorter<?> backingSorter;
private final Set<TableModelListener> listeners = new HashSet<>();
- private final JXTable backingTable;
+ private final JTable backingTable;
@Override
public void propertyChange(PropertyChangeEvent pce) {
@@ -87,6 +80,7 @@ public void propertyChange(PropertyChangeEvent pce) {
if (backingSorter != null) {
backingSorter.removeRowSorterListener(this);
}
+ backingSorter = null;
if (pce.getNewValue() != null) {
backingSorter = (RowSorter) pce.getNewValue();
backingSorter.addRowSorterListener(this);
@@ -105,8 +99,12 @@ public void propertyChange(PropertyChangeEvent pce) {
}
}
- public CountingTableModel(JXTable table) {
+ public CountingTableModel(JTable table) {
this.backingTable = table;
+ this.backingSorter = this.backingTable.getRowSorter();
+ if(this.backingSorter != null) {
+ this.backingSorter.addRowSorterListener(this);
+ }
backingTable.addPropertyChangeListener(this);
this.backingTableModel = table.getModel();
this.backingTableModel.addTableModelListener(this);
@@ -220,11 +218,11 @@ public JTableHeader getTableHeader() {
return header;
}
- private static final Icon rightArrow = new Icon() {
+ private static final Icon ICON_RIGHT_ARROW = new Icon() {
@Override
public int getIconWidth() {
- return 8;
+ return 10;
}
@Override
@@ -239,33 +237,72 @@ public void paintIcon(Component c, Graphics g, int x, int y) {
g.fillPolygon(new Polygon(new int[]{0, 5, 0}, new int[]{-5, 0, 5}, 3));
}
};
- private final IconBorder iconBorder = new IconBorder();
+
+ private static final Icon ICON_CLEAR = new Icon() {
+
+ @Override
+ public int getIconWidth() {
+ return 10;
+ }
- private class RowHeaderColumnRenderer extends DefaultTableRenderer {
+ @Override
+ public int getIconHeight() {
+ return 8;
+ }
@Override
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ }
+ };
+
+ private class RowHeaderColumnRenderer extends JPanel implements TableCellRenderer {
+
+ private final JLabel iconLabel = new JLabel(ICON_CLEAR);
+ private final JLabel textLabel = new JLabel("");
+
+ @SuppressWarnings("OverridableMethodCallInConstructor")
+ public RowHeaderColumnRenderer() {
+ super();
+
+ GridBagConstraints iconConstraints = new GridBagConstraints();
+ iconConstraints.anchor = GridBagConstraints.BASELINE_LEADING;
+ iconConstraints.fill = GridBagConstraints.NONE;
+ iconConstraints.weightx = 0;
+ iconConstraints.weighty = 0;
+
+ GridBagConstraints labelConstraints = new GridBagConstraints();
+ labelConstraints.anchor = GridBagConstraints.BASELINE_LEADING;
+ labelConstraints.fill = GridBagConstraints.HORIZONTAL;
+ labelConstraints.weightx = 1;
+ labelConstraints.weighty = 0;
+
+ this.setLayout(new GridBagLayout());
+ this.add(iconLabel, iconConstraints);
+ this.add(textLabel, labelConstraints);
+ }
+
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) {
- Component comp = super.getTableCellRendererComponent(table, value, isSelected,
- hasFocus, rowIndex, columnIndex);
-
- if (isSelected) {
- iconBorder.setIcon(rightArrow);
- Border origBorder = ((JComponent) comp).getBorder();
- Border border = new CompoundBorder(origBorder, iconBorder);
- ((JComponent) comp).setBorder(border);
- comp.setBackground(table.getSelectionBackground());
- comp.setForeground(table.getSelectionForeground());
+ textLabel.setText(value == null ? "" : value.toString());
+ if(isSelected) {
+ iconLabel.setIcon(ICON_RIGHT_ARROW);
+ this.setBackground(table.getSelectionBackground());
+ this.setForeground(table.getSelectionForeground());
+ } else {
+ iconLabel.setIcon(ICON_CLEAR);
+ this.setBackground(table.getBackground());
+ this.setForeground(table.getForeground());
}
- return comp;
+ return this;
}
}
/**
* The headerTable used to create the row header column.
*/
private final CountingTableModel ctm;
- private final JXTable headerTable;
- private final JXTable backingTable;
+ private final JTable headerTable;
+ private final JTable backingTable;
/**
* Create a row header from the given {@code JTable}. This row header will
@@ -274,7 +311,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
*
* @param table the table for which to produce a row header.
*/
- public JXTableRowHeader(JXTable table) {
+ public JXTableRowHeader(JTable table) {
assert table != null : "JXTableRowHeader needs to be instanciated with a JXTable";
this.backingTable = table;
@@ -293,12 +330,22 @@ public JXTableRowHeader(JXTable table) {
this.headerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
this.headerTable.getTableHeader().setReorderingAllowed(false);
this.headerTable.getTableHeader().setResizingAllowed(false);
+ this.headerTable.getTableHeader().setToolTipText("Row number");
+ this.headerTable.getTableHeader().addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ RowSorter sorter = backingTable.getRowSorter();
+ if(sorter instanceof DefaultRowSorter) {
+ ((DefaultRowSorter) sorter).setSortKeys(null);
+ }
+ }
+ });
add(this.headerTable);
TableColumn column = this.headerTable.getColumnModel().getColumn(0);
// pack before setting preferred width.
- this.headerTable.packAll();
+ this.headerTable.doLayout();
TableCellRenderer defaultRenderer = createDefaultRenderer();
@@ -311,11 +358,8 @@ public JXTableRowHeader(JXTable table) {
column.getPreferredWidth(), 0));
this.headerTable.setInheritsPopupMenu(true);
- this.headerTable.setShowGrid(true, true);
+ this.headerTable.setShowGrid(true);
this.headerTable.setGridColor(ResultSetJXTable.GRID_COLOR);
- this.headerTable.setHighlighters(
- HighlighterFactory.createAlternateStriping(
- ResultSetJXTable.ROW_COLOR, ResultSetJXTable.ALTERNATE_ROW_COLOR));
}
/**
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetCellRenderer.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetCellRenderer.java
index 4a9b77067..c9da3764d 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetCellRenderer.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetCellRenderer.java
@@ -25,54 +25,43 @@
import java.sql.Blob;
import java.sql.Clob;
import java.text.SimpleDateFormat;
+import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTable;
-import javax.swing.UIManager;
+import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
-import org.jdesktop.swingx.renderer.*;
import org.netbeans.modules.db.dataview.output.SQLConstant;
import org.netbeans.modules.db.dataview.util.ColorHelper;
import org.netbeans.modules.db.dataview.util.DataViewUtils;
+import org.netbeans.modules.db.dataview.util.DateType;
+import org.netbeans.modules.db.dataview.util.FormatStringValue;
import org.netbeans.modules.db.dataview.util.LobHelper;
+import org.netbeans.modules.db.dataview.util.StringValue;
import org.netbeans.modules.db.dataview.util.TimeType;
import org.netbeans.modules.db.dataview.util.TimestampType;
/**
* @author Ahimanikya Satapathy
*/
-public class ResultSetCellRenderer extends DefaultTableRenderer {
+public class ResultSetCellRenderer extends DefaultTableCellRenderer {
- protected final static FormatStringValue DATETIME_TO_STRING = new FormatStringValue() {
-
- @Override
- public String getString(Object value) {
- if (format == null) {
- format = new SimpleDateFormat (TimestampType.DEFAULT_FORMAT_PATTERN);
- }
- return super.getString(value);
- }
- };
- protected final static FormatStringValue TIME_TO_STRING = new FormatStringValue() {
-
- @Override
- public String getString(Object value) {
- if (format == null) {
- format = new SimpleDateFormat (TimeType.DEFAULT_FOMAT_PATTERN);
- }
- return super.getString(value);
- }
- };
+ protected final static FormatStringValue DATETIME_TO_STRING = new FormatStringValue(new SimpleDateFormat (TimestampType.DEFAULT_FORMAT_PATTERN));
+ protected final static FormatStringValue TIME_TO_STRING = new FormatStringValue(new SimpleDateFormat (TimeType.DEFAULT_FOMAT_PATTERN));
+ protected final static FormatStringValue Date_TO_STRING = new FormatStringValue(new SimpleDateFormat (DateType.DEFAULT_FOMAT_PATTERN));
+
private final TableCellRenderer NULL_RENDERER = new NullObjectCellRenderer();
private final TableCellRenderer DEFAULT_RENDERER = new SQLConstantsCellRenderer();
- private final TableCellRenderer NUMNBER_RENDERER = new NumberObjectCellRenderer();
+ private final TableCellRenderer NUMBER_RENDERER = new NumberObjectCellRenderer();
private final TableCellRenderer BOOLEAN_RENDERER = new BooleanCellRenderer();
private final TableCellRenderer CELL_FOCUS_RENDERER = new CellFocusCustomRenderer();
private final TableCellRenderer BLOB_RENDERER = new BlobCellRenderer();
private final TableCellRenderer CLOB_RENDERER = new ClobCellRenderer();
+ private StringValue stringValue = null;
+
public ResultSetCellRenderer() {
- super(new StringValue() {
+ this(new StringValue() {
@Override
public String getString(Object o) {
@@ -81,16 +70,14 @@ public String getString(Object o) {
});
}
- public ResultSetCellRenderer(ComponentProvider<? extends JComponent> componentProvider) {
- super(componentProvider);
- }
-
- public ResultSetCellRenderer(StringValue converter, int alignment) {
- super(converter, alignment);
- }
-
public ResultSetCellRenderer(StringValue converter) {
- super(converter, JLabel.LEADING);
+ super();
+ stringValue = converter;
+ }
+
+ public ResultSetCellRenderer(StringValue converter, float alignment) {
+ this(converter);
+ ((JLabel) this).setAlignmentX(alignment);
}
@Override
@@ -98,7 +85,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
if (null == value) {
return NULL_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
} else if (value instanceof Number) {
- return NUMNBER_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ return NUMBER_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
} else if (DataViewUtils.isSQLConstantString(value, null)) {
Component c = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setTableCellToolTip(c, value);
@@ -110,7 +97,10 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
} else if (value instanceof Clob) {
return CLOB_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
} else {
- Component c = CELL_FOCUS_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if(stringValue != null) {
+ value = stringValue.getString(value);
+ }
+ Component c = CELL_FOCUS_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setTableCellToolTip(c, value);
return c;
}
@@ -144,22 +134,18 @@ protected void setTableCellToolTip(Component c, Object value) {
class BooleanCellRenderer extends CellFocusCustomRenderer {
- private JRendererCheckBox cb;
+ private JCheckBox cb;
public BooleanCellRenderer() {
super();
- cb = new JRendererCheckBox();
+ cb = new JCheckBox();
+ cb.setOpaque(true);
cb.setHorizontalAlignment(0);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
cb.setSelected((Boolean) value);
- if (!isSelected) {
- cb.setBackground(table.getBackground());
- } else {
- cb.setBackground(table.getSelectionBackground());
- }
return cb;
}
}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetJXTable.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetJXTable.java
index b88707047..781a31eb5 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetJXTable.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetJXTable.java
@@ -31,29 +31,22 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.Action;
-import javax.swing.DefaultRowSorter;
+import javax.swing.JCheckBox;
import javax.swing.JComponent;
-import javax.swing.JLabel;
+import javax.swing.JTable;
import javax.swing.JTextField;
-import javax.swing.RowFilter;
-import javax.swing.RowSorter;
import javax.swing.TransferHandler;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.plaf.UIResource;
import javax.swing.table.*;
-import org.jdesktop.swingx.JXTableHeader;
-import org.jdesktop.swingx.decorator.ColorHighlighter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-import org.jdesktop.swingx.renderer.CheckBoxProvider;
-import org.jdesktop.swingx.renderer.JRendererCheckBox;
-import org.jdesktop.swingx.renderer.StringValues;
import org.netbeans.modules.db.dataview.meta.DBColumn;
import org.netbeans.modules.db.dataview.table.celleditor.*;
import org.netbeans.modules.db.dataview.util.BinaryToStringConverter;
@@ -79,7 +72,11 @@
private static final DateFormat timestampFormat = new SimpleDateFormat(TimestampType.DEFAULT_FORMAT_PATTERN);
private final int multiplier;
+
+ private final StringFallbackRowSorter sorter = new StringFallbackRowSorter(null);
+ private Set<Integer> visibleColumns = new HashSet<>();
+
// If structure changes, enforce relayout
private final TableModelListener dataExchangedListener = new TableModelListener() {
@Override
@@ -92,20 +89,15 @@ public void tableChanged(TableModelEvent e) {
@SuppressWarnings("OverridableMethodCallInConstructor")
public ResultSetJXTable() {
+ this.setRowSorter(sorter);
this.setAutoCreateColumnsFromModel(false);
this.setTransferHandler(new TableTransferHandler());
- setShowGrid(true, true);
+ setShowGrid(true);
setGridColor(GRID_COLOR);
getTableHeader().setReorderingAllowed(false);
- setColumnControlVisible(true);
- getColumnControl().setToolTipText(org.openide.util.NbBundle.getMessage(ResultSetJXTable.class, "ResultSetJXTable.columnControl.tooltip"));
setFillsViewportHeight(true);
- setHorizontalScrollEnabled(true);
-
- setHighlighters(HighlighterFactory.createAlternateStriping(ROW_COLOR, ALTERNATE_ROW_COLOR));
- addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, ROLLOVER_ROW_COLOR, null));
setDefaultCellRenderers();
setDefaultCellEditors();
@@ -120,6 +112,7 @@ public ResultSetJXTable() {
getActionMap().put("selectNextPreviousCell", new EditingAwareAction(getActionMap().get("selectPreviousRowCell")));
setSurrendersFocusOnKeystroke(true);
+ setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
}
@Override
@@ -128,26 +121,11 @@ protected JTableHeader createDefaultTableHeader() {
}
@Override
- protected RowSorter<? extends TableModel> createDefaultRowSorter() {
- return new StringFallbackRowSorter(this.getModel());
- }
-
- @Override
protected TableModel createDefaultDataModel() {
return new ResultSetTableModel(new DBColumn[0]);
}
@Override
- @SuppressWarnings("unchecked")
- public <R extends TableModel> void setRowFilter(RowFilter<? super R, ? super Integer> filter) {
- if(getRowSorter() instanceof DefaultRowSorter) {
- ((DefaultRowSorter) getRowSorter()).setRowFilter(filter);
- } else {
- super.setRowFilter(filter);
- }
- }
-
- @Override
public void setModel(TableModel dataModel) {
if(! (dataModel instanceof ResultSetTableModel)) {
throw new IllegalArgumentException(
@@ -158,11 +136,30 @@ public void setModel(TableModel dataModel) {
if(getModel() != null) {
getModel().removeTableModelListener(dataExchangedListener);
}
+ if(sorter != null) {
+ sorter.setModel((ResultSetTableModel) dataModel);
+ }
super.setModel(dataModel);
+ if(visibleColumns != null) {
+ visibleColumns.clear();
+ for(int i = 0; i < dataModel.getColumnCount(); i++) {
+ visibleColumns.add(i);
+ }
+ }
updateHeader();
dataModel.addTableModelListener(dataExchangedListener);
}
+ public Set<Integer> getVisibleColumns() {
+ return new HashSet<>(visibleColumns);
+ }
+
+ public void setVisibleColumns(Set<Integer> visibleColumns) {
+ this.visibleColumns.addAll(visibleColumns);
+ this.visibleColumns.retainAll(visibleColumns);
+ updateHeader();
+ }
+
@Override
public ResultSetTableModel getModel() {
return (ResultSetTableModel) super.getModel();
@@ -172,9 +169,9 @@ public ResultSetTableModel getModel() {
protected void setDefaultCellRenderers() {
setDefaultRenderer(Object.class, new ResultSetCellRenderer());
setDefaultRenderer(String.class, new ResultSetCellRenderer());
- setDefaultRenderer(Number.class, new ResultSetCellRenderer(StringValues.NUMBER_TO_STRING, JLabel.RIGHT));
- setDefaultRenderer(Boolean.class, new ResultSetCellRenderer(new CheckBoxProvider()));
- setDefaultRenderer(java.sql.Date.class, new ResultSetCellRenderer(StringValues.DATE_TO_STRING));
+ setDefaultRenderer(Number.class, new ResultSetCellRenderer());
+ setDefaultRenderer(Boolean.class, new BooleanCellRenderer());
+ setDefaultRenderer(java.sql.Date.class, new ResultSetCellRenderer(ResultSetCellRenderer.Date_TO_STRING));
setDefaultRenderer(java.sql.Time.class, new ResultSetCellRenderer(ResultSetCellRenderer.TIME_TO_STRING));
setDefaultRenderer(java.sql.Timestamp.class, new ResultSetCellRenderer(ResultSetCellRenderer.DATETIME_TO_STRING));
setDefaultRenderer(java.util.Date.class, new ResultSetCellRenderer(ResultSetCellRenderer.DATETIME_TO_STRING));
@@ -196,7 +193,7 @@ protected void setDefaultCellEditors() {
txtFld.addKeyListener(kl);
setDefaultEditor(Number.class, new NumberFieldEditor(numFld));
- JRendererCheckBox b = new JRendererCheckBox();
+ JCheckBox b = new JCheckBox();
b.addKeyListener(kl);
setDefaultEditor(Boolean.class, new BooleanTableCellEditor(b));
@@ -242,7 +239,11 @@ protected void updateHeader() {
List<Integer> columnWidthList = getColumnWidthList(columns);
for (int i = 0; i < columns.length; i++) {
- TableColumn tc = getColumnFactory().createTableColumn(i);
+ if(! (visibleColumns.isEmpty() || visibleColumns.contains(i))) {
+ continue;
+ }
+
+ TableColumn tc = new TableColumn(i);
tc.setPreferredWidth(columnWidthList.get(i));
DBColumn col = columns[i];
@@ -426,7 +427,7 @@ protected void copyRowValues(boolean withHeader) {
}
// This is mainly used for set Tooltip for column headers
- private class JTableHeaderImpl extends JXTableHeader {
+ private class JTableHeaderImpl extends JTableHeader {
public JTableHeaderImpl(TableColumnModel cm) {
super(cm);
@@ -437,7 +438,6 @@ public String getToolTipText(MouseEvent e) {
return getColumnToolTipText(e);
}
- @Override
protected String getColumnToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint();
int index = columnModel.getColumnIndexAtX(p.x);
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableCellEditor.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableCellEditor.java
index ff724a8ff..110a54d5a 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableCellEditor.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/ResultSetTableCellEditor.java
@@ -22,11 +22,11 @@
import java.awt.event.MouseEvent;
import java.util.EventObject;
import javax.swing.DefaultCellEditor;
+import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.text.DefaultCaret;
-import org.jdesktop.swingx.renderer.JRendererCheckBox;
import org.netbeans.modules.db.dataview.util.DataViewUtils;
public class ResultSetTableCellEditor extends DefaultCellEditor {
@@ -84,14 +84,14 @@ public Component getTableCellEditorComponent(JTable table, Object value, boolean
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
- public ResultSetTableCellEditor(final JRendererCheckBox checkBox) {
+ public ResultSetTableCellEditor(final JCheckBox checkBox) {
super(checkBox);
delegate = new EditorDelegate() {
@Override
public void setValue(Object value) {
val = value;
- checkBox.setSelected((value != null) ? checkBox.isSelected() : false);
+ checkBox.setSelected((value != null) ? ((Boolean) value) : false);
}
@Override
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/StringFallbackRowSorter.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/StringFallbackRowSorter.java
index 4e8a69727..28a583ed0 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/StringFallbackRowSorter.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/StringFallbackRowSorter.java
@@ -21,8 +21,7 @@
import java.sql.Blob;
import java.sql.Clob;
import java.util.Comparator;
-import javax.swing.table.TableModel;
-import org.jdesktop.swingx.sort.TableSortController;
+import javax.swing.table.TableRowSorter;
import org.netbeans.modules.db.dataview.util.LobHelper;
/**
@@ -33,8 +32,8 @@
* ResultSetJXTable are sorted and different types are present (for example
* string and date)
*/
-public class StringFallbackRowSorter extends TableSortController<TableModel> {
- public StringFallbackRowSorter(TableModel model) {
+public class StringFallbackRowSorter extends TableRowSorter<ResultSetTableModel> {
+ public StringFallbackRowSorter(ResultSetTableModel model) {
super(model);
}
@@ -85,4 +84,4 @@ public int compare(Object t, Object t1) {
public boolean equals(Object o) {
return delegate.equals(o);
}
-}
\ No newline at end of file
+}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BooleanTableCellEditor.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BooleanTableCellEditor.java
index 3c9bd0200..cd1a4f36b 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BooleanTableCellEditor.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/BooleanTableCellEditor.java
@@ -21,15 +21,16 @@
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
import java.awt.Component;
import javax.swing.BorderFactory;
+import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
-import org.jdesktop.swingx.renderer.JRendererCheckBox;
public class BooleanTableCellEditor extends ResultSetTableCellEditor implements TableCellEditor {
- public BooleanTableCellEditor(JRendererCheckBox cb) {
+ public BooleanTableCellEditor(JCheckBox cb) {
super(cb);
+ cb.setOpaque(true);
cb.setHorizontalAlignment(0);
}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/DateTimePickerCellEditor.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/DateTimePickerCellEditor.java
index f85e83a92..e4565e323 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/DateTimePickerCellEditor.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/DateTimePickerCellEditor.java
@@ -19,33 +19,23 @@
package org.netbeans.modules.db.dataview.table.celleditor;
import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.EventObject;
-import javax.swing.AbstractCellEditor;
+import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JTable;
-import javax.swing.UIManager;
-import javax.swing.table.TableCellEditor;
-import org.jdesktop.swingx.JXDatePicker;
+import javax.swing.JTextField;
+import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
import org.netbeans.modules.db.dataview.util.DataViewUtils;
-import org.netbeans.modules.db.dataview.util.JXDateTimePicker;
import org.netbeans.modules.db.dataview.util.TimestampType;
-public class DateTimePickerCellEditor extends AbstractCellEditor implements TableCellEditor {
+public class DateTimePickerCellEditor extends ResultSetTableCellEditor {
- private boolean editable = true;
- private JXDateTimePicker datePicker;
+ private Timestamp initialValue;
private DateFormat dateFormat;
- private ActionListener pickerActionListener;
- private boolean ignoreAction;
- private JTable table;
public DateTimePickerCellEditor() {
this(new SimpleDateFormat (TimestampType.DEFAULT_FORMAT_PATTERN));
@@ -58,56 +48,30 @@ public DateTimePickerCellEditor() {
* @param dateFormat
*/
public DateTimePickerCellEditor(DateFormat dateFormat) {
-
- // JW: the copy is used to synchronize .. can
- // we use something else?
+ super(new JTextField());
this.dateFormat = dateFormat != null ? dateFormat : new SimpleDateFormat (TimestampType.DEFAULT_FORMAT_PATTERN);
- datePicker = new JXDateTimePicker();
- // default border crushes the editor/combo
- datePicker.getEditor().setBorder(
- BorderFactory.createEmptyBorder(0, 1, 0, 1));
- // should be fixed by j2se 6.0
- datePicker.setFont(UIManager.getDefaults().getFont("TextField.font"));
- if (dateFormat != null) {
- datePicker.setFormats(dateFormat);
- }
- datePicker.addActionListener(getPickerActionListener());
}
@Override
public Timestamp getCellEditorValue() {
- return datePicker.getDateTime();
- }
-
- @Override
- public boolean isCellEditable(EventObject anEvent) {
- if (anEvent instanceof MouseEvent) {
- return ((MouseEvent) anEvent).getClickCount() >= 2;
+ Date parsedTimestamp = TimestampType.doParse((String) super.getCellEditorValue());
+ if(parsedTimestamp != null) {
+ return new Timestamp(parsedTimestamp.getTime());
+ } else {
+ return initialValue;
}
- return super.isCellEditable(anEvent);
}
-
+
@Override
- public boolean stopCellEditing() {
- ignoreAction = true;
- boolean canCommit = commitChange();
- ignoreAction = false;
- if (canCommit) {
- datePicker.setDateTime(null);
- return super.stopCellEditing();
+ public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) {
+ Component c = super.getTableCellEditorComponent(table, "", isSelected, row, column);
+ JTextField jtf = (JTextField) c;
+ initialValue = getValueAsTimestamp(value);
+ jtf.setText(dateFormat.format(initialValue));
+ if (suppressEditorBorder) {
+ jtf.setBorder(BorderFactory.createEmptyBorder());
}
- return false;
- }
-
- @Override
- public Component getTableCellEditorComponent(final JTable table, Object value,
- boolean isSelected, int row, int column) {
- this.table = table;
- ignoreAction = true;
- datePicker.setDateTime(getValueAsTimestamp(value));
-
- ignoreAction = false;
- return datePicker;
+ return c;
}
protected Timestamp getValueAsTimestamp(Object value) {
@@ -135,56 +99,8 @@ protected Timestamp getValueAsTimestamp(Object value) {
protected boolean isEmpty(Object value) {
return value == null || value instanceof String && ((String) value).length() == 0;
}
-
- protected boolean commitChange() {
- try {
- datePicker.commitEdit();
- return true;
- } catch (ParseException e) {
- }
- return false;
- }
-
- public DateFormat[] getFormats() {
- return datePicker.getFormats();
- }
-
- public void setFormats(DateFormat... formats) {
- datePicker.setFormats(formats);
- }
-
- private ActionListener getPickerActionListener() {
- if (pickerActionListener == null) {
- pickerActionListener = createPickerActionListener();
- }
- return pickerActionListener;
- }
-
- protected ActionListener createPickerActionListener() {
- ActionListener l = new ActionListener() {
-
- @Override
- public void actionPerformed(final ActionEvent e) {
- // avoid duplicate trigger from
- // commit in stopCellEditing
- if (ignoreAction) {
- return;
- }
- terminateEdit(e);
- }
-
- private void terminateEdit(final ActionEvent e) {
- if ((e != null) && (JXDatePicker.COMMIT_KEY.equals(e.getActionCommand()))) {
- stopCellEditing();
- } else {
- cancelCellEditing();
- }
- }
- };
- return l;
- }
-
+
public void addKeyListener(KeyListener kl) {
- datePicker.addKeyListener(kl);
+ ((JTextField) getComponent()).addKeyListener(kl);
}
}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/StringTableCellEditor.java b/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/StringTableCellEditor.java
index b7bf28160..3b3a9f224 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/StringTableCellEditor.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/table/celleditor/StringTableCellEditor.java
@@ -29,8 +29,10 @@
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import javax.swing.BorderFactory;
+import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
+import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
@@ -39,14 +41,12 @@
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableModel;
import javax.swing.text.JTextComponent;
-import org.jdesktop.swingx.JXButton;
-import org.jdesktop.swingx.JXPanel;
import org.netbeans.modules.db.dataview.table.ResultSetTableCellEditor;
import org.openide.windows.WindowManager;
public class StringTableCellEditor extends ResultSetTableCellEditor implements TableCellEditor, ActionListener {
- private final JXButton customEditorButton = new JXButton("...");
+ private final JButton customEditorButton = new JButton("...");
private JTextComponent tc;
private TableModel tableModel;
private String columnName;
@@ -73,7 +73,7 @@ public Component getTableCellEditorComponent(final JTable table, Object value, b
this.modelColumn = table.convertColumnIndexToModel(column);
this.tc = c instanceof JTextComponent ? (JTextComponent) c : null;
- JXPanel panel = new JXPanel(new BorderLayout()) {
+ JPanel panel = new JPanel(new BorderLayout()) {
@Override
public void addNotify() {
super.addNotify();
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/BasicDateTimePickerUI.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/BasicDateTimePickerUI.java
deleted file mode 100644
index e059e469e..000000000
--- a/db.dataview/src/org/netbeans/modules/db/dataview/util/BasicDateTimePickerUI.java
+++ /dev/null
@@ -1,1635 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.modules.db.dataview.util;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.FontMetrics;
-import java.awt.Insets;
-import java.awt.KeyboardFocusManager;
-import java.awt.LayoutManager;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Calendar;
-
-import java.util.Locale;
-import java.util.TimeZone;
-import java.util.logging.Logger;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ActionMap;
-import javax.swing.Icon;
-import javax.swing.InputMap;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JFormattedTextField;
-import javax.swing.JPopupMenu;
-import javax.swing.KeyStroke;
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-import javax.swing.JFormattedTextField.AbstractFormatter;
-import javax.swing.JFormattedTextField.AbstractFormatterFactory;
-import javax.swing.border.Border;
-import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.UIResource;
-import javax.swing.text.DefaultFormatterFactory;
-import javax.swing.text.View;
-
-import org.jdesktop.swingx.JXMonthView;
-import org.jdesktop.swingx.SwingXUtilities;
-import org.jdesktop.swingx.calendar.CalendarUtils;
-import org.jdesktop.swingx.calendar.DatePickerFormatter;
-import org.jdesktop.swingx.calendar.DateSelectionModel;
-import org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource;
-import org.jdesktop.swingx.event.DateSelectionEvent;
-import org.jdesktop.swingx.event.DateSelectionListener;
-import org.jdesktop.swingx.event.DateSelectionEvent.EventType;
-
-
-/**
- * The basic implementation of a <code>DatePickerUI</code>.
- * <p>
- *
- *
- * @author Joshua Outwater
- * @author Jeanette Winzenburg
- */
-public class BasicDateTimePickerUI extends ComponentUI {
-
- @SuppressWarnings("all")
- private static final Logger LOG = Logger.getLogger(BasicDateTimePickerUI.class
- .getName());
-
- protected JXDateTimePicker datePicker;
- private JButton popupButton;
- private BasicDatePickerPopup popup;
- private Handler handler;
- /*
- * shared listeners
- */
- protected PropertyChangeListener propertyChangeListener;
- private FocusListener focusListener;
-
- /*
- * listener's for the arrow button
- */
- protected MouseListener mouseListener;
- protected MouseMotionListener mouseMotionListener;
-
- /*
- * listeners for the picker's editor
- */
- private ActionListener editorActionListener;
- private EditorCancelAction editorCancelAction;
- private PropertyChangeListener editorPropertyListener;
-
- /**
- * listeners for the picker's monthview
- */
- private DateSelectionListener monthViewSelectionListener;
- private ActionListener monthViewActionListener;
- private PropertyChangeListener monthViewPropertyListener;
-
- private PopupRemover popupRemover;
-
-
- @SuppressWarnings({"UnusedDeclaration"})
- public static ComponentUI createUI(JComponent c) {
- return new BasicDateTimePickerUI();
- }
-
- @Override
- public void installUI(JComponent c) {
- datePicker = (JXDateTimePicker)c;
- datePicker.setLayout(createLayoutManager());
- installComponents();
- installDefaults();
- installKeyboardActions();
- installListeners();
- }
-
- @Override
- public void uninstallUI(JComponent c) {
- uninstallListeners();
- uninstallKeyboardActions();
- uninstallDefaults();
- uninstallComponents();
- datePicker.setLayout(null);
- datePicker = null;
- }
-
- protected void installComponents() {
-
- JFormattedTextField editor = datePicker.getEditor();
- if (editor == null || editor instanceof UIResource) {
- DateFormat[] formats = getCustomFormats(editor);
- // we are not yet listening ...
- datePicker.setEditor(createEditor());
- if (formats != null) {
- datePicker.setFormats(formats);
- }
- }
- updateFromEditorChanged(null, false);
-
- popupButton = createPopupButton();
- if (popupButton != null) {
- popupButton.putClientProperty("doNotCancelPopup",
- createDoNotCancelPopupClientProperty());
- datePicker.add(popupButton);
- }
- updateChildLocale(datePicker.getLocale());
-
- }
-
- /**
- * Checks and returns custom formats on the editor, if any.
- *
- * @param editor the editor to check
- * @return the custom formats uses in the editor or null if it had
- * used defaults as defined in the datepicker properties
- */
- private DateFormat[] getCustomFormats(JFormattedTextField editor) {
- DateFormat[] formats = null;
- if (editor != null) {
- AbstractFormatterFactory factory = editor.getFormatterFactory();
- if (factory != null) {
- AbstractFormatter formatter = factory.getFormatter(editor);
- if (!(formatter instanceof DatePickerFormatterUIResource)) {
- formats = ((DatePickerFormatter) formatter).getFormats();
- }
- }
-
- }
- return formats;
- }
-
- protected void uninstallComponents() {
- JFormattedTextField editor = datePicker.getEditor();
- if (editor != null) {
- datePicker.remove(editor);
- }
-
- if (popupButton != null) {
- datePicker.remove(popupButton);
- popupButton = null;
- }
- }
-
- protected void installDefaults() {
-
- }
-
- protected void uninstallDefaults() {
-
- }
-
- protected void installKeyboardActions() {
- // install picker's actions
- ActionMap pickerMap = datePicker.getActionMap();
- pickerMap.put(JXDateTimePicker.CANCEL_KEY, createCancelAction());
- pickerMap.put(JXDateTimePicker.COMMIT_KEY, createCommitAction());
- pickerMap.put(JXDateTimePicker.HOME_NAVIGATE_KEY, createHomeAction(false));
- pickerMap.put(JXDateTimePicker.HOME_COMMIT_KEY, createHomeAction(true));
- TogglePopupAction popupAction = createTogglePopupAction();
- pickerMap.put("TOGGLE_POPUP", popupAction);
-
- InputMap pickerInputMap = datePicker.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
- pickerInputMap.put(KeyStroke.getKeyStroke("ENTER"), JXDateTimePicker.COMMIT_KEY);
- pickerInputMap.put(KeyStroke.getKeyStroke("ESCAPE"), JXDateTimePicker.CANCEL_KEY);
- // PENDING: get from LF
- pickerInputMap.put(KeyStroke.getKeyStroke("F5"), JXDateTimePicker.HOME_COMMIT_KEY);
- pickerInputMap.put(KeyStroke.getKeyStroke("shift F5"), JXDateTimePicker.HOME_NAVIGATE_KEY);
- pickerInputMap.put(KeyStroke.getKeyStroke("SPACE"), "TOGGLE_POPUP");
-
- installLinkPanelKeyboardActions();
- }
-
- protected void uninstallKeyboardActions() {
- uninstallLinkPanelKeyboardActions(datePicker.getLinkPanel());
- }
-
-
- /**
- * Installs actions and key bindings on the datePicker's linkPanel. Does
- * nothing if the linkPanel is null.
- *
- * PRE: keybindings installed on picker.
- */
- protected void installLinkPanelKeyboardActions() {
- if (datePicker.getLinkPanel() == null) {
- return;
- }
- ActionMap map = datePicker.getLinkPanel().getActionMap();
- map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get(
- JXDateTimePicker.HOME_COMMIT_KEY));
- map.put(JXDateTimePicker.HOME_NAVIGATE_KEY, datePicker.getActionMap().get(
- JXDateTimePicker.HOME_NAVIGATE_KEY));
- InputMap inputMap = datePicker.getLinkPanel().getInputMap(
- JComponent.WHEN_IN_FOCUSED_WINDOW);
- // PENDING: get from LF
- inputMap.put(KeyStroke.getKeyStroke("F5"),
- JXDateTimePicker.HOME_COMMIT_KEY);
- inputMap.put(KeyStroke.getKeyStroke("shift F5"),
- JXDateTimePicker.HOME_NAVIGATE_KEY);
- }
-
-
- /**
- * Uninstalls actions and key bindings from linkPanel. Does nothing if the
- * linkPanel is null.
- *
- * @param panel the component to uninstall
- *
- */
- protected void uninstallLinkPanelKeyboardActions(JComponent panel) {
- if (panel == null) {
- return;
- }
- ActionMap map = panel.getActionMap();
- map.remove(JXDateTimePicker.HOME_COMMIT_KEY);
- map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY);
- InputMap inputMap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
- // PENDING: get from LF
- inputMap.remove(KeyStroke.getKeyStroke("F5"));
- inputMap.remove(KeyStroke.getKeyStroke("shift F5"));
-
- }
-
- /**
- * Creates and installs all listeners to all components.
- *
- */
- protected void installListeners() {
- /*
- * create the listeners.
- */
- // propertyListener for datePicker
- propertyChangeListener = createPropertyChangeListener();
-
- // mouseListener (for popup button only) ?
- mouseListener = createMouseListener();
- mouseMotionListener = createMouseMotionListener();
-
- // shared focuslistener (installed to picker and editor)
- focusListener = createFocusListener();
-
- // editor related listeners
- editorActionListener = createEditorActionListener();
- editorPropertyListener = createEditorPropertyListener();
-
- // montheView related listeners
- monthViewSelectionListener = createMonthViewSelectionListener();
- monthViewActionListener = createMonthViewActionListener();
- monthViewPropertyListener = createMonthViewPropertyListener();
-
- popupRemover = new PopupRemover();
- /*
- * install the listeners
- */
- // picker
- datePicker.addPropertyChangeListener(propertyChangeListener);
- datePicker.addFocusListener(focusListener);
-
- if (popupButton != null) {
- // JW: which property do we want to monitor?
- popupButton.addPropertyChangeListener(propertyChangeListener);
- popupButton.addMouseListener(mouseListener);
- popupButton.addMouseMotionListener(mouseMotionListener);
- }
-
- updateEditorListeners(null);
- // JW the following does more than installing the listeners ..
- // synchs properties of datepicker to monthView's
- // prepares monthview for usage in popup
- // synch the date
- // Relies on being the last thing done in the install ..
- //
- updateFromMonthViewChanged(null);
- }
- /**
- * Uninstalls and nulls all listeners which had been installed
- * by this delegate.
- *
- */
- protected void uninstallListeners() {
- // datePicker
- datePicker.removePropertyChangeListener(propertyChangeListener);
- datePicker.removeFocusListener(focusListener);
-
- // monthView
- datePicker.getMonthView().getSelectionModel().removeDateSelectionListener(monthViewSelectionListener);
- datePicker.getMonthView().removeActionListener(monthViewActionListener);
- datePicker.getMonthView().removePropertyChangeListener(propertyChangeListener);
-
- // JW: when can that be null?
- // maybe in the very beginning? if some code calls ui.uninstall
- // before ui.install? The editor is created by the ui.
- if (datePicker.getEditor() != null) {
- uninstallEditorListeners(datePicker.getEditor());
- }
- if (popupButton != null) {
- popupButton.removePropertyChangeListener(propertyChangeListener);
- popupButton.removeMouseListener(mouseListener);
- popupButton.removeMouseMotionListener(mouseMotionListener);
- }
-
- popupRemover.unload();
-
- popupRemover = null;
- propertyChangeListener = null;
- mouseListener = null;
- mouseMotionListener = null;
-
- editorActionListener = null;
- editorPropertyListener = null;
-
- monthViewSelectionListener = null;
- monthViewActionListener = null;
- monthViewPropertyListener = null;
-
- handler = null;
- }
-
-// --------------------- wiring listeners
- /**
- * Wires the picker's monthView related listening. Removes all
- * listeners from the given old view and adds the listeners to
- * the current monthView. <p>
- *
- * @param oldMonthView
- */
- protected void updateMonthViewListeners(JXMonthView oldMonthView) {
- DateSelectionModel oldModel = null;
- if (oldMonthView != null) {
- oldMonthView.removePropertyChangeListener(monthViewPropertyListener);
- oldMonthView.removeActionListener(monthViewActionListener);
- oldModel = oldMonthView.getSelectionModel();
- }
- datePicker.getMonthView().addPropertyChangeListener(monthViewPropertyListener);
- datePicker.getMonthView().addActionListener(monthViewActionListener);
- updateSelectionModelListeners(oldModel);
- }
-
-
- /**
- * Wires the picker's editor related listening and actions. Removes
- * listeners/actions from the old editor and adds them to
- * the new editor. <p>
- *
- * @param oldEditor the pickers editor before the change
- */
- protected void updateEditorListeners(JFormattedTextField oldEditor) {
- if (oldEditor != null) {
- uninstallEditorListeners(oldEditor);
- }
- datePicker.getEditor().addPropertyChangeListener(editorPropertyListener);
- datePicker.getEditor().addActionListener(editorActionListener);
- datePicker.getEditor().addFocusListener(focusListener);
- editorCancelAction = new EditorCancelAction(datePicker.getEditor());
- }
-
- /**
- * Uninstalls all listeners and actions which have been installed
- * by this delegate from the given editor.
- *
- * @param oldEditor the editor to uninstall.
- */
- private void uninstallEditorListeners(JFormattedTextField oldEditor) {
- oldEditor.removePropertyChangeListener(editorPropertyListener);
- oldEditor.removeActionListener(editorActionListener);
- oldEditor.removeFocusListener(focusListener);
- if (editorCancelAction != null) {
- editorCancelAction.uninstall();
- editorCancelAction = null;
- }
- }
-
- /**
- * Wires monthView's selection model listening. Removes the
- * selection listener from the old model and add to the new model.
- *
- * @param oldModel the dateSelectionModel before the change, may be null.
- */
- protected void updateSelectionModelListeners(DateSelectionModel oldModel) {
- if (oldModel != null) {
- oldModel.removeDateSelectionListener(monthViewSelectionListener);
- }
- datePicker.getMonthView().getSelectionModel()
- .addDateSelectionListener(monthViewSelectionListener);
-
- }
-
-
- // ---------------- component creation
- /**
- * Creates the editor used to edit the date selection. The editor is
- * configured with the default DatePickerFormatter marked as UIResource.
- *
- * @return an instance of a JFormattedTextField
- */
- protected JFormattedTextField createEditor() {
- JFormattedTextField f = new DefaultEditor(
- new DatePickerFormatterUIResource(datePicker.getLocale()));
- f.setName("dateField");
- // this produces a fixed pref widths, looking a bit funny
- // int columns = UIManagerExt.getInt("JXDateTimePicker.numColumns", null);
- // if (columns > 0) {
- // f.setColumns(columns);
- // }
- // that's always 0 as it comes from the resourcebundle
- // f.setColumns(UIManager.getInt("JXDateTimePicker.numColumns"));
- Border border = UIManager.getBorder("JXDateTimePicker.border");
- if (border != null) {
- f.setBorder(border);
- }
- return f;
- }
-
- protected JButton createPopupButton() {
- JButton b = new JButton();
- b.setName("popupButton");
- b.setRolloverEnabled(false);
- b.setMargin(new Insets(0, 3, 0, 3));
-
- Icon icon = UIManager.getIcon("JXDateTimePicker.arrowIcon");
- if (icon == null) {
- icon = (Icon)UIManager.get("Tree.expandedIcon");
- }
- b.setIcon(icon);
- b.setFocusable(false);
- return b;
- }
-
- private class DefaultEditor extends JFormattedTextField implements UIResource {
-
- private Dimension prefSizeCache;
- private int prefEmptyInset;
-
-
- public DefaultEditor(AbstractFormatter formatter) {
- super(formatter);
- }
-
-
- @Override
- public Dimension getPreferredSize() {
- Dimension preferredSize = super.getPreferredSize();
- if (getColumns() <= 0) {
- if (getValue() == null) {
- if (prefSizeCache != null) {
- preferredSize.width = prefSizeCache.width;
- preferredSize.height = prefSizeCache.height;
- } else {
- prefEmptyInset = preferredSize.width;
- preferredSize.width = prefEmptyInset + getNullWidth();
- }
- } else {
- preferredSize.width += Math.max(prefEmptyInset, 4);
- prefSizeCache = new Dimension(preferredSize);
- }
- }
- return preferredSize;
- }
-
-
- /**
- * @return
- */
- private int getNullWidth() {
- JFormattedTextField field = new JFormattedTextField(getFormatter());
- field.setMargin(getMargin());
- field.setBorder(getBorder());
- field.setFont(getFont());
- field.setValue(new Timestamp(System.currentTimeMillis()));
- return field.getPreferredSize().width;
- }
-
-
- }
-
-// ---------------- Layout
- /**
- * {@inheritDoc}
- */
- @Override
- public Dimension getMinimumSize(JComponent c) {
- return getPreferredSize(c);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Dimension getPreferredSize(JComponent c) {
- Dimension dim = getEditorPreferredSize();
- if (popupButton != null) {
- dim.width += popupButton.getPreferredSize().width;
- }
- Insets insets = datePicker.getInsets();
- dim.width += insets.left + insets.right;
- dim.height += insets.top + insets.bottom;
- return (Dimension)dim.clone();
- }
-
- /**
- * Returns a preferred size for the editor. If the selected date
- * is null, returns a reasonable minimal width. <p>
- *
- * PENDING: how to find the "reasonable" width is open to discussion.
- * This implementation creates another datepicker, feeds it with
- * the formats and asks its prefWidth. <p>
- *
- * That hack blows in some contexts (see Issue #763) - as a very quick
- * replacement create a editor only.
- *
- * PENDING: there's a resource property JXDateTimePicker.numColumns - why
- * don't we use it?
- *
- * @return the editor's preferred size
- */
- private Dimension getEditorPreferredSize() {
- Dimension dim = datePicker.getEditor().getPreferredSize();
- if (datePicker.getDateTime() == null) {
-// JFormattedTextField field = createEditor(new DatePickerFormatterUIResource(
-// datePicker.getFormats(),
-// datePicker.getLocale()));
-// field.setValue(new Date());
-// dim.width = Math.max(field.getPreferredSize().width, dim.width);
- // the editor tends to collapsing for empty values
- // JW: better do this in a custom editor?
- // seems to produce #763
-// JXDateTimePicker picker = new JXDateTimePicker(new Date());
-// picker.setFormats(datePicker.getFormats());
-// dim.width = picker.getEditor().getPreferredSize().width;
- }
- return dim;
- }
-
- public int getBaseline(int width, int height) {
- JFormattedTextField editor = datePicker.getEditor();
- View rootView = editor.getUI().getRootView(editor);
- if (rootView.getViewCount() > 0) {
- Insets insets = editor.getInsets();
- Insets insetsOut = datePicker.getInsets();
- int nh = height - insets.top - insets.bottom
- - insetsOut.top - insetsOut.bottom;
- int y = insets.top + insetsOut.top;
- View fieldView = rootView.getView(0);
- int vspan = (int) fieldView.getPreferredSpan(View.Y_AXIS);
- if (nh != vspan) {
- int slop = nh - vspan;
- y += slop / 2;
- }
- FontMetrics fm = editor.getFontMetrics(editor.getFont());
- y += fm.getAscent();
- return y;
- }
- return -1;
- }
-
-
-//------------------------------- controller methods/classes
-
-
- public Timestamp getSelectableDate(java.util.Date date) throws PropertyVetoException {
- java.util.Date cleaned = date == null ? null :
- datePicker.getMonthView().getSelectionModel().getNormalizedDate(date);
- if (CalendarUtils.areEqual(cleaned, datePicker.getDateTime())) {
- // one place to interrupt the update spiral
- throw new PropertyVetoException("date not selectable", null);
- }
-
- if (cleaned != null && datePicker.getMonthView().isUnselectableDate(cleaned)) {
- throw new PropertyVetoException("date not selectable", null);
- }
-
- if(date instanceof Timestamp) {
- return (Timestamp)date;
- }
- return new Timestamp(datePicker.getMonthView().getSelectionDate().getTime());
- }
-
-//-------------------- update methods called from listeners
- /**
- * Updates internals after picker's date property changed.
- */
- protected void updateFromDateChanged() {
- Timestamp visibleHook = datePicker.getDateTime() != null ?
- datePicker.getDateTime() : new Timestamp(datePicker.getLinkDay().getTime());
- datePicker.getMonthView().ensureDateVisible(visibleHook);
- datePicker.getEditor().setValue(datePicker.getDateTime());
- }
-
- /**
- * Updates date related properties in picker/monthView
- * after a change in the editor's cal1. Reverts the
- * cal1 if the new date is unselectable.
- *
- * @param oldDate the editor cal1 before the change
- * @param newDate the editor cal1 after the change
- */
- protected void updateFromValueChanged(Timestamp oldDate, Timestamp newDate) {
- if ((newDate != null) && datePicker.getMonthView().isUnselectableDate(newDate)) {
- revertValue(oldDate);
- return;
- }
- // the other place to interrupt the update spiral
- java.util.Date mvDate = datePicker.getMonthView().getSelectionDate();
- if (newDate != null && mvDate != null) {
- Calendar newCal = Calendar.getInstance();
- newCal.setTime(newDate);
-
- Calendar oldCal = Calendar.getInstance();
- oldCal.setTime(mvDate);
-
- if (!datePicker.isSameDate(newCal, oldCal)) {
- datePicker.getMonthView().setSelectionDate(newDate);
- }
- }
- datePicker.setDateTime(newDate);
- }
-
-
- /**
- * PENDING: currently this resets at once - but it's a no-no,
- * because it happens during notification
- *
- *
- * @param oldDate the old date to revert to
- */
- private void revertValue(Timestamp oldDate) {
- datePicker.getEditor().setValue(oldDate);
- }
- /**
- * Updates date related properties picker/editor
- * after a change in the monthView's
- * selection.
- *
- * Here: does nothing if the change is intermediate.
- *
- * @param eventType the type of the selection change
- * @param adjusting flag to indicate whether the the selection change
- * is intermediate
- */
- protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) {
- if (adjusting) {
- return;
- }
- updateEditorValue();
- }
-
- /**
- * Updates internals after the picker's monthView has changed. <p>
- *
- * Cleans to popup. Wires the listeners. Updates date.
- * Updates formats' timezone.
- *
- * @param oldMonthView the picker's monthView before the change,
- * may be null.
- */
- protected void updateFromMonthViewChanged(JXMonthView oldMonthView) {
- popup = null;
- updateMonthViewListeners(oldMonthView);
- TimeZone oldTimeZone = null;
- if (oldMonthView != null) {
- oldMonthView.setComponentInputMapEnabled(false);
- oldTimeZone = oldMonthView.getTimeZone();
- }
- datePicker.getMonthView().setComponentInputMapEnabled(true);
- updateTimeZone(oldTimeZone);
- updateEditorValue();
- }
-
-
- /**
- * Updates internals after the picker's editor property
- * has changed. <p>
- *
- * Updates the picker's children. Removes the old editor and
- * adds the new editor. Wires the editor listeners, it the flag
- * set. Typically, this method is called during installing the
- * componentUI with the flag set to false and true at all other
- * moments.
- *
- *
- * @param oldEditor the picker's editor before the change,
- * may be null.
- * @param updateListeners a flag to indicate whether the listeners
- * are ready for usage.
- */
- protected void updateFromEditorChanged(JFormattedTextField oldEditor,
- boolean updateListeners) {
- if (oldEditor != null) {
- datePicker.remove(oldEditor);
- oldEditor.putClientProperty("doNotCancelPopup", null);
- }
- datePicker.add(datePicker.getEditor());
- datePicker.getEditor().putClientProperty("doNotCancelPopup",
- createDoNotCancelPopupClientProperty());
-
- updateEditorValue();
- if (updateListeners) {
- updateEditorListeners(oldEditor);
- datePicker.revalidate();
- }
- }
-
-
- /**
- * Updates internals after the selection model changed.
- *
- * @param oldModel the model before the change.
- */
- protected void updateFromSelectionModelChanged(DateSelectionModel oldModel) {
- updateSelectionModelListeners(oldModel);
- updateEditorValue();
- }
-
- /**
- * Sets the editor cal1 to the model's selectedDate.
- */
- private void updateEditorValue() {
- //datePicker.getEditor().setValue(datePicker.getMonthView().getSelectionDate());
- Timestamp old = datePicker.getDateTime();
- java.util.Date date = datePicker.getMonthView().getSelectionDate();
- if(old != null && date != null) {
- Calendar selectedCal = Calendar.getInstance();
- selectedCal.setTime(date);
-
- Calendar oldCal = Calendar.getInstance();
- oldCal.setTime(old);
-
- if (!datePicker.isSameDate(selectedCal, oldCal)) {
- // Merge the selected date with old time
- oldCal.set(Calendar.YEAR, selectedCal.get(Calendar.YEAR));
- oldCal.set(Calendar.MONTH, selectedCal.get(Calendar.MONTH));
- oldCal.set(Calendar.DATE, selectedCal.get(Calendar.DATE));
- date = new Timestamp(oldCal.getTimeInMillis());
- datePicker.getEditor().setValue(date);
- } else {
- datePicker.getEditor().setValue(old);
- }
- } else {
- datePicker.getEditor().setValue(date);
- }
- }
-
- //---------------------- updating other properties
-
-
- /**
- * Updates properties which depend on the picker's editable. <p>
- *
- */
- protected void updateFromEditableChanged() {
- boolean isEditable = datePicker.isEditable();
- datePicker.getMonthView().setEnabled(isEditable);
- datePicker.getEditor().setEditable(isEditable);
- /*
- * PatrykRy: Commit today date is not allowed if datepicker is not editable!
- */
- setActionEnabled(JXDateTimePicker.HOME_COMMIT_KEY, isEditable);
- // for consistency, synch navigation as well
- setActionEnabled(JXDateTimePicker.HOME_NAVIGATE_KEY, isEditable);
- }
-
- /**
- *
- * @param key
- * @param enabled
- */
- private void setActionEnabled(String key, boolean enabled) {
- Action action = datePicker.getActionMap().get(key);
- if (action != null) {
- action.setEnabled(enabled);
- }
- }
-
- /**
- * Updates the picker's formats to the given TimeZone.
- * @param zone the timezone to set on the formats.
- */
- protected void updateFormatsFromTimeZone(TimeZone zone) {
- for (DateFormat format : datePicker.getFormats()) {
- format.setTimeZone(zone);
- }
- }
-
- /**
- * Updates picker's timezone dependent properties on change notification
- * from the associated monthView.
- *
- * PENDING JW: DatePicker needs to send notification on timezone change?
- *
- * @param old the timezone before the change.
- */
- protected void updateTimeZone(TimeZone old) {
- updateFormatsFromTimeZone(datePicker.getTimeZone());
- updateLinkDate();
- }
-
- /**
- * Updates the picker's linkDate to be in synch with monthView's today.
- */
- protected void updateLinkDate() {
- datePicker.setLinkDay(datePicker.getMonthView().getToday());
- }
-
- /**
- * Called form property listener, updates all components locale, formats
- * etc.
- *
- * @author PeS
- */
- protected void updateLocale() {
- Locale locale = datePicker.getLocale();
- updateFormatLocale(locale);
- updateChildLocale(locale);
- }
-
- private void updateFormatLocale(Locale locale) {
- if (locale != null) {
- // PENDING JW: timezone?
- if (getCustomFormats(datePicker.getEditor()) == null) {
- datePicker.getEditor().setFormatterFactory(
- new DefaultFormatterFactory(
- new DatePickerFormatterUIResource(locale)));
- }
- }
- }
-
- private void updateChildLocale(Locale locale) {
- if (locale != null) {
- datePicker.getEditor().setLocale(locale);
- datePicker.getLinkPanel().setLocale(locale);
- datePicker.getMonthView().setLocale(locale);
- }
- }
-
- /**
- * @param oldLinkPanel
- *
- */
- protected void updateLinkPanel(JComponent oldLinkPanel) {
- if (oldLinkPanel != null) {
- uninstallLinkPanelKeyboardActions(oldLinkPanel);
- }
- installLinkPanelKeyboardActions();
- if (popup != null) {
- popup.updateLinkPanel(oldLinkPanel);
- }
- }
-
-
-//------------------- methods called by installed actions
-
- /**
- *
- */
- protected void commit() {
- hidePopup();
- try {
- datePicker.commitEdit();
- } catch (ParseException ex) {
- // can't help it
- }
- }
-
- /**
- *
- */
- protected void cancel() {
- hidePopup();
- datePicker.cancelEdit();
- }
-
- /**
- * PENDING: widened access for debugging - need api to
- * control popup visibility?
- */
- public void hidePopup() {
- if (popup != null) {
- popup.setVisible(false);
- }
- }
-
- public boolean isPopupVisible() {
- if (popup != null) {
- return popup.isVisible();
- }
- return false;
- }
- /**
- * Navigates to linkDate. If commit, the linkDate is selected
- * and committed. If not commit, the linkDate is scrolled to visible, if the
- * monthview is open, does nothing for invisible monthView.
- *
- * @param commit boolean to indicate whether the linkDate should be
- * selected and committed
- */
- protected void home(boolean commit) {
- if (commit) {
- Calendar cal = datePicker.getMonthView().getCalendar();
- cal.setTime(datePicker.getLinkDay());
- datePicker.getMonthView().setSelectionDate(cal.getTime());
- datePicker.getMonthView().commitSelection();
- } else {
- datePicker.getMonthView().ensureDateVisible(datePicker.getLinkDay());
- }
- }
-
-//---------------------- other stuff
-
- /**
- * Creates and returns the action for committing the picker's
- * input.
- *
- * @return
- */
- private Action createCommitAction() {
- Action action = new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- commit();
- }
-
- };
- return action;
- }
-
- /**
- * Creates and returns the action for cancel the picker's
- * edit.
- *
- * @return
- */
- private Action createCancelAction() {
- Action action = new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- cancel();
- }
-
- };
- return action;
- }
-
- private Action createHomeAction(final boolean commit) {
- Action action = new AbstractAction( ) {
- @Override
- public void actionPerformed(ActionEvent e) {
- home(commit);
-
- }
-
- };
- return action ;
- }
- /**
- * The wrapper for the editor cancel action.
- *
- * PENDING: Need to extend TestAction?
- *
- */
- public class EditorCancelAction extends AbstractAction {
- private JFormattedTextField editor;
- private Action cancelAction;
- public static final String TEXT_CANCEL_KEY = "reset-field-edit";
-
- public EditorCancelAction(JFormattedTextField field) {
- install(field);
- }
-
- /**
- * Resets the contained editors actionMap to original and
- * nulls all fields. <p>
- * NOTE: after calling this method the action must not be
- * used! Create a new one for the same or another editor.
- *
- */
- public void uninstall() {
- editor.getActionMap().remove(TEXT_CANCEL_KEY);
- cancelAction = null;
- editor = null;
- }
-
- /**
- * @param editor
- */
- private void install(JFormattedTextField editor) {
- this.editor = editor;
- cancelAction = editor.getActionMap().get(TEXT_CANCEL_KEY);
- editor.getActionMap().put(TEXT_CANCEL_KEY, this);
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- cancelAction.actionPerformed(null);
- cancel();
- }
-
- }
-
- /**
- * Creates and returns the action which toggles the visibility of the popup.
- *
- * @return the action which toggles the visibility of the popup.
- */
- protected TogglePopupAction createTogglePopupAction() {
- return new TogglePopupAction();
- }
-
-
- /**
- * Toggles the popups visibility after preparing internal state.
- *
- *
- */
- public void toggleShowPopup() {
- if (popup == null) {
- popup = createMonthViewPopup();
- }
- if (popup.isVisible()) {
- popup.setVisible(false);
- } else {
- // PENDING JW: Issue 757-swing - datePicker firing focusLost on opening
- // not with following line - but need to run tests
- datePicker.getEditor().requestFocusInWindow();
-// datePicker.requestFocusInWindow();
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- popup.show(datePicker,
- 0, datePicker.getHeight());
- }
- });
- }
-
- }
-
- /**
- *
- */
- private BasicDatePickerPopup createMonthViewPopup() {
- BasicDatePickerPopup popup = new BasicDatePickerPopup();
- popup.setLightWeightPopupEnabled(datePicker.isLightWeightPopupEnabled());
- return popup;
- }
- /**
- * Action used to commit the current cal1 in the JFormattedTextField.
- * This action is used by the keyboard bindings.
- */
- private class TogglePopupAction extends AbstractAction {
- public TogglePopupAction() {
- super("TogglePopup");
- }
-
- @Override
- public void actionPerformed(ActionEvent ev) {
- toggleShowPopup();
- }
- }
-
-
- /**
- * Popup component that shows a JXMonthView component along with controlling
- * buttons to allow traversal of the months. Upon selection of a date the
- * popup will automatically hide itself and enter the selection into the
- * editable field of the JXDateTimePicker.
- *
- */
- protected class BasicDatePickerPopup extends JPopupMenu {
-
- public BasicDatePickerPopup() {
- setLayout(new BorderLayout());
- add(datePicker.getMonthView(), BorderLayout.CENTER);
- updateLinkPanel(null);
- //JXPanel timePanel = new JXPanel();
- //timePanel.add(new JXLabel("Time: "));
- //timePanel.add(datePicker._timeField);
- //add(timePanel, BorderLayout.SOUTH);
- }
-
- /**
- * @param oldLinkPanel
- */
- public void updateLinkPanel(JComponent oldLinkPanel) {
- if (oldLinkPanel != null) {
- remove(oldLinkPanel);
- }
- if (datePicker.getLinkPanel() != null) {
- add(datePicker.getLinkPanel(), BorderLayout.SOUTH);
- }
-
- }
- }
-
- /**
- * PENDING: JW - I <b>really</b> hate the one-in-all. Wont touch
- * it for now, maybe later. As long as we have it, the new
- * listeners (dateSelection) are here too, for consistency.
- * Adding the Layout here as well is ... , IMO.
- */
- private class Handler implements LayoutManager, MouseListener, MouseMotionListener,
- PropertyChangeListener, DateSelectionListener, ActionListener, FocusListener {
-
-//------------- implement Mouse/MotionListener
- private boolean _forwardReleaseEvent = false;
-
- @Override
- public void mouseClicked(MouseEvent ev) {
- }
-
- @Override
- public void mousePressed(MouseEvent ev) {
- if (!datePicker.isEnabled()) {
- return;
- }
- // PENDING JW: why do we need a mouseListener? the
- // arrowbutton should have the toggleAction installed?
- // Hmm... maybe doesn't ... check!
- // reason might be that we want to open on pressed
- // typically (or LF-dependent?),
- // the button's action is invoked on released.
- toggleShowPopup();
- }
-
- @Override
- public void mouseReleased(MouseEvent ev) {
- if (!datePicker.isEnabled() || !datePicker.isEditable()) {
- return;
- }
-
- // Retarget mouse event to the month view.
- if (_forwardReleaseEvent) {
- JXMonthView monthView = datePicker.getMonthView();
- ev = SwingUtilities.convertMouseEvent(popupButton, ev,
- monthView);
- monthView.dispatchEvent(ev);
- _forwardReleaseEvent = false;
- }
- }
-
- @Override
- public void mouseEntered(MouseEvent ev) {
- }
-
- @Override
- public void mouseExited(MouseEvent ev) {
- }
-
- @Override
- public void mouseDragged(MouseEvent ev) {
- if (!datePicker.isEnabled() || !datePicker.isEditable()) {
- return;
- }
-
- _forwardReleaseEvent = true;
-
- if (!popup.isShowing()) {
- return;
- }
-
- // Retarget mouse event to the month view.
- JXMonthView monthView = datePicker.getMonthView();
- ev = SwingUtilities.convertMouseEvent(popupButton, ev, monthView);
- monthView.dispatchEvent(ev);
- }
-
- @Override
- public void mouseMoved(MouseEvent ev) {
- }
-//------------------ implement DateSelectionListener
- @Override
- public void valueChanged(DateSelectionEvent ev) {
- updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
- }
-
-//------------------ implement propertyChangeListener
- /**
- * {@inheritDoc}
- */
- @Override
- public void propertyChange(PropertyChangeEvent e) {
- if (e.getSource() == datePicker) {
- datePickerPropertyChange(e);
- } else
- if (e.getSource() == datePicker.getEditor()) {
- editorPropertyChange(e);
- } else
- if (e.getSource() == datePicker.getMonthView()) {
- monthViewPropertyChange(e);
- } else
- if (e.getSource() == popupButton) {
- buttonPropertyChange(e);
- } else
- // PENDING - move back, ...
- if ("value".equals(e.getPropertyName())) {
- throw new IllegalStateException(
- "editor listening is moved to dedicated propertyChangeLisener");
- }
- }
-
- /**
- * Handles property changes from datepicker's editor.
- *
- * @param e the PropertyChangeEvent object describing the event source
- * and the property that has changed
- */
- private void editorPropertyChange(PropertyChangeEvent evt) {
- if ("value".equals(evt.getPropertyName())) {
-
- Object oldVal = evt.getOldValue();
- Object newVal = evt.getNewValue();
-
- Timestamp oldts = null;
- if(oldVal instanceof Timestamp){
- oldts = (Timestamp)oldVal;
- } else if(oldVal instanceof java.util.Date){
- oldts = new Timestamp(((java.util.Date)oldVal).getTime());
- }
-
- Timestamp newts = null;
- if(newVal instanceof Timestamp){
- newts = (Timestamp) newVal;
- } else if(newVal instanceof java.util.Date){
- newts = new Timestamp(((java.util.Date)newVal).getTime());
- }
-
- updateFromValueChanged(oldVal == null ? null : oldts, newts);
- }
-
- }
-
- /**
- * Handles property changes from DatePicker.
- * @param e the PropertyChangeEvent object describing the
- * event source and the property that has changed
- */
- private void datePickerPropertyChange(PropertyChangeEvent e) {
- String property = e.getPropertyName();
- if ("date".equals(property)) {
- updateFromDateChanged();
- } else if ("enabled".equals(property)) {
- boolean isEnabled = datePicker.isEnabled();
- popupButton.setEnabled(isEnabled);
- datePicker.getEditor().setEnabled(isEnabled);
- } else if ("editable".equals(property)) {
- updateFromEditableChanged();
- } else if (JComponent.TOOL_TIP_TEXT_KEY.equals(property)) {
- String tip = datePicker.getToolTipText();
- datePicker.getEditor().setToolTipText(tip);
- popupButton.setToolTipText(tip);
- } else if (JXDateTimePicker.MONTH_VIEW.equals(property)) {
- updateFromMonthViewChanged((JXMonthView) e.getOldValue());
- } else if (JXDateTimePicker.LINK_PANEL.equals(property)) {
- updateLinkPanel((JComponent) e.getOldValue());
- } else if (JXDateTimePicker.EDITOR.equals(property)) {
- updateFromEditorChanged((JFormattedTextField) e.getOldValue(), true);
- } else if ("componentOrientation".equals(property)) {
- datePicker.revalidate();
- } else if ("lightWeightPopupEnabled".equals(property)) {
- // Force recreation of the popup when this property changes.
- if (popup != null) {
- popup.setVisible(false);
- }
- popup = null;
- } else if ("formats".equals(property)) {
- updateFormatsFromTimeZone(datePicker.getTimeZone());
- }
- else if ("locale".equals(property)) {
- updateLocale();
- }
- }
-
- /**
- * Handles propertyChanges from the picker's monthView.
- *
- * @param e the PropertyChangeEvent object describing the event source
- * and the property that has changed
- */
- private void monthViewPropertyChange(PropertyChangeEvent e) {
- if ("selectionModel".equals(e.getPropertyName())) {
- updateFromSelectionModelChanged((DateSelectionModel) e.getOldValue());
- } else if ("timeZone".equals(e.getPropertyName())) {
- updateTimeZone((TimeZone) e.getOldValue());
- } else if ("today".equals(e.getPropertyName())) {
- updateLinkDate();
- }
- }
-
- /**
- * Handles propertyChanges from the picker's popupButton.
- *
- * PENDING: does nothing, kept while refactoring .. which
- * properties from the button do we want to handle?
- *
- * @param e the PropertyChangeEvent object describing the event source
- * and the property that has changed.
- */
- private void buttonPropertyChange(PropertyChangeEvent e) {
- }
-
-//-------------- implement LayoutManager
- @Override
- public void addLayoutComponent(String name, Component comp) { }
-
- @Override
- public void removeLayoutComponent(Component comp) { }
-
- @Override
- public Dimension preferredLayoutSize(Container parent) {
- return parent.getPreferredSize();
- }
-
- @Override
- public Dimension minimumLayoutSize(Container parent) {
- return parent.getMinimumSize();
- }
-
- @Override
- public void layoutContainer(Container parent) {
- Insets insets = datePicker.getInsets();
- int width = datePicker.getWidth() - insets.left - insets.right;
- int height = datePicker.getHeight() - insets.top - insets.bottom;
-
- int popupButtonWidth = popupButton != null ? popupButton.getPreferredSize().width : 0;
-
- boolean ltr = datePicker.getComponentOrientation().isLeftToRight();
-
- datePicker.getEditor().setBounds(ltr ? insets.left : insets.left + popupButtonWidth,
- insets.top,
- width - popupButtonWidth,
- height);
-
- if (popupButton != null) {
- popupButton.setBounds(ltr ? width - popupButtonWidth + insets.left : insets.left,
- insets.top,
- popupButtonWidth,
- height);
- }
- }
-
-// ------------- implement actionListener (listening to monthView actionEvent)
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e == null) {
- return;
- }
- if (e.getSource() == datePicker.getMonthView()) {
- monthViewActionPerformed(e);
- } else if (e.getSource() == datePicker.getEditor()) {
- editorActionPerformed(e);
- }
- }
-
- /**
- * Listening to actionEvents fired by the picker's editor.
- *
- * @param e
- */
- private void editorActionPerformed(ActionEvent e) {
- // pass the commit on to the picker.
- commit();
- }
-
- /**
- * Listening to actionEvents fired by the picker's monthView.
- *
- * @param e
- */
- private void monthViewActionPerformed(ActionEvent e) {
- if (JXMonthView.CANCEL_KEY.equals(e.getActionCommand())) {
- cancel();
- } else if (JXMonthView.COMMIT_KEY.equals(e.getActionCommand())) {
- commit();
- }
- }
-
-//------------------- focusListener
-
- /**
- * Issue #573-swingx - F2 in table doesn't focus the editor.
- *
- * Do the same as combo: manually pass-on the focus to the editor.
- *
- */
- @Override
- public void focusGained(FocusEvent e) {
- if (e.isTemporary()) {
- return;
- }
- popupRemover.load();
- if (e.getSource() == datePicker) {
- datePicker.getEditor().requestFocusInWindow();
- }
- }
-
- /**
- * #565-swingx: popup not hidden if clicked into combo.
- * The problem is that the combo uses the same trick as
- * this datepicker to prevent auto-closing of the popup
- * if focus is transfered back to the picker's editor.
- *
- * The idea is to hide the popup manually when the
- * permanentFocusOwner changes to somewhere else.
- *
- * JW: doesn't work - we only get the temporary lost,
- * but no permanent loss if the focus is transfered from
- * the focusOwner to a new permanentFocusOwner.
- *
- * OOOkaay ... looks like exclusively related to a combo:
- * we do get the expected focusLost if the focus is
- * transferred permanently from the temporary focusowner
- * to a new "normal" permanentFocusOwner (like a textfield),
- * we don't get it if transfered to a tricksing owner (like
- * a combo or picker). So can't do anything here.
- *
- * listen to keyboardFocusManager?
- */
- @Override
- public void focusLost(FocusEvent e) {
-
- }
- }
-
- public class PopupRemover implements PropertyChangeListener {
-
- private KeyboardFocusManager manager;
- private boolean loaded;
-
- public void load() {
- if (manager != KeyboardFocusManager.getCurrentKeyboardFocusManager()) {
- unload();
- manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- }
- if (!loaded) {
- manager.addPropertyChangeListener("permanentFocusOwner", this);
- loaded = true;
- }
- }
-
- /**
- * @param b
- */
- private void unload(boolean nullManager) {
- if (manager != null) {
- manager.removePropertyChangeListener("permanentFocusOwner", this);
- if (nullManager) {
- manager = null;
- }
- }
- loaded = false;
- }
-
- public void unload() {
- unload(true);
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (!isPopupVisible()) {
- unload(false);
- return;
- }
- Component comp = manager.getPermanentFocusOwner();
- if ((comp != null) && !SwingXUtilities.isDescendingFrom(comp, datePicker)) {
- unload(false);
- // on hiding the popup the focusmanager transfers
- // focus back to the old permanentFocusOwner
- // before showing the popup, that is the picker
- // or the editor. So we have to force it back ...
- hidePopup();
- comp.requestFocusInWindow();
- // this has no effect as focus changes are asynchronous
-// inHide = false;
- }
- }
-
-
- }
-
-
-// ------------------ listener creation
-
- /**
- * Creates and returns the property change listener for the
- * picker's monthView
- * @return the listener for monthView properties
- */
- protected PropertyChangeListener createMonthViewPropertyListener() {
- return getHandler();
- }
-
- /**
- * Creates and returns the focuslistener for picker and editor.
- * @return the focusListener
- */
- protected FocusListener createFocusListener() {
- return getHandler();
- }
-
-
- /**
- * Creates and returns the ActionListener for the picker's editor.
- * @return the Actionlistener for the editor.
- */
- protected ActionListener createEditorActionListener() {
- return getHandler();
- }
-
- /**
- * Creates and returns the ActionListener for the picker's monthView.
- *
- * @return the Actionlistener for the monthView.
- */
- protected ActionListener createMonthViewActionListener() {
- return getHandler();
- }
-
-/**
- * Returns the listener for the dateSelection.
- *
- * @return the date selection listener
- */
- protected DateSelectionListener createMonthViewSelectionListener() {
- return getHandler();
- }
-
- /**
- * @return a propertyChangeListener listening to
- * editor property changes
- */
- protected PropertyChangeListener createEditorPropertyListener() {
- return getHandler();
- }
-
- /**
- * Lazily creates and returns the shared all-mighty listener of everything
- *
- * @return the shared listener.
- */
- private Handler getHandler() {
- if (handler == null) {
- handler = new Handler();
- }
- return handler;
- }
-
- protected PropertyChangeListener createPropertyChangeListener() {
- return getHandler();
- }
-
- protected LayoutManager createLayoutManager() {
- return getHandler();
- }
-
- protected MouseListener createMouseListener() {
- return getHandler();
- }
-
- protected MouseMotionListener createMouseMotionListener() {
- return getHandler();
- }
-
-
-//------------ utility methods
-
- private Object createDoNotCancelPopupClientProperty() {
- // this is a trick to get hold of the client prop which
- // prevents closing of the popup
- JComboBox box = new JComboBox();
- return box.getClientProperty("doNotCancelPopup");
- }
-}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/ColorHelper.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/ColorHelper.java
index 9c32c5b3e..4d8428989 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/util/ColorHelper.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/util/ColorHelper.java
@@ -20,7 +20,6 @@
import java.awt.Color;
import javax.swing.UIManager;
-import org.jdesktop.swingx.plaf.UIManagerExt;
/**
* Helper to deal with different color schemes.
@@ -202,7 +201,7 @@ public static Color getJxdatetimepickerBackground() {
if(isDarkTheme()) {
UIManager.put("nb.dataview.jxdatetimepicker.background", new RelativeColor(new Color(0, 0, 0), new Color(0, 0, 0), "Table.background")); //NOI18N
} else {
- UIManager.put("nb.dataview.jxdatetimepicker.background", UIManagerExt.getColor("JXMonthView.background"));
+ UIManager.put("nb.dataview.jxdatetimepicker.background", UIManager.getColor("JXMonthView.background"));
}
return UIManager.getColor("nb.dataview.jxdatetimepicker.background"); //NOI18N
} else {
@@ -216,7 +215,7 @@ public static Color getJxdatetimepickerForeground() {
if(isDarkTheme()) {
UIManager.put("nb.dataview.jxdatetimepicker.foreground", new RelativeColor(new Color(0, 0, 0), new Color(0, 0, 0), "Table.foreground")); //NOI18N
} else {
- UIManager.put("nb.dataview.jxdatetimepicker.foreground", UIManagerExt.getColor("JXMonthView.foreground"));
+ UIManager.put("nb.dataview.jxdatetimepicker.foreground", UIManager.getColor("JXMonthView.foreground"));
}
return UIManager.getColor("nb.dataview.jxdatetimepicker.foreground"); //NOI18N
} else {
@@ -234,7 +233,7 @@ public static Color getJxdatetimepickerSelectedBackground() {
UIManager.put("nb.dataview.jxdatetimepicker.selectedBackground", new RelativeColor(new Color(0, 0, 0), new Color(0, 0, 0), "Table.selectionBackground")); //NOI18N
}
} else {
- UIManager.put("nb.dataview.jxdatetimepicker.selectedBackground", UIManagerExt.getColor("JXMonthView.selectedBackground"));
+ UIManager.put("nb.dataview.jxdatetimepicker.selectedBackground", UIManager.getColor("JXMonthView.selectedBackground"));
}
return UIManager.getColor("nb.dataview.jxdatetimepicker.selectedBackground"); //NOI18N
@@ -253,7 +252,7 @@ public static Color getJxdatetimepickerSelectedForeground() {
UIManager.put("nb.dataview.jxdatetimepicker.selectedForeground", new RelativeColor(new Color(0, 0, 0), new Color(0, 0, 0), "Table.selectionForeground")); //NOI18N
}
} else {
- UIManager.put("nb.dataview.jxdatetimepicker.selectedForeground", UIManagerExt.getColor("JXMonthView.selectedForeground"));
+ UIManager.put("nb.dataview.jxdatetimepicker.selectedForeground", UIManager.getColor("JXMonthView.selectedForeground"));
}
return UIManager.getColor("nb.dataview.jxdatetimepicker.selectedForeground"); //NOI18N
@@ -268,7 +267,7 @@ public static Color getJxdatetimepickerDaysOfTheWeekForeground() {
if (isDarkTheme()) {
UIManager.put("nb.dataview.jxdatetimepicker.daysOfTheWeekForeground", new RelativeColor(new Color(0, 0, 0), new Color(0, 0, 0), "Table.background")); //NOI18N
} else {
- UIManager.put("nb.dataview.jxdatetimepicker.daysOfTheWeekForeground", UIManagerExt.getColor("JXMonthView.daysOfTheWeekForeground"));
+ UIManager.put("nb.dataview.jxdatetimepicker.daysOfTheWeekForeground", UIManager.getColor("JXMonthView.daysOfTheWeekForeground"));
}
return UIManager.getColor("nb.dataview.jxdatetimepicker.daysOfTheWeekForeground"); //NOI18N
} else {
@@ -282,7 +281,7 @@ public static Color getJxdatetimepickerTodayBackground() {
if(isDarkTheme()) {
UIManager.put("nb.dataview.jxdatetimepicker.todayBackground", new RelativeColor(new Color(0, 0, 0), new Color(20, 20, 20), "Table.background")); //NOI18N
} else {
- UIManager.put("nb.dataview.jxdatetimepicker.todayBackground", UIManagerExt.getColor("JXMonthView.foreground"));
+ UIManager.put("nb.dataview.jxdatetimepicker.todayBackground", UIManager.getColor("JXMonthView.foreground"));
}
return UIManager.getColor("nb.dataview.jxdatetimepicker.todayBackground"); //NOI18N
} else {
@@ -335,7 +334,7 @@ public static Color getJxdatetimepickerTodayPanelLinkForeground() {
public static Color getJxdatetimepickerMonthStringBackground() {
Color managerColor = UIManager.getColor("nb.dataview.jxdatetimepicker.monthStringBackground");
if (managerColor == null) {
- UIManager.put("nb.dataview.jxdatetimepicker.monthStringBackground", UIManagerExt.getColor("JXMonthView.monthStringBackground")); //NOI18N
+ UIManager.put("nb.dataview.jxdatetimepicker.monthStringBackground", UIManager.getColor("JXMonthView.monthStringBackground")); //NOI18N
return UIManager.getColor("nb.dataview.jxdatetimepicker.monthStringBackground"); //NOI18N
} else {
return managerColor;
@@ -345,7 +344,7 @@ public static Color getJxdatetimepickerMonthStringBackground() {
public static Color getJxdatetimepickerMonthStringForeground() {
Color managerColor = UIManager.getColor("nb.dataview.jxdatetimepicker.monthStringForeground");
if (managerColor == null) {
- UIManager.put("nb.dataview.jxdatetimepicker.monthStringForeground", UIManagerExt.getColor("JXMonthView.monthStringForeground")); //NOI18N
+ UIManager.put("nb.dataview.jxdatetimepicker.monthStringForeground", UIManager.getColor("JXMonthView.monthStringForeground")); //NOI18N
return UIManager.getColor("nb.dataview.jxdatetimepicker.monthStringForeground"); //NOI18N
} else {
return managerColor;
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/DateType.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/DateType.java
index 7f241ed59..c9fc3dce8 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/util/DateType.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/util/DateType.java
@@ -39,10 +39,8 @@
public static final String DEFAULT_FOMAT_PATTERN = "yyyy-MM-dd"; // NOI18N
private static final DateFormat[] DATE_PARSING_FORMATS = new DateFormat[]{
new SimpleDateFormat (DEFAULT_FOMAT_PATTERN),
- DateFormat.getDateInstance(),
- DateFormat.getTimeInstance(DateFormat.SHORT),
- DateFormat.getTimeInstance(DateFormat.SHORT, TimestampType.LOCALE),
- new SimpleDateFormat("yyyy-MM-dd"), // NOI18N
+ DateFormat.getDateInstance(DateFormat.MEDIUM),
+ DateFormat.getDateInstance(DateFormat.SHORT),
new SimpleDateFormat("MM-dd-yyyy"), // NOI18N
};
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/FormatStringValue.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/FormatStringValue.java
new file mode 100644
index 000000000..9672429e0
--- /dev/null
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/util/FormatStringValue.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.db.dataview.util;
+
+import java.text.Format;
+
+public class FormatStringValue implements StringValue {
+ private final Format format;
+
+ public FormatStringValue (Format format) {
+ if(format == null) {
+ throw new IllegalArgumentException("FormatStringValue constructed with NULL value for format.");
+ }
+ this.format = format;
+ }
+
+ public String getString(Object o) {
+ return this.format.format(o);
+ }
+}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/JXDateTimePicker.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/JXDateTimePicker.java
deleted file mode 100644
index 8527cb8ee..000000000
--- a/db.dataview/src/org/netbeans/modules/db/dataview/util/JXDateTimePicker.java
+++ /dev/null
@@ -1,1007 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.modules.db.dataview.util;
-
-import java.awt.Color;
-import java.awt.ComponentOrientation;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.GradientPaint;
-import java.awt.Graphics;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.Format;
-import java.text.MessageFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Comparator;
-import java.util.EventListener;
-import java.util.Locale;
-import java.util.TimeZone;
-import java.util.logging.Logger;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JFormattedTextField;
-import javax.swing.JFormattedTextField.AbstractFormatter;
-import javax.swing.JFormattedTextField.AbstractFormatterFactory;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.UIManager;
-import javax.swing.text.DefaultFormatterFactory;
-import org.jdesktop.swingx.JXHyperlink;
-import org.jdesktop.swingx.JXMonthView;
-import org.jdesktop.swingx.JXPanel;
-import org.jdesktop.swingx.calendar.DatePickerFormatter;
-import org.jdesktop.swingx.event.EventListenerMap;
-import org.jdesktop.swingx.painter.MattePainter;
-import org.jdesktop.swingx.plaf.DatePickerAddon;
-import org.jdesktop.swingx.plaf.LookAndFeelAddons;
-import org.jdesktop.swingx.plaf.UIManagerExt;
-import org.jdesktop.swingx.util.Contract;
-
-/**
- * A component for entering dates with a user interaction similar to a
- * JComboBox. The dates can be typed into a text field or selected from a
- * JXMonthView which opens in a JXPopupMenu on user's request.
- * <p>
- *
- * The date selection is controlled by the JXMonthView's DateSelectionModel.
- * This allows the use of all its functionality in the JXDateTimePicker as well.
- * F.i. restrict the selection to a date in the current or next week:
- * <p>
- *
- * <pre><code>
- * Appointment appointment = new Appointment(director,
- * "Be sure to have polished shoes!");
- * JXDateTimePicker picker = new JXDateTimePicker();
- * Calendar calendar = picker.getMonthView().getCalendar();
- * // starting today if we are in a hurry
- * calendar.setTime(new Date());
- * picker.getMonthView().setLowerBound(calendar.getTime());
- * // end of next week
- * CalendarUtils.endOfWeek(calendar);
- * calendar.add(Calendar.WEEK_OF_YEAR);
- * picker.getMonthView().setUpperBound(calendar.getTime());
- * </code></pre>
- *
- * Similar to a JXMonthView, the JXDateTimePicker fires an ActionEvent when the user
- * actively commits or cancels a selection. Interested client code can add a
- * ActionListener to be notified by the user action.
- *
- * <pre><code>
- * JXDateTimePicker picker = new JXDateTimePicker(new Date());
- * ActionListener l = new ActionListener() {
- * public void actionPerformed(ActionEvent e) {
- * if (JXDateTimePicker.COMMIT_KEY.equals(e.getActionCommand)) {
- * saveDate(picker.getDate());
- * }
- * }
- * };
- * picker.addActionListener(l);
- * </code></pre>
- *
- * <p>
- * The DateFormats used in the JXDateTimePicker's are initialized to the default
- * formats of the DatePickerFormatter, as defined by the picker's resourceBundle
- * DatePicker.properties. Application code can overwrite the picker's default
- *
- * <pre><code>
- * picker.setDateFormats(myCustomFormat, myAlternativeCustomFormat);
- * </code></pre>
- *
- * PENDING JW: explain what the alternatives are for (after understanding it
- * myself ;-)
- * <p>
- *
- * The selected Date is a bound property of the JXDateTimePicker. This allows easy
- * binding to a property of a custom bean when using a binding framework.
- * <p>
- *
- * @author Joshua Outwater
- * @author Jeanette Winzenburg
- *
- * @see JXMonthView
- * @see org.jdesktop.swingx.calendar.DateSelectionModel
- * @see DatePickerFormatter
- *
- */
-public class JXDateTimePicker extends JComponent {
- @SuppressWarnings("unused")
- private static final Logger LOG = Logger.getLogger(JXDateTimePicker.class
- .getName());
- static {
- LookAndFeelAddons.contribute(new DatePickerAddon());
- }
-
- /**
- * UI Class ID
- */
- public static final String uiClassID = "BasicDateTimePickerUI";
-
- public static final String EDITOR = "editor";
- public static final String MONTH_VIEW = "monthView";
- /** @deprecated no longer used - all "millis" are replaced by date */
- @Deprecated
- public static final String DATE_IN_MILLIS = "dateInMillis";
- public static final String LINK_PANEL = "linkPanel";
-
- /** action command used for commit actionEvent. */
- public static final String COMMIT_KEY = "datePickerCommit";
- /** action command used for cancel actionEvent. */
- public static final String CANCEL_KEY = "datePickerCancel";
- /** action key for navigate home action */
- public static final String HOME_NAVIGATE_KEY = "navigateHome";
- /** action key for commit home action */
- public static final String HOME_COMMIT_KEY = "commitHome";
-
- private static final DateFormat[] EMPTY_DATE_FORMATS = new DateFormat[0];
-
- /**
- * The editable date field that displays the date
- */
- private JFormattedTextField _dateField;
- protected JFormattedTextField _timeField;
-
- /**
- * Popup that displays the month view with controls for
- * traversing/selecting dates.
- */
- private JPanel _linkPanel;
- private MessageFormat _linkFormat;
- private java.util.Date linkDate;
-
- private JXMonthView _monthView;
- private boolean editable = true;
- private EventListenerMap listenerMap;
- protected boolean lightWeightPopupEnabled = JPopupMenu.getDefaultLightWeightPopupEnabled();
-
- private Timestamp date;
-
- private PropertyChangeListener monthViewListener;
-
-
- /**
- * Intantiates a date picker with no selection and the default
- * <code>DatePickerFormatter</code>.
- * <p/>
- * The date picker is configured with the default time zone and locale
- *
- * @see #setTimeZone
- * @see #getTimeZone
- */
- public JXDateTimePicker() {
- this(null, null);
- }
-
-
-
- /**
- * Intantiates a date picker using the specified time as the initial
- * selection and the default
- * <code>DatePickerFormatter</code>.
- * <p/>
- * The date picker is configured with the default time zone and locale
- *
- * @param selected the initially selected date
- * @see #setTimeZone
- * @see #getTimeZone
- */
- public JXDateTimePicker(Timestamp selected) {
- this(selected, null);
- }
-
- /**
- * Intantiates a date picker with no selection and the default
- * <code>DatePickerFormatter</code>.
- * <p/>
- * The date picker is configured with the default time zone and specified
- * locale
- *
- * @param locale initial Locale
- * @see #setTimeZone
- * @see #getTimeZone
- */
- public JXDateTimePicker(Locale locale) {
- this(null, locale);
- }
-
- /**
- * Intantiates a date picker using the specified time as the initial
- * selection and the default
- * <code>DatePickerFormatter</code>.
- * <p/>
- * The date picker is configured with the default time zone and specified locale
- *
- * @param selection initially selected Date
- * @param locale initial Locale
- * @see #setTimeZone
- * @see #getTimeZone
- *
- */
- public JXDateTimePicker(Timestamp selection, Locale locale) {
- init();
- if (locale != null) {
- setLocale(locale);
- }
- // install the controller before setting the date
- updateUI();
- setDateTime(selection);
- }
-
- /**
- * Sets the date property. <p>
- *
- * Does nothing if the ui vetos the new date - as might happen if
- * the code tries to set a date which is unselectable in the
- * monthView's context. The actual value of the new Date is controlled
- * by the JXMonthView's DateSelectionModel. The default implementation
- * normalizes the date to the start of the day in the model's calendar's
- * coordinates, that is all time fields are zeroed. To keep the time fields,
- * configure the monthView with a SingleDaySelectionModel.
- * <p>
- *
- * At all "stable" (= not editing in date input field nor
- * in the monthView) times the date is the same in the
- * JXMonthView, this JXDateTimePicker and the editor. If a new Date
- * is set, this invariant is enforced by the DatePickerUI.
- * <p>
- *
- * This is a bound property.
- *
- *
- * @param date the new date to set.
- * @see #getDate()
- * @see org.jdesktop.swingx.calendar.DateSelectionModel
- * @see org.jdesktop.swingx.calendar.SingleDaySelectionModel
- */
- public void setDateTime(Timestamp date) {
- if(date == null) {
- return;
- }
- /*
- * JW:
- * this is a poor woman's constraint property.
- * Introduces explicit coupling to the ui.
- * Which is unusual at this place in code.
- *
- * If needed the date can be made a formal
- * constraint property and let the ui add a
- * VetoablePropertyListener.
- */
- try {
- date = getUI().getSelectableDate(date);
- } catch (PropertyVetoException e) {
- return;
- }
-
- Timestamp old = getDateTime();
- this.date = date;
- firePropertyChange("date", old, getDateTime());
- }
-
- protected boolean isSameDate(Calendar cal1, Calendar cal2) {
- Comparator<Calendar> c = new SelectedValuesComparator();
- if (c.compare(cal1, cal2) == 0) {
- return true;
- }
- return false;
- }
-
- protected class SelectedValuesComparator implements Comparator<Calendar> {
- @Override
- public int compare(Calendar cal1, Calendar cal2) {
-
- if (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
- cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) &&
- cal1.get(Calendar.DATE) == cal2.get(Calendar.DATE)) {
- return 0;
- }
- if (cal1.after(cal2)) {
- return 1;
- } else {
- return -1;
- }
- }
- }
-
-
- /**
- * Returns the currently selected date.
- *
- * @return Date
- */
- public Timestamp getDateTime() {
- return date;
- }
-
- /**
- *
- */
- private void init() {
- listenerMap = new EventListenerMap();
- initMonthView();
-
- updateLinkFormat();
- linkDate = _monthView.getToday();
- _linkPanel = new TodayPanel();
- }
-
- private void initMonthView() {
- _monthView = new JXMonthView();
-// _monthView.setSelectionModel(new SingleDaySelectionModel());
- _monthView.setTraversable(true);
-
- _monthView.setBackground(ColorHelper.getJxdatetimepickerBackground());
- _monthView.setForeground(ColorHelper.getJxdatetimepickerForeground());
- _monthView.setSelectionBackground(ColorHelper.getJxdatetimepickerSelectedBackground()); //NOI18N
- _monthView.setSelectionForeground(ColorHelper.getJxdatetimepickerSelectedForeground()); //NOI18N
- _monthView.setMonthStringBackground(ColorHelper.getJxdatetimepickerMonthStringBackground()); //NOI18N
- _monthView.setMonthStringForeground(ColorHelper.getJxdatetimepickerMonthStringForeground()); //NOI18N
- _monthView.setDaysOfTheWeekForeground(ColorHelper.getJxdatetimepickerDaysOfTheWeekForeground()); //NOI18N
- _monthView.setTodayBackground(ColorHelper.getJxdatetimepickerTodayBackground()); //NOI18N
-
- _monthView.addPropertyChangeListener(getMonthViewListener());
- }
-
- /**
- * Lazily creates and returns the PropertyChangeListener which listens
- * for model's calendar properties.
- *
- * @return a PropertyChangeListener for monthView's property change notification.
- */
- private PropertyChangeListener getMonthViewListener() {
- if (monthViewListener == null) {
- monthViewListener = new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if ("timeZone".equals(evt.getPropertyName())) {
- updateTimeZone((TimeZone) evt.getOldValue(), (TimeZone) evt.getNewValue());
- }
-
- }
-
- };
- }
- return monthViewListener;
- }
-
- /**
- * Callback from monthView timezone changes. <p>
- *
- * NOTE: as timeZone is a bound property of this class we need to
- * guarantee the propertyChangeNotification. As this class doesn't
- * own this property it must listen to the owner (monthView) and
- * re-fire the change.
- *
- * @param oldValue the old timezone.
- * @param newValue the new timezone.
- */
- protected void updateTimeZone(TimeZone oldValue, TimeZone newValue) {
- firePropertyChange("timeZone", oldValue, newValue);
- }
-
- /**
- * Returns the look and feel (L&F) object that renders this component.
- *
- * @return the DatePickerUI object that renders this component
- */
- public BasicDateTimePickerUI getUI() {
- return (BasicDateTimePickerUI) ui;
- }
-
- /**
- * Sets the L&F object that renders this component.
- *
- * @param ui UI to use for this {@code JXDateTimePicker}
- */
- public void setUI(BasicDateTimePickerUI ui) {
- super.setUI(ui);
- }
-
- /**
- * Resets the UI property with the value from the current look and feel.
- *
- * @see UIManager#getUI
- */
- @Override
- public void updateUI() {
- setUI(new BasicDateTimePickerUI());
- // JW: quick hack around #706-swingx - monthView not updated
- // not sure if this here is the correct place nor
- // the correct method - SwingUtilities.updateComponentTree might be better
- getMonthView().updateUI();
- invalidate();
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public String getUIClassID() {
- return uiClassID;
- }
-
- /**
- * Replaces the currently installed formatter and factory used by the
- * editor. These string formats are defined by the
- * <code>java.text.SimpleDateFormat</code> class. <p>
- *
- * Note: The given formats are internally synched to the picker's current
- * TimeZone.
- *
- * @param formats zero or more not null string formats to use. Note that a
- * null array is allowed and resets the formatter to use the
- * localized default formats.
- * @throws NullPointerException any array element is null.
- * @see java.text.SimpleDateFormat
- */
- public void setFormats(String... formats) {
- DateFormat[] dateFormats = null;
- if (formats != null) {
- Contract.asNotNull(formats,
- "the array of format strings must not "
- + "must not contain null elements");
- dateFormats = new DateFormat[formats.length];
- for (int counter = formats.length - 1; counter >= 0; counter--) {
- dateFormats[counter] = new SimpleDateFormat(formats[counter], getLocale());
- }
- }
- setFormats(dateFormats);
- }
-
- /**
- * Replaces the currently installed formatter and factory used by the
- * editor.<p>
- *
- * Note: The given formats are internally synched to the picker's current
- * TimeZone.
- *
- * @param formats zero or more not null formats to use. Note that a
- * null array is allowed and resets the formatter to use the
- * localized default formats.
- * @throws NullPointerException any of its elements is null.
- */
- public void setFormats(DateFormat... formats) {
- if (formats != null) {
- Contract.asNotNull(formats, "the array of formats " + "must not contain null elements");
- }
-
- DateFormat[] old = getFormats();
- _dateField.setFormatterFactory(new DefaultFormatterFactory(
- new DatePickerFormatter(formats, getLocale())));
- firePropertyChange("formats", old, getFormats());
- }
-
- /**
- * Returns an array of the formats used by the installed formatter
- * if it is a subclass of <code>JXDatePickerFormatter<code>.
- * <code>javax.swing.JFormattedTextField.AbstractFormatter</code>
- * and <code>javax.swing.text.DefaultFormatter</code> do not have
- * support for accessing the formats used.
- *
- * @return array of formats guaranteed to be not null, but might be empty.
- */
- public DateFormat[] getFormats() {
- // Dig this out from the factory, if possible, otherwise return null.
- AbstractFormatterFactory factory = _dateField.getFormatterFactory();
- if (factory != null) {
- AbstractFormatter formatter = factory.getFormatter(_dateField);
- if (formatter instanceof DatePickerFormatter) {
- return ((DatePickerFormatter) formatter).getFormats();
- }
- }
- return EMPTY_DATE_FORMATS;
- }
-
- /**
- * Return the <code>JXMonthView</code> used in the popup to
- * select dates from.
- *
- * @return the month view component
- */
- public JXMonthView getMonthView() {
- return _monthView;
- }
-
- /**
- * Set the component to use the specified JXMonthView. If the new JXMonthView
- * is configured to a different time zone it will affect the time zone of this
- * component.
- *
- * @param monthView month view comopnent.
- * @throws NullPointerException if view component is null
- *
- * @see #setTimeZone
- * @see #getTimeZone
- */
- public void setMonthView(JXMonthView monthView) {
- Contract.asNotNull(monthView, "monthView must not be null");
- JXMonthView oldMonthView = getMonthView();
- TimeZone oldTZ = getTimeZone();
- oldMonthView.removePropertyChangeListener(getMonthViewListener());
- _monthView = monthView;
- getMonthView().addPropertyChangeListener(getMonthViewListener());
- firePropertyChange(MONTH_VIEW, oldMonthView, getMonthView());
- firePropertyChange("timeZone", oldTZ, getTimeZone());
- }
-
- /**
- * Gets the time zone. This is a convenience method which returns the time zone
- * of the JXMonthView being used.
- *
- * @return The <code>TimeZone</code> used by the <code>JXMonthView</code>.
- */
- public TimeZone getTimeZone() {
- return _monthView.getTimeZone();
- }
-
- /**
- * Sets the time zone with the given time zone value. This is a convenience
- * method which returns the time zone of the JXMonthView being used.<p>
- *
- * PENDING JW: currently this property is the only property of the monthView
- * which is exposed in this api. Not sure why it is here at all.
- * It's asymetric (to the other properties) and as such should be either removed
- * or the others which might be relevant to a datePicker exposed as well (probably
- * hiding the monthView itself as an implementation detail of the ui delegate).
- *
- * @param tz The <code>TimeZone</code>.
- */
- public void setTimeZone(TimeZone tz) {
- _monthView.setTimeZone(tz);
- }
-
-
- /**
- * Returns the date shown in the LinkPanel.
- * <p>
- * PENDING JW: the property should be named linkDate - but that's held by the
- * deprecated long returning method. Maybe revisit if we actually remove the other.
- *
- * @return the date shown in the LinkPanel.
- */
- public java.util.Date getLinkDay() {
- return linkDate;
- }
-
- /**
- * Set the date the link will use and the string defining a MessageFormat
- * to format the link. If no valid date is in the editor when the popup
- * is displayed the popup will focus on the month the linkDate is in. Calling
- * this method will replace the currently installed linkPanel and install
- * a new one with the requested date and format.
- *
- *
- * @param linkDay the Date to set on the LinkPanel
- * @param linkFormatString String used to format the link
- * @see java.text.MessageFormat
- */
- public void setLinkDay(java.util.Date linkDay, String linkFormatString) {
- setLinkFormat(new MessageFormat(linkFormatString));
- setLinkDay(linkDay);
- }
-
- /**
- * Sets the date shown in the TodayPanel.
- *
- * PENDING JW ... quick api hack for testing. Don't recreate the panel if
- * it had been used
- *
- * @param linkDay the date used in the TodayPanel
- */
- public void setLinkDay(java.util.Date linkDay) {
- this.linkDate = linkDay;
- Format[] formats = getLinkFormat().getFormatsByArgumentIndex();
- for (Format format : formats) {
- if (format instanceof DateFormat) {
- ((DateFormat) format).setTimeZone(getTimeZone());
- }
- }
- setLinkPanel(new TodayPanel());
- }
-
-
- /**
- * @param _linkFormat the _linkFormat to set
- */
- protected void setLinkFormat(MessageFormat _linkFormat) {
- this._linkFormat = _linkFormat;
- }
-
- /**
- * @return the _linkFormat
- */
- protected MessageFormat getLinkFormat() {
- return _linkFormat;
- }
-
- /**
- * Update text on the link panel.
- *
- */
- private void updateLinkFormat() {
- // PENDING JW: move to ui
- String linkFormat = UIManagerExt.getString(
- "JXDatePicker.linkFormat", getLocale());
-
- if (linkFormat != null) {
- setLinkFormat(new MessageFormat(linkFormat));
- } else {
- setLinkFormat(new MessageFormat("{0,date, dd MMMM yyyy}"));
- }
- }
-
- /**
- * Return the panel that is used at the bottom of the popup. The default
- * implementation shows a link that displays the current month.
- *
- * @return The currently installed link panel
- */
- public JPanel getLinkPanel() {
- return _linkPanel;
- }
-
- /**
- * Set the panel that will be used at the bottom of the popup.
- * PENDING JW: why insist on JPanel? JComponent would be enough?
- *
- * @param linkPanel The new panel to install in the popup
- */
- public void setLinkPanel(JPanel linkPanel) {
- JPanel oldLinkPanel = _linkPanel;
- _linkPanel = linkPanel;
- firePropertyChange(LINK_PANEL, oldLinkPanel, _linkPanel);
- }
-
- /**
- * Returns the formatted text field used to edit the date selection.
- * <p>
- * Clients should NOT use this method. It is provided to temporarily support
- * the PLAF code.
- *
- * @return the formatted text field
- */
-// @Deprecated
- public JFormattedTextField getEditor() {
- return _dateField;
- }
-
- /**
- * Sets the editor. <p>
- *
- * The default is created and set by the UI delegate.
- * <p>
- * Clients should NOT use this method. It is provided to temporarily support
- * the PLAF code.
- *
- * @param editor the formatted input.
- * @throws NullPointerException if editor is null.
- *
- * @see #getEditor
- */
-// @Deprecated
- public void setEditor(JFormattedTextField editor) {
- Contract.asNotNull(editor, "editor must not be null");
- JFormattedTextField oldEditor = _dateField;
- _dateField = editor;
- firePropertyChange(EDITOR, oldEditor, _dateField);
- }
-
- @Override
- public void setComponentOrientation(ComponentOrientation orientation) {
- super.setComponentOrientation(orientation);
- _monthView.setComponentOrientation(orientation);
- }
-
- /**
- * Returns true if the current value being edited is valid.
- *
- * @return true if the current value being edited is valid.
- */
- public boolean isEditValid() {
- return _dateField.isEditValid();
- }
-
- /**
- * Commits the editor's changes and notifies ActionListeners.
- *
- * Forces the current value to be taken from the AbstractFormatter and
- * set as the current value. This has no effect if there is no current
- * AbstractFormatter installed.
- *
- * @throws java.text.ParseException Throws parse exception if the date
- * can not be parsed.
- */
- public void commitEdit() throws ParseException {
- try {
- _dateField.commitEdit();
- fireActionPerformed(COMMIT_KEY);
- } catch (ParseException e) {
- // re-throw
- throw e;
- }
- }
-
- /**
- * Cancels the editor's changes and notifies ActionListeners.
- *
- */
- public void cancelEdit() {
- // hmmm... no direct api?
- _dateField.setValue(_dateField.getValue());
- fireActionPerformed(CANCEL_KEY);
- }
-
- /**
- * Sets the editable property. If false, ...?
- *
- * The default value is true.
- *
- * @param value
- * @see #isEditable()
- */
- public void setEditable(boolean value) {
- boolean oldEditable = isEditable();
- editable = value;
- firePropertyChange("editable", oldEditable, editable);
- if (editable != oldEditable) {
- repaint();
- }
- }
-
- /**
- * Returns the editable property.
- *
- * @return {@code true} if the picker is editable; {@code false} otherwise
- */
- public boolean isEditable() {
- return editable;
- }
-
- /**
- * Returns the font that is associated with the editor of this date picker.
- */
- @Override
- public Font getFont() {
- return getEditor().getFont();
- }
-
- /**
- * Set the font for the editor associated with this date picker.
- */
- @Override
- public void setFont(final Font font) {
- getEditor().setFont(font);
- }
-
- /**
- * Sets the <code>lightWeightPopupEnabled</code> property, which
- * provides a hint as to whether or not a lightweight
- * <code>Component</code> should be used to contain the
- * <code>JXDateTimePicker</code>, versus a heavyweight
- * <code>Component</code> such as a <code>Panel</code>
- * or a <code>Window</code>. The decision of lightweight
- * versus heavyweight is ultimately up to the
- * <code>JXDateTimePicker</code>. Lightweight windows are more
- * efficient than heavyweight windows, but lightweight
- * and heavyweight components do not mix well in a GUI.
- * If your application mixes lightweight and heavyweight
- * components, you should disable lightweight popups.
- * The default value for the <code>lightWeightPopupEnabled</code>
- * property is <code>true</code>, unless otherwise specified
- * by the look and feel. Some look and feels always use
- * heavyweight popups, no matter what the value of this property.
- * <p/>
- * See the article <a href="http://java.sun.com/products/jfc/tsc/articles/mixing/index.html">Mixing Heavy and Light Components</a>
- * on <a href="http://java.sun.com/products/jfc/tsc">
- * <em>The Swing Connection</em></a>
- * This method fires a property changed event.
- *
- * @param aFlag if <code>true</code>, lightweight popups are desired
- * @beaninfo bound: true
- * expert: true
- * description: Set to <code>false</code> to require heavyweight popups.
- */
- public void setLightWeightPopupEnabled(boolean aFlag) {
- boolean oldFlag = lightWeightPopupEnabled;
- lightWeightPopupEnabled = aFlag;
- firePropertyChange("lightWeightPopupEnabled", oldFlag, lightWeightPopupEnabled);
- }
-
- /**
- * Gets the value of the <code>lightWeightPopupEnabled</code>
- * property.
- *
- * @return the value of the <code>lightWeightPopupEnabled</code>
- * property
- * @see #setLightWeightPopupEnabled
- */
- public boolean isLightWeightPopupEnabled() {
- return lightWeightPopupEnabled;
- }
-
- /**
- * Get the baseline for the specified component, or a value less
- * than 0 if the baseline can not be determined. The baseline is measured
- * from the top of the component.
- *
- * @param width Width of the component to determine baseline for.
- * @param height Height of the component to determine baseline for.
- * @return baseline for the specified component
- */
- @Override
- public int getBaseline(int width, int height) {
- return ((BasicDateTimePickerUI) ui).getBaseline(width, height);
- }
-
-
- /**
- * Adds an ActionListener.
- * <p/>
- * The ActionListener will receive an ActionEvent when a selection has
- * been made.
- *
- * @param l The ActionListener that is to be notified
- */
- public void addActionListener(ActionListener l) {
- listenerMap.add(ActionListener.class, l);
- }
-
- /**
- * Removes an ActionListener.
- *
- * @param l The action listener to remove.
- */
- public void removeActionListener(ActionListener l) {
- listenerMap.remove(ActionListener.class, l);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
- java.util.List<T> listeners = listenerMap.getListeners(listenerType);
- T[] result;
- if (!listeners.isEmpty()) {
- //noinspection unchecked
- result = (T[]) java.lang.reflect.Array.newInstance(listenerType, listeners.size());
- result = listeners.toArray(result);
- } else {
- result = super.getListeners(listenerType);
- }
- return result;
- }
-
-
- /**
- * Fires an ActionEvent with the given actionCommand
- * to all listeners.
- */
- protected void fireActionPerformed(String actionCommand) {
- ActionListener[] listeners = getListeners(ActionListener.class);
- ActionEvent e = null;
-
- for (ActionListener listener : listeners) {
- if (e == null) {
- e = new ActionEvent(this,
- ActionEvent.ACTION_PERFORMED,
- actionCommand);
- }
- listener.actionPerformed(e);
- }
- }
-
- /**
- * Pes: added setLocale method to refresh link text on locale changes
- */
- private final class TodayPanel extends JXPanel {
- private TodayAction todayAction;
- private JXHyperlink todayLink;
-
- @SuppressWarnings("rawtypes")
- TodayPanel() {
- super(new FlowLayout());
- Color gradientStart = ColorHelper.getJxdatetimepickerTodayPanelBackgroundGradientStart();
- Color gradientEnd = ColorHelper.getJxdatetimepickerTodayPanelBackgroundGradientEnd();
- setBackgroundPainter(new MattePainter(new GradientPaint(0, 0, gradientStart, 0, 1, gradientEnd)));
- todayAction = new TodayAction();
- todayLink = new JXHyperlink(todayAction);
- todayLink.addMouseListener(createDoubleClickListener());
- Color textColor = ColorHelper.getJxdatetimepickerTodayPanelLinkForeground();
- todayLink.setUnclickedColor(textColor);
- todayLink.setClickedColor(textColor);
- add(todayLink);
- }
-
- /**
- * @return
- */
- private MouseListener createDoubleClickListener() {
- MouseAdapter adapter = new MouseAdapter() {
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (e.getClickCount() != 2) {
- return;
- }
- todayAction.select = true;
- }
-
- };
- return adapter;
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- g.setColor(new Color(187, 187, 187));
- g.drawLine(0, 0, getWidth(), 0);
- g.setColor(new Color(221, 221, 221));
- g.drawLine(0, 1, getWidth(), 1);
- }
-
- /**
- * {@inheritDoc} <p>
- * Overridden to update the link format and hyperlink text.
- */
- @Override
- public void setLocale(Locale l) {
- super.setLocale(l);
- updateLinkFormat();
- todayLink.setText(getLinkFormat().format(new Object[]{getLinkDay()}));
- }
-
- private final class TodayAction extends AbstractAction {
- boolean select;
- TodayAction() {
- super(getLinkFormat().format(new Object[]{getLinkDay()}));
- Calendar cal = _monthView.getCalendar();
- cal.setTime(getLinkDay());
- putValue(NAME, getLinkFormat().format(new Object[] {cal.getTime()}));
- }
-
- @Override
- public void actionPerformed(ActionEvent ae) {
- String key = select ? JXDateTimePicker.HOME_COMMIT_KEY : JXDateTimePicker.HOME_NAVIGATE_KEY;
- select = false;
- Action delegate = getActionMap().get(key);
- /*
- * PatrykRy: Commit today date only when commit action is enabled.
- * Home navigate is always enabled.
- */
- if (delegate != null && delegate.isEnabled()) {
- delegate.actionPerformed(null);
- }
-
- }
- }
- }
-
-
-}
-
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/LobHelper.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/LobHelper.java
index 2571cbabc..c83e0d4c1 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/util/LobHelper.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/util/LobHelper.java
@@ -24,7 +24,6 @@
import java.util.Comparator;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.jdesktop.swingx.renderer.StringValue;
public class LobHelper {
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/StringValue.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/StringValue.java
new file mode 100644
index 000000000..99c9cd3ae
--- /dev/null
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/util/StringValue.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.db.dataview.util;
+
+public interface StringValue {
+ public String getString(Object o);
+}
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/TimeType.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/TimeType.java
index e36f5dcd6..ba38bea95 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/util/TimeType.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/util/TimeType.java
@@ -42,9 +42,7 @@
new SimpleDateFormat (DEFAULT_FOMAT_PATTERN),
DateFormat.getTimeInstance(),
DateFormat.getTimeInstance(DateFormat.SHORT),
- DateFormat.getTimeInstance(DateFormat.LONG, TimestampType.LOCALE),
- DateFormat.getTimeInstance(DateFormat.SHORT, TimestampType.LOCALE),
- new SimpleDateFormat("HH:mm:ss", TimestampType.LOCALE), // NOI18N
+ new SimpleDateFormat("HH:mm"), // NOI18N
};
{
diff --git a/db.dataview/src/org/netbeans/modules/db/dataview/util/TimestampType.java b/db.dataview/src/org/netbeans/modules/db/dataview/util/TimestampType.java
index fdfce2aef..3c528c00a 100644
--- a/db.dataview/src/org/netbeans/modules/db/dataview/util/TimestampType.java
+++ b/db.dataview/src/org/netbeans/modules/db/dataview/util/TimestampType.java
@@ -37,19 +37,17 @@
*/
public class TimestampType {
// Irrespective of the JVM's Locale lets pick a Locale for use on any JVM
- public static final Locale LOCALE = Locale.UK;
public static final String DEFAULT_FORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS"; // NOI18N
private static final DateFormat[] TIMESTAMP_PARSING_FORMATS = new DateFormat[]{
new SimpleDateFormat (DEFAULT_FORMAT_PATTERN),
- DateFormat.getDateTimeInstance(),
- DateFormat.getTimeInstance(DateFormat.SHORT),
- DateFormat.getTimeInstance(DateFormat.LONG, LOCALE),
- DateFormat.getTimeInstance(DateFormat.SHORT, LOCALE),
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"), // NOI18N
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), // NOI18N
+ DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault()),
+ new SimpleDateFormat("yyyy-MM-dd HH:mm"), // NOI18N
new SimpleDateFormat("yyyy-MM-dd"), // NOI18N
+ DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()),
new SimpleDateFormat("MM-dd-yyyy"), // NOI18N
new SimpleDateFormat("HH:mm:ss"), // NOI18N
+ new SimpleDateFormat("HH:mm"), // NOI18N
+ DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault())
};
{
@@ -78,7 +76,7 @@ public static Timestamp convert(Object value) throws DBException {
}
}
- private synchronized static Date doParse (String sVal) {
+ public synchronized static Date doParse (String sVal) {
Date dVal = null;
for (DateFormat format : TIMESTAMP_PARSING_FORMATS) {
try {
diff --git a/db.dataview/test/unit/data/etc/dbdel.sql b/db.dataview/test/unit/data/etc/dbdel.sql
index 328d8093f..eaf436233 100644
--- a/db.dataview/test/unit/data/etc/dbdel.sql
+++ b/db.dataview/test/unit/data/etc/dbdel.sql
@@ -14,4 +14,4 @@
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
-drop table IF EXISTS CASCADE simpletable;
\ No newline at end of file
+drop table IF EXISTS simpletable CASCADE;
\ No newline at end of file
diff --git a/db.dataview/test/unit/data/etc/dbprop.properties b/db.dataview/test/unit/data/etc/dbprop.properties
index 9e0c2e3b1..ea88cc0a4 100644
--- a/db.dataview/test/unit/data/etc/dbprop.properties
+++ b/db.dataview/test/unit/data/etc/dbprop.properties
@@ -16,9 +16,9 @@
# under the License.
#driver_class_name=com.mysql.jdbc.Driver
-driver_class_name=org.axiondb.jdbc.AxionDriver
+driver_class_name=org.h2.Driver
#url=jdbc:mysql://jbrave-pc1.sfbay:3306/travel
-url=jdbc:axiondb:db:build/testDB
+url=jdbc:h2:mem:testDB
user=sa
password=sa
#user=travel
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/meta/DBMetaDataFactoryTest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/meta/DBMetaDataFactoryTest.java
index 71949f01d..c30d5e973 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/meta/DBMetaDataFactoryTest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/meta/DBMetaDataFactoryTest.java
@@ -68,7 +68,7 @@ public void testConstructor(){
try {
DatabaseMetaData meta = conn.getMetaData();
assertNotNull(dbMeta);
- assertEquals("jdbc:axiondb:db:build/testDB", meta.getURL());
+ assertEquals("jdbc:h2:mem:testDB", meta.getURL());
} catch (SQLException ex) {
Exceptions.printStackTrace(ex);
}
@@ -86,7 +86,7 @@ public void testConstructor(){
* Test of getDBType method, of class DBMetaDataFactory.
*/
public void testGetDBType() throws Exception {
- int expResult = 8;
+ int expResult = 3;
int result = dbMeta.getDBType();
assertEquals(expResult, result);
}
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/meta/DBTableTest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/meta/DBTableTest.java
index b4083e418..b7a4e1eed 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/meta/DBTableTest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/meta/DBTableTest.java
@@ -24,6 +24,7 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import org.netbeans.api.db.explorer.DatabaseConnection;
+import org.netbeans.api.db.sql.support.SQLIdentifiers;
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.db.dataview.util.DbUtil;
import org.netbeans.modules.db.dataview.util.TestCaseContext;
@@ -35,7 +36,7 @@
*/
public class DBTableTest extends NbTestCase {
- DBTable table;
+ private DBTable table;
private TestCaseContext context;
private DatabaseConnection dbconn;
private Connection conn;
@@ -76,6 +77,7 @@ protected void createTable(){
String aSchema = rsMeta.getSchemaName(1);
String aCatalog = rsMeta.getCatalogName(1);
table = new DBTable(aName, aSchema, aCatalog);
+ table.setQuoter(SQLIdentifiers.createQuoter(conn.getMetaData()));
//table.setQuoter(quoter);
} catch (SQLException ex) {
Exceptions.printStackTrace(ex);
@@ -97,7 +99,7 @@ public void testAddColumn() throws Exception {
* Test of getCatalog method, of class DBTable.
*/
public void testGetCatalog() {
- String expResult = "";
+ String expResult = "TESTDB";
String result = table.getCatalog();
assertEquals(expResult, result);
}
@@ -106,7 +108,7 @@ public void testGetCatalog() {
* Test of getDisplayName method, of class DBTable.
*/
public void testGetDisplayName() {
- String expResult = "SIMPLETABLE";
+ String expResult = "TESTDB.\"PUBLIC\".SIMPLETABLE";
String result = table.getDisplayName();
assertEquals(expResult, result);
}
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/DataViewDBTableTest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/DataViewDBTableTest.java
index c471eb9f9..ca10e803c 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/DataViewDBTableTest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/DataViewDBTableTest.java
@@ -36,7 +36,7 @@
*/
public class DataViewDBTableTest extends NbTestCase {
- Collection<DBTable> tables;
+ private Collection<DBTable> tables;
private TestCaseContext context;
private DatabaseConnection dbconn;
private Connection conn;
@@ -116,7 +116,7 @@ public void testGetFullyQualifiedName() {
String sqlStr = context.getSqlSelect();
DataView dv = DataView.create(dbconn, sqlStr, index);
DataViewDBTable instance = dv.getPageContext(0).getTableMetaData();
- String expResult = "SIMPLETABLE";
+ String expResult = "TESTDB.\"PUBLIC\".SIMPLETABLE";
String result = instance.getFullyQualifiedName(0, false);
assertEquals(expResult, result);
}
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/DataViewTest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/DataViewTest.java
index 52c50f580..3208c1204 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/DataViewTest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/DataViewTest.java
@@ -173,9 +173,8 @@ public void testGetSQLString() {
String sqlStr = context.getSqlSelect();
int pagSize = 4;
DataView instance = DataView.create(dbconn, sqlStr, pagSize);
- String expResult = "select * from simpletable";
String result = instance.getSQLString();
- assertEquals(expResult, result);
+ assertEquals(sqlStr, result);
}
/**
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/InsertRecordTableUITest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/InsertRecordTableUITest.java
index c91159a1b..0df1ad687 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/InsertRecordTableUITest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/InsertRecordTableUITest.java
@@ -20,6 +20,8 @@
import java.sql.Connection;
import java.sql.Date;
+import java.util.Collections;
+import javax.swing.RowSorter;
import javax.swing.SortOrder;
import org.netbeans.api.db.explorer.DatabaseConnection;
import org.netbeans.junit.MockServices;
@@ -93,7 +95,7 @@ public Void run() {
ird.insertRecordTableUI.setValueAt(
new Date(new java.util.Date().getTime()), 1, 5);
try {
- ird.insertRecordTableUI.setSortOrder(5, SortOrder.ASCENDING);
+ ird.insertRecordTableUI.getRowSorter().setSortKeys(Collections.singletonList(new RowSorter.SortKey(5, SortOrder.ASCENDING)));
} catch (ClassCastException ex) {
assert false : "Bug 219011 - should not be reached!";
}
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/SQLStatementExecutorTest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/SQLStatementExecutorTest.java
index be8f31472..2e01b6826 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/SQLStatementExecutorTest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/output/SQLStatementExecutorTest.java
@@ -39,6 +39,7 @@
public class SQLStatementExecutorTest extends NbTestCase {
private TestCaseContext context;
private DatabaseConnection dbconn;
+ private Connection conn;
public SQLStatementExecutorTest(String testName) {
super(testName);
@@ -55,6 +56,7 @@ protected void setUp() throws Exception {
MockServices.setServices(new DBConnectionProviderImpl().getClass());
context = DbUtil.getContext();
dbconn = DbUtil.getDBConnection();
+ conn = DbUtil.getjdbcConnection();
DbUtil.createTable();
}
@@ -66,10 +68,12 @@ protected void tearDown() throws Exception {
}
public void testSQLExecutionHelper(){
+ final String sqlStr = context.getSqlUpdate();
+ DataView dv = null;
try {
int pageSize = 5;
- final String sqlStr = context.getSqlUpdate();
- DataView dv = DataView.create(dbconn, sqlStr, pageSize);
+
+ dv = DataView.create(dbconn, sqlStr, pageSize);
SQLStatementExecutor executor = new SQLStatementExecutor(dv, NbBundle.getMessage(SQLExecutionHelper.class, "LBL_sql_insert"), "", true) {
@Override
@@ -85,12 +89,10 @@ public void execute() throws SQLException, DBException {
}
};
executor.execute();
- assertEquals(1, dv.getUpdateCount());
- assertEquals(sqlStr, dv.getSQLString());
- } catch (SQLException ex) {
- Exceptions.printStackTrace(ex);
- } catch (DBException ex) {
+ } catch (SQLException | DBException ex) {
Exceptions.printStackTrace(ex);
}
+ assertEquals(1, dv.getUpdateCount());
+ assertEquals(sqlStr, dv.getSQLString());
}
}
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImplTest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImplTest.java
index 185c282b8..1e93cdb1a 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImplTest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImplTest.java
@@ -62,7 +62,7 @@ public void testGetConnection() {
DBConnectionProviderImpl instance = new DBConnectionProviderImpl();
Connection result = instance.getConnection(dbconn);
assertNotNull(result);
- assertEquals("AxionDB", result.getMetaData().getDatabaseProductName());
+ assertEquals("H2", result.getMetaData().getDatabaseProductName());
result.close();
} catch (SQLException ex) {
Exceptions.printStackTrace(ex);
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DateTypeTest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DateTypeTest.java
index 7b3389f45..fe11a9cad 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DateTypeTest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DateTypeTest.java
@@ -33,7 +33,7 @@
* @author navaneeth
*/
public class DateTypeTest extends NbTestCase {
- private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", TimestampType.LOCALE);
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
private long now = System.currentTimeMillis();
private long expectedMillis = 0l;
private DateType type = null;
@@ -111,11 +111,11 @@ public void testConvertStringTypes() throws Exception {
// savings)
);
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG,
- TimestampType.LOCALE);
+ Locale.UK);
fmt.setTimeZone(TimeZone.getDefault());
assertEquals("Make sure 'expected' is as expected",
"01 August 2002 12:00:00 "
- + TimeZone.getDefault().getDisplayName(true, TimeZone.SHORT, TimestampType.LOCALE),
+ + TimeZone.getDefault().getDisplayName(true, TimeZone.SHORT, Locale.UK),
fmt.format(expectedDate));
String toConvert = DATE_FORMAT.format(expectedDate);
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java
index 593e67cc7..c0a3a06a2 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java
@@ -40,11 +40,12 @@
*/
public class DbUtil {
- public static String URL = "url";
- public static String USER = "user";
- public static String PASSWORD = "password";
- public static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
- private static List<Connection> localConnectionList = new ArrayList<Connection>();
+ public static final String URL = "url";
+ public static final String USER = "user";
+ public static final String PASSWORD = "password";
+ public static final String DRIVER_CLASS_NAME = "driver_class_name";
+ private static final String TEST_DB_DRIVER_CLASS = getContext().getProperties().getProperty(DRIVER_CLASS_NAME);
+ private static final List<Connection> localConnectionList = new ArrayList<Connection>();
public static DatabaseConnection getDBConnection() {
try {
@@ -56,10 +57,15 @@ public static DatabaseConnection getDBConnection() {
list.add(Utilities.toURI(jars[i]).toURL());
}
URL[] urls = list.toArray(new URL[0]);
- Class.forName(AXION_DRIVER);
- JDBCDriver driver = JDBCDriver.create(AXION_DRIVER, "MashupDB", AXION_DRIVER, urls);
- DatabaseConnection dbconn = DatabaseConnection.create(driver, prop.getProperty("url"), prop.getProperty("user"),
- "", prop.getProperty("password"), true);
+ Class.forName(TEST_DB_DRIVER_CLASS);
+ JDBCDriver driver = JDBCDriver.create(TEST_DB_DRIVER_CLASS, "MashupDB", TEST_DB_DRIVER_CLASS, urls);
+ DatabaseConnection dbconn = DatabaseConnection.create(
+ driver,
+ prop.getProperty("url"),
+ prop.getProperty("user"),
+ "",
+ prop.getProperty("password"),
+ true);
return dbconn;
} catch (Exception ex) {
ex.printStackTrace();
@@ -81,8 +87,8 @@ public static Connection getjdbcConnection() {
private static JDBCDriver registerDriver(String driverName) throws Exception {
JDBCDriver drv;
- if (driverName.equals(AXION_DRIVER)) {
- drv = registerAxionDriverInstance();
+ if (driverName.equals(TEST_DB_DRIVER_CLASS)) {
+ drv = registerTestDBDriverInstance();
} else {
drv = registerDriverInstance(driverName);
}
@@ -235,8 +241,8 @@ public static JDBCDriver registerDriverInstance(final String driverName) throws
} catch (Exception ex) {
throw new Exception("Invalid driver name specified.");
}
- if (driverName.equals(AXION_DRIVER)) {
- driver = registerAxionDriverInstance();
+ if (driverName.equals(TEST_DB_DRIVER_CLASS)) {
+ driver = registerTestDBDriverInstance();
} else {
if (drivers.length == 0) {
throw new Exception("Specified JDBC Driver not found in DB Explorer: " + driverName);
@@ -247,11 +253,10 @@ public static JDBCDriver registerDriverInstance(final String driverName) throws
return driver;
}
- private static JDBCDriver registerAxionDriverInstance() throws Exception {
+ private static JDBCDriver registerTestDBDriverInstance() throws Exception {
JDBCDriver driver = null;
- String driverName = AXION_DRIVER;
TestCaseContext cxt = getContext();
- JDBCDriver[] drivers = JDBCDriverManager.getDefault().getDrivers(driverName);
+ JDBCDriver[] drivers = JDBCDriverManager.getDefault().getDrivers(TEST_DB_DRIVER_CLASS);
if (drivers.length == 0) {
// if axion db driver not available in db explorer, add it.
//URL[] url = new URL[1];
@@ -261,12 +266,12 @@ private static JDBCDriver registerAxionDriverInstance() throws Exception {
list.add(Utilities.toURI(jars[i]).toURL());
}
URL[] url = list.toArray(new URL[0]);
- driver = JDBCDriver.create(driverName, "Mashup DB", driverName, url);
+ driver = JDBCDriver.create(DRIVER_CLASS_NAME, "Mashup DB", DRIVER_CLASS_NAME, url);
JDBCDriverManager.getDefault().addDriver(driver);
}
if (driver == null) {
for (int i = 0; i < drivers.length; i++) {
- if (drivers[i].getClassName().equals(driverName)) {
+ if (drivers[i].getClassName().equals(DRIVER_CLASS_NAME)) {
driver = drivers[i];
break;
}
@@ -314,7 +319,7 @@ public static String unifyPath(String workDir) {
return workDir;
}
- public static TestCaseContext getContext() {
+ public static TestCaseContext getContext() {
try {
TestCaseDataFactory tfactory = TestCaseDataFactory.getTestCaseFactory();
TestCaseContext context = (TestCaseContext) tfactory.getTestCaseContext()[0];
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseContext.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseContext.java
index 69765d607..25a970fac 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseContext.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseContext.java
@@ -23,10 +23,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Properties;
/**
@@ -129,11 +126,12 @@ private String getContent(File f) throws Exception{
String s;
while((s=br.readLine())!=null){
sb.append(s);
+ sb.append("\n");
}
if(sb.length()==0) {
throw new RuntimeException(name+": File called "+f.getName()+" doesn't contain the data.");
}
- return sb.toString();
+ return sb.toString().trim();
}
@Override
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseDataFactory.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseDataFactory.java
index 76cc69662..465c34d27 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseDataFactory.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TestCaseDataFactory.java
@@ -35,26 +35,23 @@
*/
public class TestCaseDataFactory {
- public static String DB_SQLCREATE="dbcreate.sql";
- public static String DB_SQLINSERT="dbinsert.sql";
- public static String DB_SQLSELECT="dbselect.sql";
- public static String DB_SQLUPDATE="dbupdate.sql";
- public static String DB_DATA= "dbdata.properties";
- public static String DB_PROP= "dbprop.properties";
- public static String DB_SQLDEL="dbdel.sql";
- public static String DB_JARS="jar";
- public static String[] FILES={DB_SQLCREATE,DB_SQLINSERT,DB_SQLUPDATE,DB_PROP,DB_SQLDEL,DB_SQLSELECT,DB_DATA};
- private List<TestCaseContext> list=new ArrayList<TestCaseContext>();
+ public static final String DB_SQLCREATE="dbcreate.sql";
+ public static final String DB_SQLINSERT="dbinsert.sql";
+ public static final String DB_SQLSELECT="dbselect.sql";
+ public static final String DB_SQLUPDATE="dbupdate.sql";
+ public static final String DB_DATA= "dbdata.properties";
+ public static final String DB_PROP= "dbprop.properties";
+ public static final String DB_SQLDEL="dbdel.sql";
+ public static final String DB_JARS="jar";
+ public static final String[] FILES={DB_SQLCREATE,DB_SQLINSERT,DB_SQLUPDATE,DB_PROP,DB_SQLDEL,DB_SQLSELECT,DB_DATA};
+ private final List<TestCaseContext> list=new ArrayList<>();
private static TestCaseDataFactory factory;
- public static TestCaseDataFactory getTestCaseFactory() throws Exception{
-
- if(factory==null){
-
- factory=new TestCaseDataFactory();
- factory.process();
-
- }
+ public static TestCaseDataFactory getTestCaseFactory() throws Exception {
+ if (factory == null) {
+ factory = new TestCaseDataFactory();
+ factory.process();
+ }
return factory;
}
@@ -78,7 +75,7 @@ private File getDataDir() throws URISyntaxException {
private void process() throws Exception{
File data_dir = getDataDir();
- HashMap<String, Object> map = new HashMap<String, Object>();
+ HashMap<String, Object> map = new HashMap<>();
File etcDir = new File(data_dir, "etc");
for (int index = 0; index < FILES.length; index++) {
File f = new File(etcDir, FILES[index]);
@@ -87,22 +84,16 @@ private void process() throws Exception{
}
map.put(FILES[index], f);
}
- String[] s = etcDir.list(new FilenameFilter() {
+ File[] drivers = new File(data_dir, "../../../../external").listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
- return name.endsWith(".jar") || name.endsWith(".zip") ? true : false;
+ return name.endsWith(".jar") || name.endsWith(".zip");
}
});
- if (s.length == 0) {
+ if (drivers == null || drivers.length == 0) {
throw new RuntimeException("the driver doesn't exist in folder: " + etcDir);
}
- ArrayList<File> drivers = new ArrayList<File>();
- for (int myint = 0; myint < s.length; myint++) {
- File file = new File(etcDir, s[myint]);
- drivers.add(file);
-
- }
- map.put(DB_JARS, drivers.toArray(new File[0]));
+ map.put(DB_JARS, drivers);
TestCaseContext context = new TestCaseContext(map, etcDir.getName());
list.add(context);
diff --git a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TimeTypeTest.java b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TimeTypeTest.java
index 31e26463b..a7c2084b3 100644
--- a/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TimeTypeTest.java
+++ b/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/TimeTypeTest.java
@@ -22,6 +22,7 @@
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Locale;
import java.util.TimeZone;
import org.netbeans.junit.NbTestCase;
@@ -94,7 +95,7 @@ public void testConvertStringTypes() throws Exception {
// 12:00 PM
expectedTime = TimeType.convert (new Time (new Long (expectedTime.getTime () + 12 * 60 * 60 * 1000L)));
DateFormat fmt = DateFormat.getTimeInstance(DateFormat.LONG,
- TimestampType.LOCALE);
+ Locale.UK);
fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
assertEquals("Make sure 'expected' is as expected", "12:00:00 GMT", fmt.format(expectedTime));
diff --git a/libs.swingx/build.xml b/libs.swingx/build.xml
deleted file mode 100644
index 0079f9aa2..000000000
--- a/libs.swingx/build.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<project name="libs.swingx" default="netbeans" basedir=".">
- <import file="../nbbuild/templates/projectized.xml"/>
-</project>
diff --git a/libs.swingx/external/swingx-all-1.6.4-license.txt b/libs.swingx/external/swingx-all-1.6.4-license.txt
deleted file mode 100644
index 2a4f4fce3..000000000
--- a/libs.swingx/external/swingx-all-1.6.4-license.txt
+++ /dev/null
@@ -1,516 +0,0 @@
-Name: SwingX
-Version: 1.6.3
-License: LGPL-2.1
-Files: swingx-all-1.6.4.jar
-
-Copyright (c) 2005-2006 Sun Microsystems, Inc., 4150 Network Circle, Santa
-Clara, California 95054, U.S.A. All rights reserved. Use is subject
-to license terms below. Sun, Sun Microsystems and the Sun logo are
-trademarks or registered trademarks of Sun Microsystems, Inc. in the
-U.S. and other countries.
-
-Notice: This product is covered by U.S. export control laws and may be
-subject to the export or import laws in other countries. These laws may
-restrict the fields of use for this software and may require you to
-secure government authorization.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 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.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-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 and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, 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 library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete 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 distribute a copy of this License along with the
-Library.
-
- 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 Library or any portion
-of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-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 Library, 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 Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you 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.
-
- If distribution of 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 satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be 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.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library 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.
-
- 9. 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 Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-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 with
-this License.
-
- 11. 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 Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library 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 Library.
-
-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.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library 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.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser 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 Library
-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 Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-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
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "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
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. 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 LIBRARY 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
-LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. 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 library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; 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.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
diff --git a/libs.swingx/manifest.mf b/libs.swingx/manifest.mf
deleted file mode 100644
index a8bc64f0c..000000000
--- a/libs.swingx/manifest.mf
+++ /dev/null
@@ -1,6 +0,0 @@
-Manifest-Version: 1.0
-AutoUpdate-Show-In-Client: false
-OpenIDE-Module: org.netbeans.libs.swingx/1
-OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/swingx/Bundle.properties
-AutoUpdate-Essential-Module: true
-OpenIDE-Module-Specification-Version: 1.28
diff --git a/libs.swingx/nbproject/project.properties b/libs.swingx/nbproject/project.properties
deleted file mode 100644
index 70da85d98..000000000
--- a/libs.swingx/nbproject/project.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-release.external/swingx-all-1.6.4.jar=modules/ext/swingx-all-1.6.4.jar
-sigtest.gen.fail.on.error=false
-
diff --git a/libs.swingx/nbproject/project.xml b/libs.swingx/nbproject/project.xml
deleted file mode 100644
index 9b3c10166..000000000
--- a/libs.swingx/nbproject/project.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<project xmlns="http://www.netbeans.org/ns/project/1">
- <type>org.netbeans.modules.apisupport.project</type>
- <configuration>
- <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
- <code-name-base>org.netbeans.libs.swingx</code-name-base>
- <module-dependencies/>
- <friend-packages>
- <friend>org.netbeans.modules.db.dataview</friend>
- <friend>org.netbeans.modules.team.ide</friend>
- <friend>org.netbeans.modules.kenai.ui</friend>
- <friend>org.netbeans.modules.css.visual</friend>
- <package>org.jdesktop.beans</package>
- <package>org.jdesktop.swingx</package>
- <package>org.jdesktop.swingx.action</package>
- <package>org.jdesktop.swingx.auth</package>
- <package>org.jdesktop.swingx.autocomplete</package>
- <package>org.jdesktop.swingx.autocomplete.workarounds</package>
- <package>org.jdesktop.swingx.border</package>
- <package>org.jdesktop.swingx.calendar</package>
- <package>org.jdesktop.swingx.color</package>
- <package>org.jdesktop.swingx.combobox</package>
- <package>org.jdesktop.swingx.decorator</package>
- <package>org.jdesktop.swingx.error</package>
- <package>org.jdesktop.swingx.event</package>
- <package>org.jdesktop.swingx.geom</package>
- <package>org.jdesktop.swingx.graphics</package>
- <package>org.jdesktop.swingx.hyperlink</package>
- <package>org.jdesktop.swingx.icon</package>
- <package>org.jdesktop.swingx.image</package>
- <package>org.jdesktop.swingx.multislider</package>
- <package>org.jdesktop.swingx.multisplitpane</package>
- <package>org.jdesktop.swingx.painter</package>
- <package>org.jdesktop.swingx.painter.effects</package>
- <package>org.jdesktop.swingx.plaf</package>
- <package>org.jdesktop.swingx.plaf.basic</package>
- <package>org.jdesktop.swingx.plaf.basic.core</package>
- <package>org.jdesktop.swingx.plaf.linux</package>
- <package>org.jdesktop.swingx.plaf.macosx</package>
- <package>org.jdesktop.swingx.plaf.metal</package>
- <package>org.jdesktop.swingx.plaf.misc</package>
- <package>org.jdesktop.swingx.plaf.motif</package>
- <package>org.jdesktop.swingx.plaf.nimbus</package>
- <package>org.jdesktop.swingx.plaf.synth</package>
- <package>org.jdesktop.swingx.plaf.windows</package>
- <package>org.jdesktop.swingx.prompt</package>
- <package>org.jdesktop.swingx.renderer</package>
- <package>org.jdesktop.swingx.rollover</package>
- <package>org.jdesktop.swingx.search</package>
- <package>org.jdesktop.swingx.sort</package>
- <package>org.jdesktop.swingx.table</package>
- <package>org.jdesktop.swingx.text</package>
- <package>org.jdesktop.swingx.tips</package>
- <package>org.jdesktop.swingx.tree</package>
- <package>org.jdesktop.swingx.treetable</package>
- <package>org.jdesktop.swingx.util</package>
- </friend-packages>
- <class-path-extension>
- <runtime-relative-path>ext/swingx-all-1.6.4.jar</runtime-relative-path>
- <binary-origin>external/swingx-all-1.6.4.jar</binary-origin>
- </class-path-extension>
- </data>
- </configuration>
-</project>
diff --git a/libs.swingx/src/org/netbeans/libs/swingx/Bundle.properties b/libs.swingx/src/org/netbeans/libs/swingx/Bundle.properties
deleted file mode 100644
index a75d78b5e..000000000
--- a/libs.swingx/src/org/netbeans/libs/swingx/Bundle.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-## libs/swing-layout/manifest.mf
-OpenIDE-Module-Name=SwingX
-OpenIDE-Module-Display-Category=Libraries
-OpenIDE-Module-Short-Description=Bundles SwingX library.
-OpenIDE-Module-Long-Description=This module bundles SwingX library.
diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties
index 6cbb9a942..e0bf2fc8d 100644
--- a/nbbuild/cluster.properties
+++ b/nbbuild/cluster.properties
@@ -411,7 +411,6 @@ nb.cluster.ide=\
libs.svnClientAdapter,\
libs.svnClientAdapter.javahl,\
libs.svnClientAdapter.svnkit,\
- libs.swingx,\
libs.xerces,\
localhistory,\
localtasks,\
diff --git a/team.commons/src/org/netbeans/modules/bugtracking/commons/UIUtils.java b/team.commons/src/org/netbeans/modules/bugtracking/commons/UIUtils.java
index a0b9ed2ec..9d487c89f 100644
--- a/team.commons/src/org/netbeans/modules/bugtracking/commons/UIUtils.java
+++ b/team.commons/src/org/netbeans/modules/bugtracking/commons/UIUtils.java
@@ -38,17 +38,20 @@
import java.awt.event.KeyEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
+import java.text.DateFormat;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.logging.Level;
import javax.swing.JComponent;
-import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.JTextField;
import javax.swing.JViewport;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
@@ -56,8 +59,6 @@
import javax.swing.event.AncestorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import javax.swing.text.DateFormatter;
-import javax.swing.text.DefaultFormatterFactory;
import org.netbeans.modules.team.ide.spi.IDEServices;
import org.openide.util.ChangeSupport;
import org.openide.util.Lookup;
@@ -388,23 +389,33 @@ public static int getLongestWordWidth(String header, String[] values, JComponent
return picker;
}
- private static class DummyDatePickerComponent extends JFormattedTextField implements IDEServices.DatePickerComponent {
+ private static class DummyDatePickerComponent extends JTextField implements IDEServices.DatePickerComponent {
- private static final DateFormatter formatter = new javax.swing.text.DateFormatter() {
-
- @Override
- public Object stringToValue (String text) throws java.text.ParseException {
- if (text == null || text.trim().isEmpty()) {
- return null;
- }
- return super.stringToValue(text);
- }
+ public static final DateFormat DEFAULT_FOMAT = DateFormat.getDateInstance(); // NOI18N
+ private static final DateFormat[] DATE_PARSING_FORMATS = new DateFormat[]{
+ DEFAULT_FOMAT,
+ DateFormat.getDateInstance(DateFormat.MEDIUM),
+ DateFormat.getDateInstance(DateFormat.SHORT),
+ new SimpleDateFormat("yyyy-MM-dd"), // NOI18N
+ new SimpleDateFormat("MM-dd-yyyy"), // NOI18N
};
- private final ChangeSupport support;
+ private Date oldValue;
+ private ChangeSupport support = new ChangeSupport(this);
+
+ @SuppressWarnings("OverridableMethodCallInConstructor")
DummyDatePickerComponent () {
- super(new DefaultFormatterFactory(formatter));
- support = new ChangeSupport(this);
+ super(13);
+ addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ Date newValue = getDate();
+ if(! Objects.equals(oldValue, newValue)) {
+ support.fireChange();
+ }
+ setDate(newValue);
+ }
+ });
}
@Override
@@ -414,33 +425,40 @@ public JComponent getComponent () {
@Override
public void setDate (Date date) {
- try {
- setText(formatter.valueToString(date));
- } catch (ParseException ex) {
- Support.LOG.log(Level.INFO, null, ex);
+ oldValue = date;
+ if(date == null) {
+ setText("");
+ } else {
+ setText(DEFAULT_FOMAT.format(date));
}
}
@Override
- public Date getDate () {
- try {
- return (Date) formatter.stringToValue(getText());
- } catch (ParseException ex) {
- Support.LOG.log(Level.INFO, null, ex);
+ public Date getDate() {
+ String value = getText().trim();
+ if(value.isEmpty()) {
return null;
}
+ for (DateFormat df : DATE_PARSING_FORMATS) {
+ try {
+ return df.parse(value);
+ } catch (ParseException ex) {
+ Support.LOG.log(Level.FINE, null, ex);
+ }
+ }
+ return null;
}
@Override
- public void addChangeListener (ChangeListener listener) {
+ public void addChangeListener(ChangeListener listener) {
support.addChangeListener(listener);
}
@Override
- public void removeChangeListener (ChangeListener listener) {
+ public void removeChangeListener(ChangeListener listener) {
support.removeChangeListener(listener);
}
-
+
@Override
public boolean allowsOpeningDaySelector () {
return false;
diff --git a/team.ide/nbproject/project.xml b/team.ide/nbproject/project.xml
index 02f869b61..1dc0f608e 100644
--- a/team.ide/nbproject/project.xml
+++ b/team.ide/nbproject/project.xml
@@ -35,15 +35,6 @@
</run-dependency>
</dependency>
<dependency>
- <code-name-base>org.netbeans.libs.swingx</code-name-base>
- <build-prerequisite/>
- <compile-dependency/>
- <run-dependency>
- <release-version>1</release-version>
- <specification-version>1.20</specification-version>
- </run-dependency>
- </dependency>
- <dependency>
<code-name-base>org.netbeans.modules.autoupdate.services</code-name-base>
<build-prerequisite/>
<compile-dependency/>
diff --git a/team.ide/src/org/netbeans/modules/team/ide/IDEServicesImpl.java b/team.ide/src/org/netbeans/modules/team/ide/IDEServicesImpl.java
index f92668f13..dc231617c 100644
--- a/team.ide/src/org/netbeans/modules/team/ide/IDEServicesImpl.java
+++ b/team.ide/src/org/netbeans/modules/team/ide/IDEServicesImpl.java
@@ -19,7 +19,8 @@
package org.netbeans.modules.team.ide;
-import java.awt.Dimension;
+import java.awt.Component;
+import java.awt.Graphics;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@@ -29,10 +30,9 @@
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.SwingUtilities;
-import org.jdesktop.swingx.icon.PainterIcon;
-import org.jdesktop.swingx.painter.BusyPainter;
import org.netbeans.api.autoupdate.InstallSupport;
import org.netbeans.api.autoupdate.OperationContainer;
import org.netbeans.api.autoupdate.UpdateElement;
@@ -286,7 +286,7 @@ public void openInFavorites(File workingDir) {
@Override
public DatePickerComponent createDatePicker () {
- return new JXDatePickerImpl();
+ return null;
}
@Override
@@ -356,24 +356,51 @@ public void openInStackAnalyzer(BufferedReader s) {
}
}
- private static class SwingXBusyIcon extends PainterIcon implements BusyIcon {
- private static final int SIZE = 16;
- private static final int POINTS = 8;
+ private static class SwingXBusyIcon implements BusyIcon {
+ //@StaticResource(searchClasspath=true)
+ private static final String ICON_PROGRESS_0 = "org/openide/awt/resources/quicksearch/progress_0.png"; // NOI18N
+ //@StaticResource(searchClasspath=true)
+ private static final String ICON_PROGRESS_1 = "org/openide/awt/resources/quicksearch/progress_1.png"; // NOI18N
+ //@StaticResource(searchClasspath=true)
+ private static final String ICON_PROGRESS_2 = "org/openide/awt/resources/quicksearch/progress_2.png"; // NOI18N
+ //@StaticResource(searchClasspath=true)
+ private static final String ICON_PROGRESS_3 = "org/openide/awt/resources/quicksearch/progress_3.png"; // NOI18N
+ //@StaticResource(searchClasspath=true)
+ private static final String ICON_PROGRESS_4 = "org/openide/awt/resources/quicksearch/progress_4.png"; // NOI18N
+ //@StaticResource(searchClasspath=true)
+ private static final String ICON_PROGRESS_5 = "org/openide/awt/resources/quicksearch/progress_5.png"; // NOI18N
+ //@StaticResource(searchClasspath=true)
+ private static final String ICON_PROGRESS_6 = "org/openide/awt/resources/quicksearch/progress_6.png"; // NOI18N
+ //@StaticResource(searchClasspath=true)
+ private static final String ICON_PROGRESS_7 = "org/openide/awt/resources/quicksearch/progress_7.png"; // NOI18N
+ private static final ImageIcon[] ICON_PROGRESS = new ImageIcon[]{
+ new ImageIcon(ICON_PROGRESS_0), new ImageIcon(ICON_PROGRESS_1), new ImageIcon(ICON_PROGRESS_2), new ImageIcon(ICON_PROGRESS_3),
+ new ImageIcon(ICON_PROGRESS_4), new ImageIcon(ICON_PROGRESS_5), new ImageIcon(ICON_PROGRESS_6), new ImageIcon(ICON_PROGRESS_7)
+ };
- private int currentFrame;
- private BusyPainter busyPainter;
+ private int currentFrame = 0;
SwingXBusyIcon() {
- super(new Dimension(SIZE, SIZE));
- busyPainter = new BusyPainter(SIZE);
- busyPainter.setPoints(POINTS);
- setPainter(busyPainter);
}
@Override
public void tick() {
- currentFrame = (currentFrame + 1) % POINTS;
- busyPainter.setFrame(currentFrame);
+ currentFrame = (currentFrame + 1) % ICON_PROGRESS.length;
+ }
+
+ @Override
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ ICON_PROGRESS[currentFrame].paintIcon(c, g, x, y);
+ }
+
+ @Override
+ public int getIconWidth() {
+ return ICON_PROGRESS[currentFrame].getIconWidth();
+ }
+
+ @Override
+ public int getIconHeight() {
+ return ICON_PROGRESS[currentFrame].getIconHeight();
}
}
}
diff --git a/team.ide/src/org/netbeans/modules/team/ide/JXDatePickerImpl.form b/team.ide/src/org/netbeans/modules/team/ide/JXDatePickerImpl.form
deleted file mode 100644
index c914999ab..000000000
--- a/team.ide/src/org/netbeans/modules/team/ide/JXDatePickerImpl.form
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-
-<Form version="1.4" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
- <AuxValues>
- <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
- <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
- <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
- <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
- <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
- <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
- <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
- </AuxValues>
-
- <Layout>
- <DimensionLayout dim="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="datePicker" min="-2" max="-2" attributes="0"/>
- </Group>
- </DimensionLayout>
- <DimensionLayout dim="1">
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="datePicker" min="-2" max="-2" attributes="0"/>
- </Group>
- </DimensionLayout>
- </Layout>
- <SubComponents>
- <Component class="org.jdesktop.swingx.JXDatePicker" name="datePicker">
- <Properties>
- <Property name="formats" type="[Ljava.text.DateFormat;" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
- <Connection code="new java.text.DateFormat[] { java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM) }" type="code"/>
- </Property>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="datePickerActionPerformed"/>
- </Events>
- </Component>
- </SubComponents>
-</Form>
diff --git a/team.ide/src/org/netbeans/modules/team/ide/JXDatePickerImpl.java b/team.ide/src/org/netbeans/modules/team/ide/JXDatePickerImpl.java
deleted file mode 100644
index 4fd2e481a..000000000
--- a/team.ide/src/org/netbeans/modules/team/ide/JXDatePickerImpl.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.team.ide;
-
-import java.awt.BorderLayout;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Date;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.event.ChangeListener;
-import org.jdesktop.swingx.JXMonthView;
-import org.netbeans.modules.team.ide.spi.IDEServices;
-import org.openide.DialogDisplayer;
-import org.openide.NotifyDescriptor;
-import org.openide.util.ChangeSupport;
-import org.openide.util.NbBundle;
-
-/**
- *
- * @author Ondrej Vrabec
- */
-public final class JXDatePickerImpl extends javax.swing.JPanel implements IDEServices.DatePickerComponent,
- PropertyChangeListener {
- private final ChangeSupport support;
-
- /**
- * Creates new form DatePickerImpl
- */
- public JXDatePickerImpl () {
- this.support = new ChangeSupport(this);
- initComponents();
- datePicker.getEditor().addPropertyChangeListener(this);
- }
-
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
-
- datePicker = new org.jdesktop.swingx.JXDatePicker();
-
- datePicker.setFormats(new java.text.DateFormat[] { java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM) });
- datePicker.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- datePickerActionPerformed(evt);
- }
- });
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- );
- }// </editor-fold>//GEN-END:initComponents
-
- private void datePickerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_datePickerActionPerformed
- support.fireChange();
- }//GEN-LAST:event_datePickerActionPerformed
-
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private org.jdesktop.swingx.JXDatePicker datePicker;
- // End of variables declaration//GEN-END:variables
-
- @Override
- public JComponent getComponent () {
- return this;
- }
-
- @Override
- public void setDate (Date date) {
- datePicker.setDate(date);
- }
-
- @Override
- public Date getDate () {
- return datePicker.getDate();
- }
-
- @Override
- public void addChangeListener (ChangeListener listener) {
- support.addChangeListener(listener);
- }
-
- @Override
- public void removeChangeListener (ChangeListener listener) {
- support.removeChangeListener(listener);
- }
-
- @Override
- public void propertyChange (PropertyChangeEvent evt) {
- if ("value".equals(evt.getPropertyName())) { //NOI18N
- if (evt.getOldValue() != null || evt.getNewValue() != null) {
- support.fireChange();
- }
- }
- }
-
- @Override
- public void setEnabled (boolean enabled) {
- super.setEnabled(enabled);
- datePicker.setEnabled(enabled);
- }
-
- @Override
- public boolean allowsOpeningDaySelector () {
- return true;
- }
-
- @Override
- @NbBundle.Messages({
- "LBL_ChooseDate=Choose Date"
- })
- public boolean openDaySelector () {
- JXMonthView monthView = datePicker.getMonthView();
- JPanel panel = new JPanel(new BorderLayout());
- panel.add(monthView);
- NotifyDescriptor nd = new NotifyDescriptor(
- panel,
- Bundle.LBL_ChooseDate(),
- NotifyDescriptor.OK_CANCEL_OPTION,
- NotifyDescriptor.PLAIN_MESSAGE,
- null,
- NotifyDescriptor.OK_OPTION);
- if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) {
- setDate(monthView.getSelectionDate());
- return true;
- } else {
- return false;
- }
- }
-}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services