visualvm-2.0.6/0000755000175000017500000000000013767155557011532 5ustar apoapovisualvm-2.0.6/LICENSE0000644000175000017500000004553313767155557012551 0ustar apoapoProject VisualVM The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. visualvm-2.0.6/README.md0000644000175000017500000000635013767155557013015 0ustar apoapo# VisualVM 2.0.6 sources repository VisualVM is a visual tool integrating commandline JDK tools and lightweight profiling capabilities. See https://visualvm.github.io for details, downloads and documentation. ## Get the tools Use Apache Ant 1.9.9 or above and Oracle JDK 8 to build VisualVM from this repository. ## Get the sources First download or clone this repository into directory `visualvm`. There are two project suites included: * visualvm (`visualvm/visualvm`) - suite for the core VisualVM tool * plugins (`visualvm/plugins`) - suite for the VisualVM plugins available in Plugins Center ## Configure the dependencies Then extract the [NetBeans Platform 11.3](visualvm/nb113_platform_27102020.zip) into directory `visualvm/visualvm` (should create `visualvm/visualvm/netbeans`). ## Build and run VisualVM tool To build VisualVM, use `ant build-zip` command in the `visualvm/visualvm` directory. To run VisualVM, use `ant run` command in the `visualvm/visualvm` directory. ## Build and run VisualVM plugins To build or run the plugins suite, use `ant build` or `ant run` in the `visualvm/plugins` directory. This will automatically build the zip distribution of the core VisualVM tool into `visualvm/visualvm/dist/visualvm.zip` and extract it into the `visualvm/plugins/visualvm` directory. After that the build of the plugins suite continues to build each of the individual plugins. Running the plugins suite means starting VisualVM with all the plugins installed. ## Generate the Maven artifacts First prepare the binaries: 1. Build VisualVM tool as described above 2. Expand/decompress the generated `visualvm.zip` file in `visualvm/dist`. 3. Generate the NBMs by running: `ant nbms`. This will generate a folder `build/updates` containing all the NBMs. To generate the artifacts use [`org.apache.netbeans.utilities:nb-repository-plugin`](https://bits.netbeans.org/mavenutilities/nb-repository-plugin/index.html). Make sure the current directory is still `visualvm/visualvm`. To install the artifacts into your local repository use the following command: ``` mvn \ -DnetbeansInstallDirectory=dist/visualvm \ -DnetbeansNbmDirectory=build/updates \ -DgroupIdPrefix=org.graalvm.visualvm \ -DforcedVersion=RELEASE206 \ org.apache.netbeans.utilities:nb-repository-plugin:populate ``` To publish the artifacts into a remote repository use the following command: ``` mvn -DnetbeansInstallDirectory=dist/visualvm \ -DnetbeansNbmDirectory=build/updates \ -DgroupIdPrefix=org.graalvm.visualvm \ -DforcedVersion=RELEASE206 \ -DdeployUrl= \ -DdeployId= \ -DskipInstall=true \ org.apache.netbeans.utilities:nb-repository-plugin:populate ``` For more information about `nb-repository-plugin` see https://bits.netbeans.org/mavenutilities/nb-repository-plugin/index.html ## Contribute We highly appreciate any feedback! Please let us know your ideas, missing features, or bugs found. Either [file a RFE/bug](https://github.com/oracle/visualvm/issues/new/choose) or [leave us a message](https://visualvm.github.io/feedback.html). For legal reasons, we cannot accept external pull requests. See [CONTRIBUTING](https://github.com/oracle/visualvm/blob/master/CONTRIBUTING.md) for details. visualvm-2.0.6/CONTRIBUTING.md0000644000175000017500000000173013767155557013764 0ustar apoapo# Contributing to VisualVM *Copyright © 2017, 2020, Oracle Corporation and/or its affiliates.* **Pull requests are currently not being accepted for the VisualVM project.** Please let us know your ideas, missing features, or bugs found. Either [file a RFE/bug](https://github.com/oracle/visualvm/issues/new/choose) or [leave us a message](https://visualvm.github.io/feedback.html). Any information, ideas or suggestions that you provide to us either through a Bug Report or a Feature Request ([https://github.com/oracle/visualvm/issues/new/choose](https://github.com/oracle/visualvm/issues/new/choose)) or using Gitter chat or email shall be considered Feedback. Oracle and its affiliates have a perpetual, royalty-free, non-exclusive, irrevocable license to use, reproduce, distribute or otherwise commercialize any Feedback that you voluntarily provide. Oracle shall have no obligation to respond to any Feedback or to incorporate your Feedback into the VisualVM software.visualvm-2.0.6/templates/0000755000175000017500000000000013767155557013530 5ustar apoapovisualvm-2.0.6/templates/apisupport/0000755000175000017500000000000013767155557015736 5ustar apoapovisualvm-2.0.6/templates/apisupport/build.xml0000644000175000017500000000100513767155557017553 0ustar apoapo Builds, tests, and runs the project org.graalvm.visualvm.apisupport. visualvm-2.0.6/templates/apisupport/javahelp/0000755000175000017500000000000013767155557017530 5ustar apoapovisualvm-2.0.6/templates/apisupport/javahelp/org/0000755000175000017500000000000013767155557020317 5ustar apoapovisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/0000755000175000017500000000000013767155557021750 5ustar apoapovisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/0000755000175000017500000000000013767155557023616 5ustar apoapovisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/0000755000175000017500000000000013767155557026024 5ustar apoapovisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/0000755000175000017500000000000013767155557026754 5ustar apoapo././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-map.xmlvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-map.x0000644000175000017500000000062713767155557032466 0ustar apoapo ././@LongLink0000644000000000000000000000014600000000000011604 Lustar rootrootvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-hs.xmlvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-hs.xm0000644000175000017500000000213013767155557032467 0ustar apoapo VisualVM View Help org.visualvm.visualvmview.about TOC javax.help.TOCView visualvmview-toc.xml Index javax.help.IndexView visualvmview-idx.xml Search javax.help.SearchView JavaHelpSearch ././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-toc.xmlvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-toc.x0000644000175000017500000000045613767155557032476 0ustar apoapo ././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-idx.xmlvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-idx.x0000644000175000017500000000061013767155557032465 0ustar apoapo ././@LongLink0000644000000000000000000000015200000000000011601 Lustar rootrootvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-about.htmlvisualvm-2.0.6/templates/apisupport/javahelp/org/graalvm/visualvm/apisupport/docs/visualvmview-about0000644000175000017500000000513113767155557032550 0ustar apoapo VisualVM View Wizard: Name and Location

VisualVM View Wizard: Name and Location

The VisualVM View wizard creates a new VisualVM View for a selected VisualVM data source. You open the New VisualVM View wizard by right-clicking a module project, choosing New > Other and selecting VisualVM View from the Module Development category.

In the Name and Location page, you have to set the following:

  • Prefix. Specifies the prefix for the new VisualVM classes that will be generated by the wizard. This value also sets the text in the view's tab.
  • Data Source. Specifies the data source for which you are creating the view:
    • Application
    • CoreDump
    • DataSource
    • HeapDump
    • Host
    • SnapShot
    • ThreadDump

    Note: If you select "DataSource", you will create a new view that will be shown for all data sources. Selecting any of the others will create a new view only for the specific data source that you selected.

  • Package Name. Specifies the name of the package where the generated classes will be created.

visualvm-2.0.6/templates/apisupport/manifest.mf0000644000175000017500000000033313767155557020067 0ustar apoapoManifest-Version: 1.0 OpenIDE-Module: org.graalvm.visualvm.apisupport OpenIDE-Module-Layer: org/graalvm/visualvm/apisupport/layer.xml OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/apisupport/Bundle.properties visualvm-2.0.6/templates/apisupport/src/0000755000175000017500000000000013767155557016525 5ustar apoapovisualvm-2.0.6/templates/apisupport/src/org/0000755000175000017500000000000013767155557017314 5ustar apoapovisualvm-2.0.6/templates/apisupport/src/org/graalvm/0000755000175000017500000000000013767155557020745 5ustar apoapovisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/0000755000175000017500000000000013767155557022613 5ustar apoapovisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/0000755000175000017500000000000013767155557025021 5ustar apoapovisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/0000755000175000017500000000000013767155557025752 5ustar apoapo././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/NameAndLocationPanel.formvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/NameAndLocationPanel.fo0000644000175000017500000003001313767155557032251 0ustar apoapo
././@LongLink0000644000000000000000000000015700000000000011606 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/templateVisualVMViewProvider.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/templateVisualVMViewPro0000644000175000017500000000434713767155557032463 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.application.Application; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.snapshot.Snapshot; import org.graalvm.visualvm.core.ui.DataSourceView; import org.graalvm.visualvm.core.ui.DataSourceViewProvider; import org.graalvm.visualvm.core.ui.DataSourceViewsManager; import org.graalvm.visualvm.core.ui.PluggableDataSourceViewProvider; import org.graalvm.visualvm.coredump.CoreDump; import org.graalvm.visualvm.heapdump.HeapDump; import org.graalvm.visualvm.host.Host; import org.graalvm.visualvm.threaddump.ThreadDump; import java.util.Set; public class ${TEMPLATENAME}ViewProvider extends PluggableDataSourceViewProvider<${DISPLAYNAME}> { private static class Singleton { final private static ${TEMPLATENAME}ViewProvider INSTANCE = new ${TEMPLATENAME}ViewProvider(); } private ${TEMPLATENAME}ViewProvider() {} // TODO adjust the view visibility @Override public boolean supportsViewFor(${DISPLAYNAME} my${DISPLAYNAME}) { //Always shown: return true; } @Override public synchronized DataSourceView createView(final ${DISPLAYNAME} my${DISPLAYNAME}) { return new ${TEMPLATENAME}View(my${DISPLAYNAME}) ; } public static ${TEMPLATENAME}ViewProvider getInstance() { return Singleton.INSTANCE; } /** * TODO Call this method from the module Installer#restored() **/ public static void install() { DataSourceViewsManager.sharedInstance().addViewProvider(Singleton.INSTANCE, ${DISPLAYNAME}.class); } /** * TODO Call this method from the module Installer#uninstalled() **/ public static void uninstall() { DataSourceViewsManager.sharedInstance().removeViewProvider(Singleton.INSTANCE); } @Override public Set getPluggableLocations(DataSourceView arg0) { // TODO update the view supported locations (DataViewComponent.TOP_LEFT, DataViewComponent.TOP_RIGHT, DataViewComponent.BOTTOM_LEFT, DataViewComponent.BOTTOM_RIGHT) return ALL_LOCATIONS; } } ././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/NameAndLocationPanel.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/NameAndLocationPanel.ja0000644000175000017500000003612213767155557032246 0ustar apoapo package org.graalvm.visualvm.apisupport.tabs; import java.awt.Color; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.NbModuleProject; import org.netbeans.modules.apisupport.project.ui.UIUtil; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.netbeans.modules.apisupport.project.universe.ModuleEntry; import org.netbeans.modules.apisupport.project.universe.NbPlatform; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.Utilities; /** * The second panel in project template wizard. * * @author Milos Kleint */ final class NameAndLocationPanel extends BasicWizardIterator.Panel { private static final String PROJECT_TEMPLATES_DIR = "Templates/Project"; // NOI18N private static final String DEFAULT_CATEGORY_PATH = PROJECT_TEMPLATES_DIR + "/Other"; // NOI18N private NewProjectIterator.DataModel data; /** Creates new NameAndLocationPanel */ NameAndLocationPanel(WizardDescriptor setting, NewProjectIterator.DataModel data) { super(setting); this.data = data; initComponents(); initAccessibility(); Color lblBgr = UIManager.getColor("Label.background"); // NOI18N putClientProperty("NewFileWizard_Title", getMessage("LBL_ProjectWizardTitle")); modifiedFilesValue.setBackground(lblBgr); createdFilesValue.setBackground(lblBgr); modifiedFilesValue.setEditable(false); createdFilesValue.setEditable(false); DocumentListener dListener = new UIUtil.DocumentAdapter() { public void insertUpdate(DocumentEvent e) { if (checkValidity()) { updateData(); } } }; txtName.getDocument().addDocumentListener(dListener); if (comCategory.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField) comCategory.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } } protected void storeToDataModel() { updateData(); } private void updateData() { data.setPackageName(comPackageName.getEditor().getItem().toString()); data.setName(txtName.getText().trim()); data.setCategory(comCategory.getEditor().getItem().toString()); NewProjectIterator.generateFileChanges(data); CreatedModifiedFiles fls = data.getCreatedModifiedFiles(); createdFilesValue.setText(generateText(fls.getCreatedPaths())); modifiedFilesValue.setText(generateText(fls.getModifiedPaths())); //#68294 check if the paths for newly created files are valid or not.. String[] invalid = data.getCreatedModifiedFiles().getInvalidPaths(); if (invalid.length > 0) { setError(NbBundle.getMessage(NameAndLocationPanel.class, "ERR_ToBeCreateFileExists", invalid[0])); } } protected void readFromDataModel() { checkValidity(); } protected String getPanelName() { return getMessage("LBL_NameLocation_Title"); } private boolean checkValidity() { // if (!checkPlatformValidity()) { // return false; // } if (txtName.getText().trim().length() == 0) { setError(getMessage("ERR_Name_Prefix_Empty")); return false; } if (!Utilities.isJavaIdentifier(txtName.getText().trim())) { setError(getMessage("ERR_Name_Prefix_Invalid")); return false; } String packageName = comPackageName.getEditor().getItem().toString().trim(); if (packageName.length() == 0 || !UIUtil.isValidPackageName(packageName)) { setError(getMessage("ERR_Package_Invalid")); return false; } markValid(); return true; } // private boolean checkPlatformValidity() { // NbModuleProject nbprj = data.getProject().getLookup().lookup(NbModuleProject.class); // if (nbprj == null) { // //ignore this check for non default netbeans projects. // return true; // } // NbPlatform platform = nbprj.getPlatform(false); // if (platform == null) { // setError(getMessage("ERR_No_Platform")); // return false; // } // ModuleEntry[] entries = platform.getModules(); // Collection modules = new HashSet(Arrays.asList(NewProjectIterator.MODULES)); // // for (int i = 0; i < entries.length; i++) { // modules.remove(entries[i].getCodeNameBase()); // } // if (modules.size() > 0) { // setError(getMessage("ERR_Missing_Modules")); // return false; // } // return true; // } protected HelpCtx getHelp() { return new HelpCtx(NameAndLocationPanel.class); } private static String getMessage(String key) { return NbBundle.getMessage(NameAndLocationPanel.class, key); } /** 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. */ // //GEN-BEGIN:initComponents private void initComponents() { lblName = new javax.swing.JLabel(); txtName = new javax.swing.JTextField(); lblDisplayName = new javax.swing.JLabel(); lblProjectName = new javax.swing.JLabel(); txtProjectName = new JTextField(ProjectUtils.getInformation(this.data.getProject()).getDisplayName()); lblPackageName = new javax.swing.JLabel(); comPackageName = UIUtil.createPackageComboBox(this.data.getSourceRootGroup()); createdFiles = new javax.swing.JLabel(); modifiedFiles = new javax.swing.JLabel(); filler = new javax.swing.JLabel(); createdFilesValue = new javax.swing.JTextArea(); modifiedFilesValue = new javax.swing.JTextArea(); comCategory = new javax.swing.JComboBox(); lblName.setLabelFor(txtName); org.openide.awt.Mnemonics.setLocalizedText(lblName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_Name_1")); // NOI18N lblDisplayName.setLabelFor(comCategory); org.openide.awt.Mnemonics.setLocalizedText(lblDisplayName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_DisplayName_1")); // NOI18N lblProjectName.setLabelFor(txtProjectName); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/graalvm/visualvm/apisupport/tabs/Bundle"); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lblProjectName, bundle.getString("LBL_ProjectName_1")); // NOI18N txtProjectName.setEditable(false); lblPackageName.setLabelFor(comPackageName); org.openide.awt.Mnemonics.setLocalizedText(lblPackageName, bundle.getString("LBL_PackageName_1")); // NOI18N comPackageName.setEditable(true); createdFiles.setLabelFor(createdFilesValue); org.openide.awt.Mnemonics.setLocalizedText(createdFiles, bundle.getString("LBL_CreatedFiles_1")); // NOI18N modifiedFiles.setLabelFor(modifiedFilesValue); org.openide.awt.Mnemonics.setLocalizedText(modifiedFiles, bundle.getString("LBL_ModifiedFiles_1")); // NOI18N createdFilesValue.setColumns(20); createdFilesValue.setRows(5); createdFilesValue.setBorder(null); modifiedFilesValue.setColumns(20); modifiedFilesValue.setRows(5); modifiedFilesValue.setToolTipText("modifiedFilesValue"); modifiedFilesValue.setBorder(null); comCategory.setEditable(true); comCategory.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Application", "CoreDump", "DataSource", "HeapDump", "Host", "Snapshot", "ThreadDump" })); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(layout.createSequentialGroup() .add(lblName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 64, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 54, Short.MAX_VALUE)) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(createdFiles, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(modifiedFiles, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(12, 12, 12) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(txtName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE) .add(comCategory, 0, 296, Short.MAX_VALUE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE) .add(comPackageName, 0, 296, Short.MAX_VALUE) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE))) .add(filler, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 400, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(layout.createSequentialGroup() .add(lblDisplayName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(323, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(2, 2, 2) .add(lblName)) .add(txtName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER) .add(lblDisplayName) .add(comCategory, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(comPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(36, 36, 36) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(createdFiles) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(modifiedFiles) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)) .add(filler, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 92, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(20, 20, 20)) ); }// //GEN-END:initComponents private void initAccessibility() { this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_NameAndLocationPanel")); comPackageName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_PackageName")); comCategory.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_DisplayName")); txtName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_Name")); txtProjectName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ProjectName")); createdFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_CreatedFilesValue")); modifiedFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ModifiedFilesValue")); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox comCategory; private javax.swing.JComboBox comPackageName; private javax.swing.JLabel createdFiles; private javax.swing.JTextArea createdFilesValue; private javax.swing.JLabel filler; private javax.swing.JLabel lblDisplayName; private javax.swing.JLabel lblName; private javax.swing.JLabel lblPackageName; private javax.swing.JLabel lblProjectName; private javax.swing.JLabel modifiedFiles; private javax.swing.JTextArea modifiedFilesValue; private javax.swing.JTextField txtName; private javax.swing.JTextField txtProjectName; // End of variables declaration//GEN-END:variables private static String generateText(String[] relPaths) { StringBuffer sb = new StringBuffer(); if (relPaths.length > 0) { for (int i = 0; i < relPaths.length; i++) { if (i > 0) { sb.append('\n'); } sb.append(relPaths[i]); } } return sb.toString(); } } ././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/templateVisualVMView.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/templateVisualVMView.ja0000644000175000017500000000454313767155557032371 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.application.Application; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.snapshot.Snapshot; import org.graalvm.visualvm.core.ui.DataSourceView; import org.graalvm.visualvm.core.ui.components.DataViewComponent; import org.graalvm.visualvm.coredump.CoreDump; import org.graalvm.visualvm.heapdump.HeapDump; import org.graalvm.visualvm.host.Host; import org.graalvm.visualvm.threaddump.ThreadDump; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JEditorPane; import javax.swing.JPanel; import org.openide.util.ImageUtilities; public class ${TEMPLATENAME}View extends DataSourceView { private DataViewComponent dvc; // TODO update the icon path private static final String IMAGE_PATH = "org/graalvm/visualvm/coredump/resources/coredump.png"; // NOI18N public ${TEMPLATENAME}View(${DISPLAYNAME} My${DISPLAYNAME}) { super(My${DISPLAYNAME}, "${TEMPLATENAME}", new ImageIcon(ImageUtilities.loadImage(IMAGE_PATH, true)).getImage(), 60, false); } @Override protected DataViewComponent createComponent() { //Data area for master view: JEditorPane generalDataArea = new JEditorPane(); generalDataArea.setBorder(BorderFactory.createEmptyBorder(14, 8, 14, 8)); //Panel, which we'll reuse in all four of our detail views for this sample: JPanel panel = new JPanel(); //Master view: DataViewComponent.MasterView masterView = new DataViewComponent.MasterView ("${TEMPLATENAME} Overview", null, generalDataArea); //Configuration of master view: DataViewComponent.MasterViewConfiguration masterConfiguration = new DataViewComponent.MasterViewConfiguration(false); //Add the master view and configuration view to the component: dvc = new DataViewComponent(masterView, masterConfiguration); // TODO adjust the details view properties //Add detail views to the component: dvc.addDetailsView(new DataViewComponent.DetailsView( "${TEMPLATENAME} Details", null, 10, panel, null), DataViewComponent.TOP_LEFT); return dvc; } } visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/NewProjectIterator.java0000644000175000017500000001300313767155557032404 0ustar apoapopackage org.graalvm.visualvm.apisupport.tabs; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.netbeans.api.project.Project; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; final class NewProjectIterator extends BasicWizardIterator { private NewProjectIterator.DataModel data; public static final String[] MODULES = { "org.openide.util", // NOI18N "org.graalvm.visualvm.core", // NOI18N "org.graalvm.visualvm.application", // NOI18N "org.graalvm.visualvm.coredump", // NOI18N "org.graalvm.visualvm.heapdump", // NOI18N "org.graalvm.visualvm.threaddump", // NOI18N "org.graalvm.visualvm.host" // NOI18N }; private NewProjectIterator() { /* Use factory method. */ } ; public static NewProjectIterator createIterator() { return new NewProjectIterator(); } public Set instantiate() throws IOException { CreatedModifiedFiles cmf = data.getCreatedModifiedFiles(); cmf.run(); return getCreatedFiles(cmf, data.getProject()); } protected BasicWizardIterator.Panel[] createPanels(WizardDescriptor wiz) { data = new NewProjectIterator.DataModel(wiz); return new BasicWizardIterator.Panel[]{ new NameAndLocationPanel(wiz, data) }; } public @Override void uninitialize( WizardDescriptor wiz) { super.uninitialize(wiz); data = null; } static final class DataModel extends BasicWizardIterator.BasicDataModel { private Project template; private String name; private String displayName; private String category; private CreatedModifiedFiles files; DataModel(WizardDescriptor wiz) { super(wiz); } public CreatedModifiedFiles getCreatedModifiedFiles() { return getFiles(); } public void setCreatedModifiedFiles(CreatedModifiedFiles files) { this.setFiles(files); } public Project getTemplate() { return template; } public void setTemplate(Project template) { this.template = template; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public CreatedModifiedFiles getFiles() { return files; } public void setFiles(CreatedModifiedFiles files) { this.files = files; } } public static void generateFileChanges(DataModel model) { CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject()); NbModuleProvider moduleInfo = model.getModuleInfo(); final String category = model.getCategory(); final String name = model.getName(); final String packageName = model.getPackageName(); HashMap replaceTokens = new HashMap(); replaceTokens.put("DISPLAYNAME", category);//NOI18N replaceTokens.put("TEMPLATENAME", name);//NOI18N replaceTokens.put("PACKAGENAME", packageName);//NOI18N // Update project dependencies for (int i = 0; i < MODULES.length; i++) { fileChanges.add(fileChanges.addModuleDependency(MODULES[i])); } // // Generate Support class: // String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, // name, "ViewSupport.java"); //NOI18N // // FileObject template = CreatedModifiedFiles.getTemplate("templateViewSupport.java");//NOI18N // // fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // // Generate view provider class: String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "ViewProvider.java"); //NOI18N FileObject template = CreatedModifiedFiles.getTemplate("templateViewProvider.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // Generate view class: iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "View.java"); //NOI18N template = CreatedModifiedFiles.getTemplate("templateView.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); model.setCreatedModifiedFiles(fileChanges); } private static String getRelativePath(String rootPath, String fullyQualifiedPackageName, String prefix, String postfix) { StringBuffer sb = new StringBuffer(); sb.append(rootPath).append('/'). append(fullyQualifiedPackageName.replace('.', '/')). append('/').append(prefix).append(postfix); return sb.toString(); } } ././@LongLink0000644000000000000000000000014600000000000011604 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/visualvmview-helpset.xmlvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/visualvmview-helpset.xm0000644000175000017500000000054213767155557032524 0ustar apoapo visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/visualVMView.html0000644000175000017500000000043313767155557031241 0ustar apoapo Creates a skeleton VisualVM tab. visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/tabs/Bundle.properties0000644000175000017500000000322613767155557031304 0ustar apoapo# To change this template, choose Tools | Templates # and open the template in the editor. Templates/VisualVMPluginDevelopment/tab=View (Tab) LBL_ProjectWizardTitle=VisualVM View (Tab) LBL_ProjectSelection_Title=Select Project LBL_NameLocation_Title=Name and Location LBL_ProjectName=&Project\: LBL_PackageName=Pac&kage\: LBL_CreatedFiles=&Created Files\: LBL_ModifiedFiles=&Modified Files\: ACS_SelectProjectPanel=Select Project panel ACS_CTL_btnProject=Browse Project button ACS_CTL_comProject=Select from opened projects combobox LBL_Name=&Template Name \: LBL_DisplayName=D&isplay Name \: LBL_Category=C&ategory LBL_Project_Label=&Project \: LBL_Browse=Bro&wse... ACS_NameAndLocationPanel=Name and Location Panel ACS_CTL_PackageName=Package Name ACS_CTL_Category=Category ACS_CTL_DisplayName=Display Name ACS_CTL_Name=Template Name ACS_CTL_ProjectName=Project Name ACS_CTL_CreatedFilesValue=Created Files ACS_CTL_ModifiedFilesValue=Modified Files MSG_No_Projects=No Projects opened MSG_NoExternalRoots=Projects with external roots are not supported. MSG_NoProjectSelected=A project needs to be selected. ERR_Category_Invalid=Category is malformed. ERR_Name_Prefix_Empty=Template Name is empty. ERR_Name_Prefix_Invalid=Template Name is invalid, not a Java identifier. ERR_Package_Invalid=Package is blank or malformed. ERR_ToBeCreateFileExists=The file {0} already exists. ERR_Missing_Modules=The NetBeans platform is missing required modules. ERR_No_Platform=No NetBeans Platform defined. LBL_Name_1=Name: LBL_DisplayName_1=Data Source: LBL_ProjectName_1=Project Name: LBL_PackageName_1=Package Name: LBL_CreatedFiles_1=Created Files: LBL_ModifiedFiles_1=Modified Files: visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/0000755000175000017500000000000013767155557026304 5ustar apoapo././@LongLink0000644000000000000000000000015100000000000011600 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/NameAndLocationPanel.formvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/NameAndLocationPanel.0000644000175000017500000002617113767155557032270 0ustar apoapo
././@LongLink0000644000000000000000000000016200000000000011602 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/templateVisualVMModelProvider.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/templateVisualVMModel0000644000175000017500000000240013767155557032446 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.model.AbstractModelProvider; public class ${TEMPLATENAME}ModelProvider extends AbstractModelProvider<${TEMPLATENAME}Model, DataSource> { private static class Singleton { final private static ${TEMPLATENAME}ModelProvider INSTANCE = new ${TEMPLATENAME}ModelProvider(); } private ${TEMPLATENAME}ModelProvider() {} @Override public ${TEMPLATENAME}Model createModelFor(DataSource datasource) { // TODO check the datasource and create an appropriate model, eventually return null; } public static ${TEMPLATENAME}ModelProvider getInstance() { return Singleton.INSTANCE; } /** * TODO Call this method from the module Installer#restored() **/ public static void install() { // TODO register with the appropriate model factory } /** * TODO Call this method from the module Installer#uninstalled() **/ public static void uninstall() { // TODO unregister from the appropriate model factory } } ././@LongLink0000644000000000000000000000015100000000000011600 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/NameAndLocationPanel.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/NameAndLocationPanel.0000644000175000017500000003622013767155557032264 0ustar apoapo package org.graalvm.visualvm.apisupport.models; import org.graalvm.visualvm.apisupport.datasources.*; import java.awt.Color; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.NbModuleProject; import org.netbeans.modules.apisupport.project.ui.UIUtil; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.netbeans.modules.apisupport.project.universe.ModuleEntry; import org.netbeans.modules.apisupport.project.universe.NbPlatform; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.Utilities; /** * The second panel in project template wizard. * * @author Milos Kleint */ final class NameAndLocationPanel extends BasicWizardIterator.Panel { private static final String PROJECT_TEMPLATES_DIR = "Templates/Project"; // NOI18N private static final String DEFAULT_CATEGORY_PATH = PROJECT_TEMPLATES_DIR + "/Other"; // NOI18N private NewProjectIterator.DataModel data; /** Creates new NameAndLocationPanel */ NameAndLocationPanel(WizardDescriptor setting, NewProjectIterator.DataModel data) { super(setting); this.data = data; initComponents(); initAccessibility(); Color lblBgr = UIManager.getColor("Label.background"); // NOI18N putClientProperty("NewFileWizard_Title", getMessage("LBL_ProjectWizardTitle")); modifiedFilesValue.setBackground(lblBgr); createdFilesValue.setBackground(lblBgr); modifiedFilesValue.setEditable(false); createdFilesValue.setEditable(false); DocumentListener dListener = new UIUtil.DocumentAdapter() { public void insertUpdate(DocumentEvent e) { if (checkValidity()) { updateData(); } } }; txtName.getDocument().addDocumentListener(dListener); if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } } protected void storeToDataModel() { updateData(); } private void updateData() { data.setPackageName(comPackageName.getEditor().getItem().toString()); data.setName(txtName.getText().trim()); data.setGenerateFactory(generateFactory.isSelected()); NewProjectIterator.generateFileChanges(data); CreatedModifiedFiles fls = data.getCreatedModifiedFiles(); createdFilesValue.setText(generateText(fls.getCreatedPaths())); modifiedFilesValue.setText(generateText(fls.getModifiedPaths())); //#68294 check if the paths for newly created files are valid or not.. String[] invalid = data.getCreatedModifiedFiles().getInvalidPaths(); if (invalid.length > 0) { setError(NbBundle.getMessage(NameAndLocationPanel.class, "ERR_ToBeCreateFileExists", invalid[0])); } } protected void readFromDataModel() { checkValidity(); } protected String getPanelName() { return getMessage("LBL_NameLocation_Title"); } private boolean checkValidity() { // if (!checkPlatformValidity()) { // return false; // } if (txtName.getText().trim().length() == 0) { setError(getMessage("ERR_Name_Prefix_Empty")); return false; } if (!Utilities.isJavaIdentifier(txtName.getText().trim())) { setError(getMessage("ERR_Name_Prefix_Invalid")); return false; } String packageName = comPackageName.getEditor().getItem().toString().trim(); if (packageName.length() == 0 || !UIUtil.isValidPackageName(packageName)) { setError(getMessage("ERR_Package_Invalid")); return false; } markValid(); return true; } // private boolean checkPlatformValidity() { // NbModuleProject nbprj = data.getProject().getLookup().lookup(NbModuleProject.class); // if (nbprj == null) { // //ignore this check for non default netbeans projects. // return true; // } // NbPlatform platform = nbprj.getPlatform(false); // if (platform == null) { // setError(getMessage("ERR_No_Platform")); // return false; // } // ModuleEntry[] entries = platform.getModules(); // Collection modules = new HashSet(Arrays.asList(NewProjectIterator.MODULES)); // // for (int i = 0; i < entries.length; i++) { // modules.remove(entries[i].getCodeNameBase()); // } // if (modules.size() > 0) { // setError(getMessage("ERR_Missing_Modules")); // return false; // } // return true; // } protected HelpCtx getHelp() { return new HelpCtx(NameAndLocationPanel.class); } private static String getMessage(String key) { return NbBundle.getMessage(NameAndLocationPanel.class, key); } /** 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. */ // //GEN-BEGIN:initComponents private void initComponents() { lblName = new javax.swing.JLabel(); txtName = new javax.swing.JTextField(); lblProjectName = new javax.swing.JLabel(); txtProjectName = new JTextField(ProjectUtils.getInformation(this.data.getProject()).getDisplayName()); lblPackageName = new javax.swing.JLabel(); comPackageName = UIUtil.createPackageComboBox(this.data.getSourceRootGroup()); createdFiles = new javax.swing.JLabel(); modifiedFiles = new javax.swing.JLabel(); filler = new javax.swing.JLabel(); createdFilesValue = new javax.swing.JTextArea(); modifiedFilesValue = new javax.swing.JTextArea(); generateFactory = new javax.swing.JCheckBox(); lblName.setLabelFor(txtName); org.openide.awt.Mnemonics.setLocalizedText(lblName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_Name_1")); // NOI18N lblProjectName.setLabelFor(txtProjectName); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/graalvm/visualvm/apisupport/tabs/Bundle"); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lblProjectName, bundle.getString("LBL_ProjectName_1")); // NOI18N txtProjectName.setEditable(false); lblPackageName.setLabelFor(comPackageName); org.openide.awt.Mnemonics.setLocalizedText(lblPackageName, bundle.getString("LBL_PackageName_1")); // NOI18N comPackageName.setEditable(true); createdFiles.setLabelFor(createdFilesValue); org.openide.awt.Mnemonics.setLocalizedText(createdFiles, bundle.getString("LBL_CreatedFiles_1")); // NOI18N modifiedFiles.setLabelFor(modifiedFilesValue); org.openide.awt.Mnemonics.setLocalizedText(modifiedFiles, bundle.getString("LBL_ModifiedFiles_1")); // NOI18N createdFilesValue.setColumns(20); createdFilesValue.setRows(5); createdFilesValue.setBorder(null); modifiedFilesValue.setColumns(20); modifiedFilesValue.setRows(5); modifiedFilesValue.setToolTipText("modifiedFilesValue"); modifiedFilesValue.setBorder(null); org.openide.awt.Mnemonics.setLocalizedText(generateFactory, "Generate Model Factory"); generateFactory.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); generateFactory.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { generateFactoryActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(filler, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, generateFactory, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(modifiedFiles, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(createdFiles, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)) .addContainerGap()) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, txtName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, txtProjectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE) .add(comPackageName, 0, 298, Short.MAX_VALUE)) .addContainerGap()))) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(txtName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblName)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(comPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add(generateFactory) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(createdFiles) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(modifiedFiles) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)) .add(43, 43, 43) .add(filler, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(20, 20, 20)) ); }// //GEN-END:initComponents private void generateFactoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateFactoryActionPerformed if (checkValidity()) { updateData(); } }//GEN-LAST:event_generateFactoryActionPerformed private void initAccessibility() { this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_NameAndLocationPanel")); comPackageName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_PackageName")); txtName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_Name")); txtProjectName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ProjectName")); createdFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_CreatedFilesValue")); modifiedFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ModifiedFilesValue")); generateFactory.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_GenerateModelFactory")); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox comPackageName; private javax.swing.JLabel createdFiles; private javax.swing.JTextArea createdFilesValue; private javax.swing.JLabel filler; private javax.swing.JCheckBox generateFactory; private javax.swing.JLabel lblName; private javax.swing.JLabel lblPackageName; private javax.swing.JLabel lblProjectName; private javax.swing.JLabel modifiedFiles; private javax.swing.JTextArea modifiedFilesValue; private javax.swing.JTextField txtName; private javax.swing.JTextField txtProjectName; // End of variables declaration//GEN-END:variables private static String generateText(String[] relPaths) { StringBuilder sb = new StringBuilder(); if (relPaths.length > 0) { for (int i = 0; i < relPaths.length; i++) { if (i > 0) { sb.append('\n'); } sb.append(relPaths[i]); } } return sb.toString(); } } ././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/NewProjectIterator.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/NewProjectIterator.ja0000644000175000017500000001353213767155557032416 0ustar apoapopackage org.graalvm.visualvm.apisupport.models; import java.io.IOException; import java.util.HashMap; import java.util.Set; import org.netbeans.api.project.Project; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; final class NewProjectIterator extends BasicWizardIterator { private NewProjectIterator.DataModel data; public static final String[] MODULES = { "org.openide.util", // NOI18N "org.graalvm.visualvm.core" // NOI18N }; private NewProjectIterator() { /* Use factory method. */ } ; public static NewProjectIterator createIterator() { return new NewProjectIterator(); } public Set instantiate() throws IOException { CreatedModifiedFiles cmf = data.getCreatedModifiedFiles(); cmf.run(); return getCreatedFiles(cmf, data.getProject()); } protected BasicWizardIterator.Panel[] createPanels(WizardDescriptor wiz) { data = new NewProjectIterator.DataModel(wiz); return new BasicWizardIterator.Panel[]{ new NameAndLocationPanel(wiz, data) }; } public @Override void uninitialize( WizardDescriptor wiz) { super.uninitialize(wiz); data = null; } static final class DataModel extends BasicWizardIterator.BasicDataModel { private Project template; private String name; private String displayName; private String category; private CreatedModifiedFiles files; private boolean generateFactory; DataModel(WizardDescriptor wiz) { super(wiz); } public CreatedModifiedFiles getCreatedModifiedFiles() { return getFiles(); } public void setCreatedModifiedFiles(CreatedModifiedFiles files) { this.setFiles(files); } public Project getTemplate() { return template; } public void setTemplate(Project template) { this.template = template; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public CreatedModifiedFiles getFiles() { return files; } public void setFiles(CreatedModifiedFiles files) { this.files = files; } public boolean isGenerateFactory() { return generateFactory; } public void setGenerateFactory(boolean generateFactory) { this.generateFactory = generateFactory; } } public static void generateFileChanges(DataModel model) { CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject()); NbModuleProvider moduleInfo = model.getModuleInfo(); final String category = model.getCategory(); final String name = model.getName(); final String packageName = model.getPackageName(); HashMap replaceTokens = new HashMap(); replaceTokens.put("TEMPLATENAME", name);//NOI18N replaceTokens.put("PACKAGENAME", packageName);//NOI18N // Update project dependencies for (int i = 0; i < MODULES.length; i++) { fileChanges.add(fileChanges.addModuleDependency(MODULES[i])); } // // Generate Support class: // String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, // name, "ViewSupport.java"); //NOI18N // // FileObject template = CreatedModifiedFiles.getTemplate("templateViewSupport.java");//NOI18N // // fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // // Generate view provider class: String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "ModelProvider.java"); //NOI18N FileObject template = CreatedModifiedFiles.getTemplate("templateModelProvider.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // Generate view class: iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "Model.java"); //NOI18N template = CreatedModifiedFiles.getTemplate("templateModel.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); if (model.isGenerateFactory()) { iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "ModelFactory.java"); //NOI18N template = CreatedModifiedFiles.getTemplate("templateModelFactory.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); } model.setCreatedModifiedFiles(fileChanges); } private static String getRelativePath(String rootPath, String fullyQualifiedPackageName, String prefix, String postfix) { StringBuilder sb = new StringBuilder(); sb.append(rootPath).append('/'). append(fullyQualifiedPackageName.replace('.', '/')). append('/').append(prefix).append(postfix); return sb.toString(); } } ././@LongLink0000644000000000000000000000016100000000000011601 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/templateVisualVMModelFactory.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/templateVisualVMModel0000644000175000017500000000240613767155557032454 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.core.model.ModelFactory; import org.graalvm.visualvm.core.datasource.DataSource; public class ${TEMPLATENAME}ModelFactory extends ModelFactory<${TEMPLATENAME}Model, DataSource> { private static class Singleton { final private static ${TEMPLATENAME}ModelFactory INSTANCE = new ${TEMPLATENAME}ModelFactory(); } private ${TEMPLATENAME}ModelFactory() { } public static ${TEMPLATENAME}ModelFactory getInstance() { return Singleton.INSTANCE; } /** * Factory method for obtaining the {@link ${TEMPLATENAME}Model} for the given * {@link DataSource}. Note that there is only one instance of * {@link ${TEMPLATENAME}Model} for application instance. This {@link ${TEMPLATENAME}Model} * instance is cached. * * @param ds datasource. * * @return a {@link ${TEMPLATENAME}Model} instance which encapsulates the * application's ${TEMPLATENAME} model. */ public static ${TEMPLATENAME}Model get${TEMPLATENAME}ModelFor(DataSource ds) { return getInstance().getModel(ds); } }visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/visualVMModel.html0000644000175000017500000000045713767155557031727 0ustar apoapo Creates a skeleton for a new VisualVM model support. ././@LongLink0000644000000000000000000000015200000000000011601 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/templateVisualVMModel.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/templateVisualVMModel0000644000175000017500000000047313767155557032456 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.core.model.Model; public class ${TEMPLATENAME}Model extends Model { // TODO add model specific properties } visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/models/Bundle.properties0000644000175000017500000000330213767155557031631 0ustar apoapo# To change this template, choose Tools | Templates # and open the template in the editor. Templates/VisualVMPluginDevelopment/model=Model LBL_ProjectWizardTitle=VisualVM Model LBL_ProjectSelection_Title=Select Project LBL_NameLocation_Title=Name and Location LBL_ProjectName=&Project\: LBL_PackageName=Pac&kage\: LBL_CreatedFiles=&Created Files\: LBL_ModifiedFiles=&Modified Files\: ACS_SelectProjectPanel=Select Project panel ACS_CTL_btnProject=Browse Project button ACS_CTL_comProject=Select from opened projects combobox LBL_Name=&Template Name \: LBL_DisplayName=D&isplay Name \: LBL_Category=C&ategory LBL_Project_Label=&Project \: LBL_Browse=Bro&wse... ACS_NameAndLocationPanel=Name and Location Panel ACS_CTL_PackageName=Package Name ACS_CTL_Category=Category ACS_CTL_DisplayName=Display Name ACS_CTL_Name=Template Name ACS_CTL_ProjectName=Project Name ACS_CTL_CreatedFilesValue=Created Files ACS_CTL_ModifiedFilesValue=Modified Files ACS_CTL_GenerateModelFactory=Generate Model Factory MSG_No_Projects=No Projects opened MSG_NoExternalRoots=Projects with external roots are not supported. MSG_NoProjectSelected=A project needs to be selected. ERR_Category_Invalid=Category is malformed. ERR_Name_Prefix_Empty=Template Name is empty. ERR_Name_Prefix_Invalid=Template Name is invalid, not a Java identifier. ERR_Package_Invalid=Package is blank or malformed. ERR_ToBeCreateFileExists=The file {0} already exists. ERR_Missing_Modules=The NetBeans platform is missing required modules. ERR_No_Platform=No NetBeans Platform defined. LBL_Name_1=Name: LBL_DisplayName_1=Data Source: LBL_ProjectName_1=Project Name: LBL_PackageName_1=Package Name: LBL_CreatedFiles_1=Created Files: LBL_ModifiedFiles_1=Modified Files: visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/resources/0000755000175000017500000000000013767155557027033 5ustar apoapovisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/resources/search.png0000644000175000017500000000123613767155557031010 0ustar apoapoPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<0IDATxb?cYœ\}`ELk>09ǞoeP_"3_T g4@ Sg]uQ[ h=9aVO~0\|a+ }dp T庼!>>b›$+]1 #m)g~3<b1^@]M qSWF}{rN؆+'x5^iG ` C6 @aĐde'û9?2l, , ?L @*Y5QmHk7㔾A,Q:ofԒ_.SK}ulJ)+.l93&J2&E~#Pj #؟Xu T(ZKjR}6=z'C Z*dc)}~H/`a6@g~q^D viE\2:f,cK*o s>=ex(mN.VMBw9n۟80 ^ۜfn*kQف I1EjNLVB2qoi==vtxdcޥ2=A2bgPߚyFMoMFp}1>'s"DRL'(B51;͎niX}B$Wh>™t+`iR=+P$@ԝG%(G`ZmO>-WPHje9L_/ЙuHaWEbfq\a\\ˢ=S[;4N Es?\2 bIENDB`visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/0000755000175000017500000000000013767155557026464 5ustar apoapo././@LongLink0000644000000000000000000000015200000000000011601 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/NameAndLocationPanel.formvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/NameAndLocationPanel0000644000175000017500000003001313767155557032360 0ustar apoapo
././@LongLink0000644000000000000000000000017000000000000011601 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/templateVisualVMViewPluginProvider.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/templateVisualVMView0000644000175000017500000000301713767155557032505 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.core.ui.DataSourceViewPlugin; import org.graalvm.visualvm.core.ui.DataSourceViewPluginProvider; public class ${TEMPLATENAME}ViewPluginProvider extends DataSourceViewPluginProvider<${DISPLAYNAME}> { private static class Singleton { final private static ${TEMPLATENAME}ViewPluginProvider INSTANCE = new ${TEMPLATENAME}ViewPluginProvider(); } private ${TEMPLATENAME}ViewPluginProvider() {} // TODO adjust the view visibility @Override protected boolean supportsPluginFor(${DISPLAYNAME} my${DISPLAYNAME}) { // Always shown return true; } @Override protected DataSourceViewPlugin createPlugin(${DISPLAYNAME} my${DISPLAYNAME}) { return new ${TEMPLATENAME}ViewPlugin(my${DISPLAYNAME}); } public static ${TEMPLATENAME}ViewPluginProvider getInstance() { return Singleton.INSTANCE; } /** * TODO Call this method from the module Installer#restored() **/ public static void install() { // TODO register with the appropriate org.graalvm.visualvm.core.ui.PluggableDataSourceViewProvider } /** * TODO Call this method from the module Installer#uninstalled() **/ public static void uninstall() { // TODO unregister from the appropriate org.graalvm.visualvm.core.ui.PluggableDataSourceViewProvider } } ././@LongLink0000644000000000000000000000015200000000000011601 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/NameAndLocationPanel.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/NameAndLocationPanel0000644000175000017500000003612513767155557032372 0ustar apoapo package org.graalvm.visualvm.apisupport.subtabs; import java.awt.Color; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.NbModuleProject; import org.netbeans.modules.apisupport.project.ui.UIUtil; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.netbeans.modules.apisupport.project.universe.ModuleEntry; import org.netbeans.modules.apisupport.project.universe.NbPlatform; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.Utilities; /** * The second panel in project template wizard. * * @author Milos Kleint */ final class NameAndLocationPanel extends BasicWizardIterator.Panel { private static final String PROJECT_TEMPLATES_DIR = "Templates/Project"; // NOI18N private static final String DEFAULT_CATEGORY_PATH = PROJECT_TEMPLATES_DIR + "/Other"; // NOI18N private NewProjectIterator.DataModel data; /** Creates new NameAndLocationPanel */ NameAndLocationPanel(WizardDescriptor setting, NewProjectIterator.DataModel data) { super(setting); this.data = data; initComponents(); initAccessibility(); Color lblBgr = UIManager.getColor("Label.background"); // NOI18N putClientProperty("NewFileWizard_Title", getMessage("LBL_ProjectWizardTitle")); modifiedFilesValue.setBackground(lblBgr); createdFilesValue.setBackground(lblBgr); modifiedFilesValue.setEditable(false); createdFilesValue.setEditable(false); DocumentListener dListener = new UIUtil.DocumentAdapter() { public void insertUpdate(DocumentEvent e) { if (checkValidity()) { updateData(); } } }; txtName.getDocument().addDocumentListener(dListener); if (comCategory.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField) comCategory.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } } protected void storeToDataModel() { updateData(); } private void updateData() { data.setPackageName(comPackageName.getEditor().getItem().toString()); data.setName(txtName.getText().trim()); data.setCategory(comCategory.getEditor().getItem().toString()); NewProjectIterator.generateFileChanges(data); CreatedModifiedFiles fls = data.getCreatedModifiedFiles(); createdFilesValue.setText(generateText(fls.getCreatedPaths())); modifiedFilesValue.setText(generateText(fls.getModifiedPaths())); //#68294 check if the paths for newly created files are valid or not.. String[] invalid = data.getCreatedModifiedFiles().getInvalidPaths(); if (invalid.length > 0) { setError(NbBundle.getMessage(NameAndLocationPanel.class, "ERR_ToBeCreateFileExists", invalid[0])); } } protected void readFromDataModel() { checkValidity(); } protected String getPanelName() { return getMessage("LBL_NameLocation_Title"); } private boolean checkValidity() { // if (!checkPlatformValidity()) { // return false; // } if (txtName.getText().trim().length() == 0) { setError(getMessage("ERR_Name_Prefix_Empty")); return false; } if (!Utilities.isJavaIdentifier(txtName.getText().trim())) { setError(getMessage("ERR_Name_Prefix_Invalid")); return false; } String packageName = comPackageName.getEditor().getItem().toString().trim(); if (packageName.length() == 0 || !UIUtil.isValidPackageName(packageName)) { setError(getMessage("ERR_Package_Invalid")); return false; } markValid(); return true; } // private boolean checkPlatformValidity() { // NbModuleProject nbprj = data.getProject().getLookup().lookup(NbModuleProject.class); // if (nbprj == null) { // //ignore this check for non default netbeans projects. // return true; // } // NbPlatform platform = nbprj.getPlatform(false); // if (platform == null) { // setError(getMessage("ERR_No_Platform")); // return false; // } // ModuleEntry[] entries = platform.getModules(); // Collection modules = new HashSet(Arrays.asList(NewProjectIterator.MODULES)); // // for (int i = 0; i < entries.length; i++) { // modules.remove(entries[i].getCodeNameBase()); // } // if (modules.size() > 0) { // setError(getMessage("ERR_Missing_Modules")); // return false; // } // return true; // } protected HelpCtx getHelp() { return new HelpCtx(NameAndLocationPanel.class); } private static String getMessage(String key) { return NbBundle.getMessage(NameAndLocationPanel.class, key); } /** 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. */ // //GEN-BEGIN:initComponents private void initComponents() { lblName = new javax.swing.JLabel(); txtName = new javax.swing.JTextField(); lblDisplayName = new javax.swing.JLabel(); lblProjectName = new javax.swing.JLabel(); txtProjectName = new JTextField(ProjectUtils.getInformation(this.data.getProject()).getDisplayName()); lblPackageName = new javax.swing.JLabel(); comPackageName = UIUtil.createPackageComboBox(this.data.getSourceRootGroup()); createdFiles = new javax.swing.JLabel(); modifiedFiles = new javax.swing.JLabel(); filler = new javax.swing.JLabel(); createdFilesValue = new javax.swing.JTextArea(); modifiedFilesValue = new javax.swing.JTextArea(); comCategory = new javax.swing.JComboBox(); lblName.setLabelFor(txtName); org.openide.awt.Mnemonics.setLocalizedText(lblName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_Name_1")); // NOI18N lblDisplayName.setLabelFor(comCategory); org.openide.awt.Mnemonics.setLocalizedText(lblDisplayName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_DisplayName_1")); // NOI18N lblProjectName.setLabelFor(txtProjectName); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/graalvm/visualvm/apisupport/tabs/Bundle"); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lblProjectName, bundle.getString("LBL_ProjectName_1")); // NOI18N txtProjectName.setEditable(false); lblPackageName.setLabelFor(comPackageName); org.openide.awt.Mnemonics.setLocalizedText(lblPackageName, bundle.getString("LBL_PackageName_1")); // NOI18N comPackageName.setEditable(true); createdFiles.setLabelFor(createdFilesValue); org.openide.awt.Mnemonics.setLocalizedText(createdFiles, bundle.getString("LBL_CreatedFiles_1")); // NOI18N modifiedFiles.setLabelFor(modifiedFilesValue); org.openide.awt.Mnemonics.setLocalizedText(modifiedFiles, bundle.getString("LBL_ModifiedFiles_1")); // NOI18N createdFilesValue.setColumns(20); createdFilesValue.setRows(5); createdFilesValue.setBorder(null); modifiedFilesValue.setColumns(20); modifiedFilesValue.setRows(5); modifiedFilesValue.setToolTipText("modifiedFilesValue"); modifiedFilesValue.setBorder(null); comCategory.setEditable(true); comCategory.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Application", "CoreDump", "DataSource", "HeapDump", "Host", "Snapshot", "ThreadDump" })); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(layout.createSequentialGroup() .add(lblName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 64, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 54, Short.MAX_VALUE)) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(createdFiles, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(modifiedFiles, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(12, 12, 12) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(txtName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE) .add(comCategory, 0, 296, Short.MAX_VALUE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE) .add(comPackageName, 0, 296, Short.MAX_VALUE) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE))) .add(filler, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 400, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(layout.createSequentialGroup() .add(lblDisplayName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(323, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(2, 2, 2) .add(lblName)) .add(txtName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER) .add(lblDisplayName) .add(comCategory, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(comPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(36, 36, 36) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(createdFiles) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(modifiedFiles) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)) .add(filler, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 92, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(20, 20, 20)) ); }// //GEN-END:initComponents private void initAccessibility() { this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_NameAndLocationPanel")); comPackageName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_PackageName")); comCategory.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_DisplayName")); txtName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_Name")); txtProjectName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ProjectName")); createdFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_CreatedFilesValue")); modifiedFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ModifiedFilesValue")); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox comCategory; private javax.swing.JComboBox comPackageName; private javax.swing.JLabel createdFiles; private javax.swing.JTextArea createdFilesValue; private javax.swing.JLabel filler; private javax.swing.JLabel lblDisplayName; private javax.swing.JLabel lblName; private javax.swing.JLabel lblPackageName; private javax.swing.JLabel lblProjectName; private javax.swing.JLabel modifiedFiles; private javax.swing.JTextArea modifiedFilesValue; private javax.swing.JTextField txtName; private javax.swing.JTextField txtProjectName; // End of variables declaration//GEN-END:variables private static String generateText(String[] relPaths) { StringBuffer sb = new StringBuffer(); if (relPaths.length > 0) { for (int i = 0; i < relPaths.length; i++) { if (i > 0) { sb.append('\n'); } sb.append(relPaths[i]); } } return sb.toString(); } } visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/visualVMSubTab.html0000644000175000017500000000044013767155557032217 0ustar apoapo Creates a skeleton VisualVM datasource subtab. ././@LongLink0000644000000000000000000000015000000000000011577 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/NewProjectIterator.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/NewProjectIterator.j0000644000175000017500000001301013767155557032424 0ustar apoapopackage org.graalvm.visualvm.apisupport.subtabs; import java.io.IOException; import java.util.HashMap; import java.util.Set; import org.netbeans.api.project.Project; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; final class NewProjectIterator extends BasicWizardIterator { private NewProjectIterator.DataModel data; public static final String[] MODULES = { "org.openide.util", // NOI18N "org.graalvm.visualvm.core", // NOI18N "org.graalvm.visualvm.application", // NOI18N "org.graalvm.visualvm.coredump", // NOI18N "org.graalvm.visualvm.heapdump", // NOI18N "org.graalvm.visualvm.threaddump", // NOI18N "org.graalvm.visualvm.host" // NOI18N }; private NewProjectIterator() { /* Use factory method. */ } ; public static NewProjectIterator createIterator() { return new NewProjectIterator(); } public Set instantiate() throws IOException { CreatedModifiedFiles cmf = data.getCreatedModifiedFiles(); cmf.run(); return getCreatedFiles(cmf, data.getProject()); } protected BasicWizardIterator.Panel[] createPanels(WizardDescriptor wiz) { data = new NewProjectIterator.DataModel(wiz); return new BasicWizardIterator.Panel[]{ new NameAndLocationPanel(wiz, data) }; } public @Override void uninitialize( WizardDescriptor wiz) { super.uninitialize(wiz); data = null; } static final class DataModel extends BasicWizardIterator.BasicDataModel { private Project template; private String name; private String displayName; private String category; private CreatedModifiedFiles files; DataModel(WizardDescriptor wiz) { super(wiz); } public CreatedModifiedFiles getCreatedModifiedFiles() { return getFiles(); } public void setCreatedModifiedFiles(CreatedModifiedFiles files) { this.setFiles(files); } public Project getTemplate() { return template; } public void setTemplate(Project template) { this.template = template; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public CreatedModifiedFiles getFiles() { return files; } public void setFiles(CreatedModifiedFiles files) { this.files = files; } } public static void generateFileChanges(DataModel model) { CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject()); NbModuleProvider moduleInfo = model.getModuleInfo(); final String category = model.getCategory(); final String name = model.getName(); final String packageName = model.getPackageName(); HashMap replaceTokens = new HashMap(); replaceTokens.put("DISPLAYNAME", category);//NOI18N replaceTokens.put("TEMPLATENAME", name);//NOI18N replaceTokens.put("PACKAGENAME", packageName);//NOI18N // Update project dependencies for (int i = 0; i < MODULES.length; i++) { fileChanges.add(fileChanges.addModuleDependency(MODULES[i])); } // // Generate Support class: // String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, // name, "ViewSupport.java"); //NOI18N // // FileObject template = CreatedModifiedFiles.getTemplate("templateViewSupport.java");//NOI18N // // fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // // Generate view provider class: String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "ViewPluginProvider.java"); //NOI18N FileObject template = CreatedModifiedFiles.getTemplate("templateViewPluginProvider.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // Generate view class: iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "ViewPlugin.java"); //NOI18N template = CreatedModifiedFiles.getTemplate("templateViewPlugin.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); model.setCreatedModifiedFiles(fileChanges); } private static String getRelativePath(String rootPath, String fullyQualifiedPackageName, String prefix, String postfix) { StringBuffer sb = new StringBuffer(); sb.append(rootPath).append('/'). append(fullyQualifiedPackageName.replace('.', '/')). append('/').append(prefix).append(postfix); return sb.toString(); } } ././@LongLink0000644000000000000000000000016000000000000011600 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/templateVisualVMViewPlugin.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/templateVisualVMView0000644000175000017500000000203113767155557032500 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.core.ui.DataSourceView; import org.graalvm.visualvm.core.ui.DataSourceViewPlugin; import org.graalvm.visualvm.core.ui.components.DataViewComponent.DetailsView; import javax.swing.JLabel; public class ${TEMPLATENAME}ViewPlugin extends DataSourceViewPlugin { public ${TEMPLATENAME}ViewPlugin(${DISPLAYNAME} My${DISPLAYNAME}) { super(My${DISPLAYNAME}); } @Override public DetailsView createView(int position) { /* TODO Check the position (DataViewComponent.TOP_LEFT, DataViewComponent.TOP_RIGHT, DataViewComponent.BOTTOM_LEFT, DataViewComponent.BOTTOM_RIGHT) before creating a new view. If the position is not applicable, return null */ return new DetailsView("${TEMPLATENAME}", "${TEMPLATENAME} desc", DataSourceView.POSITION_AT_THE_END, new JLabel("${TEMPLATENAME}"), null); } } visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/subtabs/Bundle.properties0000644000175000017500000000325713767155557032022 0ustar apoapo# To change this template, choose Tools | Templates # and open the template in the editor. Templates/VisualVMPluginDevelopment/subtab=View Plugin (Subtab) LBL_ProjectWizardTitle=VisualVM View Plugin (Subtab) LBL_ProjectSelection_Title=Select Project LBL_NameLocation_Title=Name and Location LBL_ProjectName=&Project\: LBL_PackageName=Pac&kage\: LBL_CreatedFiles=&Created Files\: LBL_ModifiedFiles=&Modified Files\: ACS_SelectProjectPanel=Select Project panel ACS_CTL_btnProject=Browse Project button ACS_CTL_comProject=Select from opened projects combobox LBL_Name=&Template Name \: LBL_DisplayName=D&isplay Name \: LBL_Category=C&ategory LBL_Project_Label=&Project \: LBL_Browse=Bro&wse... ACS_NameAndLocationPanel=Name and Location Panel ACS_CTL_PackageName=Package Name ACS_CTL_Category=Category ACS_CTL_DisplayName=Display Name ACS_CTL_Name=Template Name ACS_CTL_ProjectName=Project Name ACS_CTL_CreatedFilesValue=Created Files ACS_CTL_ModifiedFilesValue=Modified Files MSG_No_Projects=No Projects opened MSG_NoExternalRoots=Projects with external roots are not supported. MSG_NoProjectSelected=A project needs to be selected. ERR_Category_Invalid=Category is malformed. ERR_Name_Prefix_Empty=Template Name is empty. ERR_Name_Prefix_Invalid=Template Name is invalid, not a Java identifier. ERR_Package_Invalid=Package is blank or malformed. ERR_ToBeCreateFileExists=The file {0} already exists. ERR_Missing_Modules=The NetBeans platform is missing required modules. ERR_No_Platform=No NetBeans Platform defined. LBL_Name_1=Prefix: LBL_DisplayName_1=Data Source: LBL_ProjectName_1=Project Name: LBL_PackageName_1=Package Name: LBL_CreatedFiles_1=Created Files: LBL_ModifiedFiles_1=Modified Files: visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/0000755000175000017500000000000013767155557027336 5ustar apoapo././@LongLink0000644000000000000000000000015600000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/NameAndLocationPanel.formvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/NameAndLocationP0000644000175000017500000002351613767155557032404 0ustar apoapo
././@LongLink0000644000000000000000000000017400000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/templateVisualVMDataSourceProvider.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/templateVisualVM0000644000175000017500000000343513767155557032530 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.graalvm.visualvm.core.datasource.DataSource; public class ${TEMPLATENAME}Provider { private static class Singleton { final private static ${TEMPLATENAME}Provider INSTANCE = new ${TEMPLATENAME}Provider(); } final private ScheduledExecutorService discoveryProcess = Executors.newSingleThreadScheduledExecutor(); private ${TEMPLATENAME}Provider() {} private void startup() { // TODO adjust the refresh interval discoveryProcess.schedule(new Runnable() { @Override public void run() { discoverDataSources(); } }, 5, TimeUnit.SECONDS); } private void shutdown() { discoveryProcess.shutdown(); } private void discoverDataSources() { // TODO handle the datasource discovery // call .getRepository().addDataSource()/ addDataSources() to add discovered datasources // call .getRepository().removeDataSource()/removeDataSources() to remove discovered datasources } public static ${TEMPLATENAME}Provider getInstance() { return Singleton.INSTANCE; } /** * TODO Call this method from the module Installer#restored() **/ public static void install() { Singleton.INSTANCE.startup(); } /** * TODO Call this method from the module Installer#uninstalled() **/ public static void uninstall() { Singleton.INSTANCE.shutdown(); } } ././@LongLink0000644000000000000000000000016400000000000011604 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/templateVisualVMDataSource.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/templateVisualVM0000644000175000017500000000162613767155557032530 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptor; import java.awt.Image; public class ${TEMPLATENAME} extends DataSource { public static class Descriptor extends DataSourceDescriptor<${TEMPLATENAME}> { // TODO adjust the constructors as needed public Descriptor(Bimbo ds, String n, String desc, Image ic, int pos, int aep) { super(ds, n, desc, ic, pos, aep); } public Descriptor(Bimbo dataSource) { super(dataSource); } } public ${TEMPLATENAME}(DataSource parent) { super(parent); // uncomment to make the datasource invisible // setVisible(false); } } ././@LongLink0000644000000000000000000000015600000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/NameAndLocationPanel.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/NameAndLocationP0000644000175000017500000003263213767155557032403 0ustar apoapo package org.graalvm.visualvm.apisupport.datasources; import java.awt.Color; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.NbModuleProject; import org.netbeans.modules.apisupport.project.ui.UIUtil; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.netbeans.modules.apisupport.project.universe.ModuleEntry; import org.netbeans.modules.apisupport.project.universe.NbPlatform; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.Utilities; /** * The second panel in project template wizard. * * @author Milos Kleint */ final class NameAndLocationPanel extends BasicWizardIterator.Panel { private static final String PROJECT_TEMPLATES_DIR = "Templates/Project"; // NOI18N private static final String DEFAULT_CATEGORY_PATH = PROJECT_TEMPLATES_DIR + "/Other"; // NOI18N private NewProjectIterator.DataModel data; /** Creates new NameAndLocationPanel */ NameAndLocationPanel(WizardDescriptor setting, NewProjectIterator.DataModel data) { super(setting); this.data = data; initComponents(); initAccessibility(); Color lblBgr = UIManager.getColor("Label.background"); // NOI18N putClientProperty("NewFileWizard_Title", getMessage("LBL_ProjectWizardTitle")); modifiedFilesValue.setBackground(lblBgr); createdFilesValue.setBackground(lblBgr); modifiedFilesValue.setEditable(false); createdFilesValue.setEditable(false); DocumentListener dListener = new UIUtil.DocumentAdapter() { public void insertUpdate(DocumentEvent e) { if (checkValidity()) { updateData(); } } }; txtName.getDocument().addDocumentListener(dListener); if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } } protected void storeToDataModel() { updateData(); } private void updateData() { data.setPackageName(comPackageName.getEditor().getItem().toString()); data.setName(txtName.getText().trim()); NewProjectIterator.generateFileChanges(data); CreatedModifiedFiles fls = data.getCreatedModifiedFiles(); createdFilesValue.setText(generateText(fls.getCreatedPaths())); modifiedFilesValue.setText(generateText(fls.getModifiedPaths())); //#68294 check if the paths for newly created files are valid or not.. String[] invalid = data.getCreatedModifiedFiles().getInvalidPaths(); if (invalid.length > 0) { setError(NbBundle.getMessage(NameAndLocationPanel.class, "ERR_ToBeCreateFileExists", invalid[0])); } } protected void readFromDataModel() { checkValidity(); } protected String getPanelName() { return getMessage("LBL_NameLocation_Title"); } private boolean checkValidity() { // if (!checkPlatformValidity()) { // return false; // } if (txtName.getText().trim().length() == 0) { setError(getMessage("ERR_Name_Prefix_Empty")); return false; } if (!Utilities.isJavaIdentifier(txtName.getText().trim())) { setError(getMessage("ERR_Name_Prefix_Invalid")); return false; } String packageName = comPackageName.getEditor().getItem().toString().trim(); if (packageName.length() == 0 || !UIUtil.isValidPackageName(packageName)) { setError(getMessage("ERR_Package_Invalid")); return false; } markValid(); return true; } // private boolean checkPlatformValidity() { // NbModuleProject nbprj = data.getProject().getLookup().lookup(NbModuleProject.class); // if (nbprj == null) { // //ignore this check for non default netbeans projects. // return true; // } // NbPlatform platform = nbprj.getPlatform(false); // if (platform == null) { // setError(getMessage("ERR_No_Platform")); // return false; // } // ModuleEntry[] entries = platform.getModules(); // Collection modules = new HashSet(Arrays.asList(NewProjectIterator.MODULES)); // // for (int i = 0; i < entries.length; i++) { // modules.remove(entries[i].getCodeNameBase()); // } // if (modules.size() > 0) { // setError(getMessage("ERR_Missing_Modules")); // return false; // } // return true; // } protected HelpCtx getHelp() { return new HelpCtx(NameAndLocationPanel.class); } private static String getMessage(String key) { return NbBundle.getMessage(NameAndLocationPanel.class, key); } /** 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. */ // //GEN-BEGIN:initComponents private void initComponents() { lblName = new javax.swing.JLabel(); txtName = new javax.swing.JTextField(); lblProjectName = new javax.swing.JLabel(); txtProjectName = new JTextField(ProjectUtils.getInformation(this.data.getProject()).getDisplayName()); lblPackageName = new javax.swing.JLabel(); comPackageName = UIUtil.createPackageComboBox(this.data.getSourceRootGroup()); createdFiles = new javax.swing.JLabel(); modifiedFiles = new javax.swing.JLabel(); filler = new javax.swing.JLabel(); createdFilesValue = new javax.swing.JTextArea(); modifiedFilesValue = new javax.swing.JTextArea(); lblName.setLabelFor(txtName); org.openide.awt.Mnemonics.setLocalizedText(lblName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_Name_1")); // NOI18N lblProjectName.setLabelFor(txtProjectName); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/graalvm/visualvm/apisupport/tabs/Bundle"); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lblProjectName, bundle.getString("LBL_ProjectName_1")); // NOI18N txtProjectName.setEditable(false); lblPackageName.setLabelFor(comPackageName); org.openide.awt.Mnemonics.setLocalizedText(lblPackageName, bundle.getString("LBL_PackageName_1")); // NOI18N comPackageName.setEditable(true); createdFiles.setLabelFor(createdFilesValue); org.openide.awt.Mnemonics.setLocalizedText(createdFiles, bundle.getString("LBL_CreatedFiles_1")); // NOI18N modifiedFiles.setLabelFor(modifiedFilesValue); org.openide.awt.Mnemonics.setLocalizedText(modifiedFiles, bundle.getString("LBL_ModifiedFiles_1")); // NOI18N createdFilesValue.setColumns(20); createdFilesValue.setRows(5); createdFilesValue.setBorder(null); modifiedFilesValue.setColumns(20); modifiedFilesValue.setRows(5); modifiedFilesValue.setToolTipText("modifiedFilesValue"); modifiedFilesValue.setBorder(null); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(createdFiles, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(modifiedFiles, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(comPackageName, 0, 293, Short.MAX_VALUE) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, txtProjectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, txtName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE))) .add(filler, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(txtName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblName)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(comPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(36, 36, 36) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE) .add(createdFiles)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE) .add(modifiedFiles)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(filler, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE) .add(20, 20, 20)) ); }// //GEN-END:initComponents private void initAccessibility() { this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_NameAndLocationPanel")); comPackageName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_PackageName")); txtName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_Name")); txtProjectName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ProjectName")); createdFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_CreatedFilesValue")); modifiedFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ModifiedFilesValue")); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox comPackageName; private javax.swing.JLabel createdFiles; private javax.swing.JTextArea createdFilesValue; private javax.swing.JLabel filler; private javax.swing.JLabel lblName; private javax.swing.JLabel lblPackageName; private javax.swing.JLabel lblProjectName; private javax.swing.JLabel modifiedFiles; private javax.swing.JTextArea modifiedFilesValue; private javax.swing.JTextField txtName; private javax.swing.JTextField txtProjectName; // End of variables declaration//GEN-END:variables private static String generateText(String[] relPaths) { StringBuffer sb = new StringBuffer(); if (relPaths.length > 0) { for (int i = 0; i < relPaths.length; i++) { if (i > 0) { sb.append('\n'); } sb.append(relPaths[i]); } } return sb.toString(); } } ././@LongLink0000644000000000000000000000015400000000000011603 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/visualVMDatasource.htmlvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/visualVMDatasour0000644000175000017500000000046413767155557032536 0ustar apoapo Creates a skeleton for a new VisualVM datasource support. ././@LongLink0000644000000000000000000000015400000000000011603 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/NewProjectIterator.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/NewProjectIterat0000644000175000017500000001221113767155557032507 0ustar apoapopackage org.graalvm.visualvm.apisupport.datasources; import java.io.IOException; import java.util.HashMap; import java.util.Set; import org.netbeans.api.project.Project; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; final class NewProjectIterator extends BasicWizardIterator { private NewProjectIterator.DataModel data; public static final String[] MODULES = { "org.openide.util", // NOI18N "org.graalvm.visualvm.core" // NOI18N }; private NewProjectIterator() { /* Use factory method. */ } ; public static NewProjectIterator createIterator() { return new NewProjectIterator(); } public Set instantiate() throws IOException { CreatedModifiedFiles cmf = data.getCreatedModifiedFiles(); cmf.run(); return getCreatedFiles(cmf, data.getProject()); } protected BasicWizardIterator.Panel[] createPanels(WizardDescriptor wiz) { data = new NewProjectIterator.DataModel(wiz); return new BasicWizardIterator.Panel[]{ new NameAndLocationPanel(wiz, data) }; } public @Override void uninitialize( WizardDescriptor wiz) { super.uninitialize(wiz); data = null; } static final class DataModel extends BasicWizardIterator.BasicDataModel { private Project template; private String name; private String displayName; private String category; private CreatedModifiedFiles files; DataModel(WizardDescriptor wiz) { super(wiz); } public CreatedModifiedFiles getCreatedModifiedFiles() { return getFiles(); } public void setCreatedModifiedFiles(CreatedModifiedFiles files) { this.setFiles(files); } public Project getTemplate() { return template; } public void setTemplate(Project template) { this.template = template; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public CreatedModifiedFiles getFiles() { return files; } public void setFiles(CreatedModifiedFiles files) { this.files = files; } } public static void generateFileChanges(DataModel model) { CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject()); NbModuleProvider moduleInfo = model.getModuleInfo(); final String name = model.getName(); final String packageName = model.getPackageName(); HashMap replaceTokens = new HashMap(); replaceTokens.put("TEMPLATENAME", name);//NOI18N replaceTokens.put("PACKAGENAME", packageName);//NOI18N // Update project dependencies for (int i = 0; i < MODULES.length; i++) { fileChanges.add(fileChanges.addModuleDependency(MODULES[i])); } // // Generate Support class: // String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, // name, "ViewSupport.java"); //NOI18N // // FileObject template = CreatedModifiedFiles.getTemplate("templateViewSupport.java");//NOI18N // // fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // // Generate view provider class: String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "Provider.java"); //NOI18N FileObject template = CreatedModifiedFiles.getTemplate("templateDataSourceProvider.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // Generate view class: iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, ".java"); //NOI18N template = CreatedModifiedFiles.getTemplate("templateDataSource.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); model.setCreatedModifiedFiles(fileChanges); } private static String getRelativePath(String rootPath, String fullyQualifiedPackageName, String prefix, String postfix) { StringBuilder sb = new StringBuilder(); sb.append(rootPath).append('/'). append(fullyQualifiedPackageName.replace('.', '/')). append('/').append(prefix).append(postfix); return sb.toString(); } } ././@LongLink0000644000000000000000000000014600000000000011604 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/Bundle.propertiesvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/datasources/Bundle.propertie0000644000175000017500000000354513767155557032511 0ustar apoapo# To change this template, choose Tools | Templates # and open the template in the editor. Templates/VisualVMPluginDevelopment/datasource=DataSource LBL_ProjectWizardTitle=VisualVM DataSource LBL_ProjectSelection_Title=Select Project LBL_NameLocation_Title=Name and Location LBL_ProjectName=&Project\: LBL_PackageName=Pac&kage\: LBL_CreatedFiles=&Created Files\: LBL_ModifiedFiles=&Modified Files\: ACS_SelectProjectPanel=Select Project panel ACS_CTL_btnProject=Browse Project button ACS_CTL_comProject=Select from opened projects combobox LBL_Name=&Template Name \: LBL_DisplayName=D&isplay Name \: LBL_Category=C&ategory LBL_Project_Label=&Project \: LBL_Browse=Bro&wse... ACS_NameAndLocationPanel=Name and Location Panel ACS_CTL_PackageName=Package Name ACS_CTL_Category=Category ACS_CTL_DisplayName=Display Name ACS_CTL_Name=Template Name ACS_CTL_ProjectName=Project Name ACS_CTL_CreatedFilesValue=Created Files ACS_CTL_ModifiedFilesValue=Modified Files MSG_No_Projects=No Projects opened MSG_NoExternalRoots=Projects with external roots are not supported. MSG_NoProjectSelected=A project needs to be selected. ERR_Category_Invalid=Category is malformed. ERR_Name_Prefix_Empty=Template Name is empty. ERR_Name_Prefix_Invalid=Template Name is invalid, not a Java identifier. ERR_Package_Invalid=Package is blank or malformed. ERR_ToBeCreateFileExists=The file {0} already exists. ERR_Missing_Modules=The NetBeans platform is missing required modules. ERR_No_Platform=No NetBeans Platform defined. LBL_Name_1=Prefix: LBL_DisplayName_1=Data Source: LBL_ProjectName_1=Project Name: LBL_PackageName_1=Package Name: LBL_CreatedFiles_1=Created Files: LBL_ModifiedFiles_1=Modified Files: LBL_Name_1_1=Type Name: LBL_DisplayName_1_1=Main Class: LBL_ProjectName_1_1=Project Name: LBL_PackageName_1_1=Package Name: LBL_CreatedFiles_1_1=Created Files: LBL_ModifiedFiles_1_1=Modified Files: visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/0000755000175000017500000000000013767155557026666 5ustar apoapo././@LongLink0000644000000000000000000000015300000000000011602 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/NameAndLocationPanel.formvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/NameAndLocationPane0000644000175000017500000003054613767155557032421 0ustar apoapo
././@LongLink0000644000000000000000000000015600000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/templateApplicationType.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/templateApplication0000644000175000017500000000161013767155557032606 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.application.type.ApplicationType; import java.awt.Image; import org.openide.util.Utilities; public class ${TEMPLATENAME}ApplicationType extends ApplicationType { protected final int appPID; public ${TEMPLATENAME}ApplicationType(int pid) { appPID = pid; } @Override public String getName() { return "${TEMPLATENAME}"; } @Override public String getVersion() { return "1.0"; } @Override public String getDescription() { return "Application type for ${TEMPLATENAME}"; } @Override public Image getIcon() { return Utilities.loadImage("org/graalvm/visualvm/core/ui/resources/snapshot.png", true); } } ././@LongLink0000644000000000000000000000015300000000000011602 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/NameAndLocationPanel.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/NameAndLocationPane0000644000175000017500000003750413767155557032422 0ustar apoapo package org.graalvm.visualvm.apisupport.apptypes; import java.awt.Color; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.NbModuleProject; import org.netbeans.modules.apisupport.project.ui.UIUtil; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.netbeans.modules.apisupport.project.universe.ModuleEntry; import org.netbeans.modules.apisupport.project.universe.NbPlatform; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.Utilities; /** * The second panel in project template wizard. * * @author Milos Kleint */ final class NameAndLocationPanel extends BasicWizardIterator.Panel { private static final String PROJECT_TEMPLATES_DIR = "Templates/Project"; // NOI18N private static final String DEFAULT_CATEGORY_PATH = PROJECT_TEMPLATES_DIR + "/Other"; // NOI18N private NewProjectIterator.DataModel data; /** Creates new NameAndLocationPanel */ NameAndLocationPanel(WizardDescriptor setting, NewProjectIterator.DataModel data) { super(setting); this.data = data; initComponents(); initAccessibility(); Color lblBgr = UIManager.getColor("Label.background"); // NOI18N putClientProperty("NewFileWizard_Title", getMessage("LBL_ProjectWizardTitle")); modifiedFilesValue.setBackground(lblBgr); createdFilesValue.setBackground(lblBgr); modifiedFilesValue.setEditable(false); createdFilesValue.setEditable(false); DocumentListener dListener = new UIUtil.DocumentAdapter() { public void insertUpdate(DocumentEvent e) { if (checkValidity()) { updateData(); } } }; txtName.getDocument().addDocumentListener(dListener); if (comCategory.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField) comCategory.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } } protected void storeToDataModel() { updateData(); } private void updateData() { data.setPackageName(comPackageName.getEditor().getItem().toString()); data.setName(txtName.getText().trim()); data.setCategory(useMainClass.isSelected() ? comCategory.getEditor().getItem().toString() : null); NewProjectIterator.generateFileChanges(data); CreatedModifiedFiles fls = data.getCreatedModifiedFiles(); createdFilesValue.setText(generateText(fls.getCreatedPaths())); modifiedFilesValue.setText(generateText(fls.getModifiedPaths())); //#68294 check if the paths for newly created files are valid or not.. String[] invalid = data.getCreatedModifiedFiles().getInvalidPaths(); if (invalid.length > 0) { setError(NbBundle.getMessage(NameAndLocationPanel.class, "ERR_ToBeCreateFileExists", invalid[0])); } } protected void readFromDataModel() { checkValidity(); } protected String getPanelName() { return getMessage("LBL_NameLocation_Title"); } private boolean checkValidity() { // if (!checkPlatformValidity()) { // return false; // } if (txtName.getText().trim().length() == 0) { setError(getMessage("ERR_Name_Prefix_Empty")); return false; } if (!Utilities.isJavaIdentifier(txtName.getText().trim())) { setError(getMessage("ERR_Name_Prefix_Invalid")); return false; } String packageName = comPackageName.getEditor().getItem().toString().trim(); if (packageName.length() == 0 || !UIUtil.isValidPackageName(packageName)) { setError(getMessage("ERR_Package_Invalid")); return false; } markValid(); return true; } // private boolean checkPlatformValidity() { // NbModuleProject nbprj = data.getProject().getLookup().lookup(NbModuleProject.class); // if (nbprj == null) { // //ignore this check for non default netbeans projects. // return true; // } // NbPlatform platform = nbprj.getPlatform(false); // if (platform == null) { // setError(getMessage("ERR_No_Platform")); // return false; // } // ModuleEntry[] entries = platform.getModules(); // Collection modules = new HashSet(Arrays.asList(NewProjectIterator.MODULES)); // // for (int i = 0; i < entries.length; i++) { // modules.remove(entries[i].getCodeNameBase()); // } // if (modules.size() > 0) { // setError(getMessage("ERR_Missing_Modules")); // return false; // } // return true; // } // protected HelpCtx getHelp() { return new HelpCtx(NameAndLocationPanel.class); } private static String getMessage(String key) { return NbBundle.getMessage(NameAndLocationPanel.class, key); } /** 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. */ // //GEN-BEGIN:initComponents private void initComponents() { bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); lblName = new javax.swing.JLabel(); txtName = new javax.swing.JTextField(); lblDisplayName = new javax.swing.JLabel(); lblProjectName = new javax.swing.JLabel(); txtProjectName = new JTextField(ProjectUtils.getInformation(this.data.getProject()).getDisplayName()); lblPackageName = new javax.swing.JLabel(); comPackageName = UIUtil.createPackageComboBox(this.data.getSourceRootGroup()); createdFiles = new javax.swing.JLabel(); modifiedFiles = new javax.swing.JLabel(); filler = new javax.swing.JLabel(); createdFilesValue = new javax.swing.JTextArea(); modifiedFilesValue = new javax.swing.JTextArea(); comCategory = new javax.swing.JComboBox(); useMainClass = new javax.swing.JCheckBox(); lblName.setLabelFor(txtName); org.openide.awt.Mnemonics.setLocalizedText(lblName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_Name_1_1")); // NOI18N lblDisplayName.setLabelFor(comCategory); org.openide.awt.Mnemonics.setLocalizedText(lblDisplayName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_DisplayName_1_1")); // NOI18N lblProjectName.setLabelFor(txtProjectName); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/graalvm/visualvm/apisupport/apptypes/Bundle"); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lblProjectName, bundle.getString("LBL_ProjectName_1_1")); // NOI18N txtProjectName.setEditable(false); lblPackageName.setLabelFor(comPackageName); org.openide.awt.Mnemonics.setLocalizedText(lblPackageName, bundle.getString("LBL_PackageName_1_1")); // NOI18N comPackageName.setEditable(true); createdFiles.setLabelFor(createdFilesValue); org.openide.awt.Mnemonics.setLocalizedText(createdFiles, bundle.getString("LBL_CreatedFiles_1_1")); // NOI18N modifiedFiles.setLabelFor(modifiedFilesValue); org.openide.awt.Mnemonics.setLocalizedText(modifiedFiles, bundle.getString("LBL_ModifiedFiles_1_1")); // NOI18N createdFilesValue.setColumns(20); createdFilesValue.setRows(5); createdFilesValue.setBorder(null); modifiedFilesValue.setColumns(20); modifiedFilesValue.setRows(5); modifiedFilesValue.setToolTipText("modifiedFilesValue"); modifiedFilesValue.setBorder(null); comCategory.setEditable(true); comCategory.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "com.toy.anagrams.ui.Anagrams" })); comCategory.setNextFocusableComponent(useMainClass); org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, useMainClass, org.jdesktop.beansbinding.ELProperty.create("${selected}"), comCategory, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(filler, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(modifiedFiles, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(createdFiles, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(lblPackageName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(lblName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(lblProjectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(lblDisplayName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE) .add(comPackageName, 0, 358, Short.MAX_VALUE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE) .add(layout.createSequentialGroup() .add(comCategory, 0, 332, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(useMainClass)) .add(txtName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(2, 2, 2) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lblName) .add(txtName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(14, 14, 14) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER) .add(lblDisplayName) .add(comCategory, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(useMainClass)) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(14, 14, 14) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(comPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(39, 39, 39) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(createdFiles) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(modifiedFiles) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(filler, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 92, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(20, 20, 20)) ); bindingGroup.bind(); }// //GEN-END:initComponents private void initAccessibility() { this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_NameAndLocationPanel")); comPackageName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_PackageName")); comCategory.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_DisplayName")); txtName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_Name")); txtProjectName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ProjectName")); createdFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_CreatedFilesValue")); modifiedFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ModifiedFilesValue")); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox comCategory; private javax.swing.JComboBox comPackageName; private javax.swing.JLabel createdFiles; private javax.swing.JTextArea createdFilesValue; private javax.swing.JLabel filler; private javax.swing.JLabel lblDisplayName; private javax.swing.JLabel lblName; private javax.swing.JLabel lblPackageName; private javax.swing.JLabel lblProjectName; private javax.swing.JLabel modifiedFiles; private javax.swing.JTextArea modifiedFilesValue; private javax.swing.JTextField txtName; private javax.swing.JTextField txtProjectName; private javax.swing.JCheckBox useMainClass; private org.jdesktop.beansbinding.BindingGroup bindingGroup; // End of variables declaration//GEN-END:variables private static String generateText(String[] relPaths) { StringBuffer sb = new StringBuffer(); if (relPaths.length > 0) { for (int i = 0; i < relPaths.length; i++) { if (i > 0) { sb.append('\n'); } sb.append(relPaths[i]); } } return sb.toString(); } } ././@LongLink0000644000000000000000000000015100000000000011600 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/NewProjectIterator.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/NewProjectIterator.0000644000175000017500000001203113767155557032456 0ustar apoapopackage org.graalvm.visualvm.apisupport.apptypes; import java.io.IOException; import java.util.HashMap; import java.util.Set; import org.netbeans.api.project.Project; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; final class NewProjectIterator extends BasicWizardIterator { private NewProjectIterator.DataModel data; public static final String[] MODULES = { "org.openide.util", // NOI18N "org.graalvm.visualvm.application", // NOI18N "org.graalvm.visualvm.core" // NOI18N }; private NewProjectIterator() { /* Use factory method. */ } ; public static NewProjectIterator createIterator() { return new NewProjectIterator(); } public Set instantiate() throws IOException { CreatedModifiedFiles cmf = data.getCreatedModifiedFiles(); cmf.run(); return getCreatedFiles(cmf, data.getProject()); } protected BasicWizardIterator.Panel[] createPanels(WizardDescriptor wiz) { data = new NewProjectIterator.DataModel(wiz); return new BasicWizardIterator.Panel[]{ new NameAndLocationPanel(wiz, data) }; } public @Override void uninitialize( WizardDescriptor wiz) { super.uninitialize(wiz); data = null; } static final class DataModel extends BasicWizardIterator.BasicDataModel { private Project template; private String name; private String displayName; private String category; private CreatedModifiedFiles files; DataModel(WizardDescriptor wiz) { super(wiz); } public CreatedModifiedFiles getCreatedModifiedFiles() { return getFiles(); } public void setCreatedModifiedFiles(CreatedModifiedFiles files) { this.setFiles(files); } public Project getTemplate() { return template; } public void setTemplate(Project template) { this.template = template; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public CreatedModifiedFiles getFiles() { return files; } public void setFiles(CreatedModifiedFiles files) { this.files = files; } } public static void generateFileChanges(DataModel model) { CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject()); NbModuleProvider moduleInfo = model.getModuleInfo(); final String category = model.getCategory(); final String name = model.getName(); final String packageName = model.getPackageName(); HashMap replaceTokens = new HashMap(); replaceTokens.put("DISPLAYNAME", category);//NOI18N replaceTokens.put("TEMPLATENAME", name);//NOI18N replaceTokens.put("PACKAGENAME", packageName);//NOI18N // Update project dependencies for (int i = 0; i < MODULES.length; i++) { fileChanges.add(fileChanges.addModuleDependency(MODULES[i])); } // Generate view provider class: String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "ApplicationTypeProvider.java"); //NOI18N FileObject template = CreatedModifiedFiles.getTemplate(category != null ? "templateMainClassApplicationTypeProvider.java" : "templateApplicationTypeProvider.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); // Generate view class: iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "ApplicationType.java"); //NOI18N template = CreatedModifiedFiles.getTemplate("templateApplicationType.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); model.setCreatedModifiedFiles(fileChanges); } private static String getRelativePath(String rootPath, String fullyQualifiedPackageName, String prefix, String postfix) { StringBuilder sb = new StringBuilder(); sb.append(rootPath).append('/'). append(fullyQualifiedPackageName.replace('.', '/')). append('/').append(prefix).append(postfix); return sb.toString(); } } ././@LongLink0000644000000000000000000000017700000000000011610 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/templateMainClassApplicationTypeProvider.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/templateMainClassAp0000644000175000017500000000304113767155557032476 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.application.Application; import org.graalvm.visualvm.application.jvm.Jvm; import org.graalvm.visualvm.application.type.ApplicationType; import org.graalvm.visualvm.application.type.ApplicationTypeFactory; import org.graalvm.visualvm.application.type.MainClassApplicationTypeFactory; public class ${TEMPLATENAME}ApplicationTypeProvider extends MainClassApplicationTypeFactory { private static class Singleton { final private static ${TEMPLATENAME}ApplicationTypeProvider INSTANCE = new ${TEMPLATENAME}ApplicationTypeProvider(); } private ${TEMPLATENAME}ApplicationTypeProvider() {} /** * Call this method from the module Installer#restored() **/ static public void install() { ApplicationTypeFactory.getDefault().registerProvider(Singleton.INSTANCE); } /** * Call this method from the module Installer#uninstalled() **/ static public void uninstall() { ApplicationTypeFactory.getDefault().unregisterProvider(Singleton.INSTANCE); } @Override public ApplicationType createApplicationTypeFor(Application app, Jvm jvm, String mainClass) { //TODO: Specify the name of the application's main class here: if ("${DISPLAYNAME}".equals(mainClass)) { return new ${TEMPLATENAME}ApplicationType(app.getPid()); } return null; } } ././@LongLink0000644000000000000000000000014600000000000011604 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/visualVMAppType.htmlvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/visualVMAppType.htm0000644000175000017500000000043713767155557032455 0ustar apoapo Creates a skeleton VisualVM application type. ././@LongLink0000644000000000000000000000016600000000000011606 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/templateApplicationTypeProvider.javxvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/templateApplication0000644000175000017500000000246013767155557032612 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.application.Application; import org.graalvm.visualvm.core.model.AbstractModelProvider; import org.graalvm.visualvm.application.type.ApplicationType; import org.graalvm.visualvm.application.type.ApplicationTypeFactory; public class ${TEMPLATENAME}ApplicationTypeProvider extends AbstractModelProvider { private static class Singleton { final private static ${TEMPLATENAME}ApplicationTypeProvider INSTANCE = new ${TEMPLATENAME}ApplicationTypeProvider(); } private ${TEMPLATENAME}ApplicationTypeProvider() {} /** * TODO Call this method from the module Installer#restored() **/ static public void install() { ApplicationTypeFactory.getDefault().registerProvider(Singleton.INSTANCE); } /** * TODO Call this method from the module Installer#uninstalled() **/ static public void uninstall() { ApplicationTypeFactory.getDefault().unregisterProvider(Singleton.INSTANCE); } @Override public ApplicationType createModelFor(Application appl) { /* put your logic here */ return null; } } visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/apptypes/Bundle.properties0000644000175000017500000000355613767155557032226 0ustar apoapo# To change this template, choose Tools | Templates # and open the template in the editor. Templates/VisualVMPluginDevelopment/apptype=Application Type LBL_ProjectWizardTitle=VisualVM Application Type LBL_ProjectSelection_Title=Select Project LBL_NameLocation_Title=Name and Location LBL_ProjectName=&Project\: LBL_PackageName=Pac&kage\: LBL_CreatedFiles=&Created Files\: LBL_ModifiedFiles=&Modified Files\: ACS_SelectProjectPanel=Select Project panel ACS_CTL_btnProject=Browse Project button ACS_CTL_comProject=Select from opened projects combobox LBL_Name=&Template Name \: LBL_DisplayName=D&isplay Name \: LBL_Category=C&ategory LBL_Project_Label=&Project \: LBL_Browse=Bro&wse... ACS_NameAndLocationPanel=Name and Location Panel ACS_CTL_PackageName=Package Name ACS_CTL_Category=Category ACS_CTL_DisplayName=Display Name ACS_CTL_Name=Template Name ACS_CTL_ProjectName=Project Name ACS_CTL_CreatedFilesValue=Created Files ACS_CTL_ModifiedFilesValue=Modified Files MSG_No_Projects=No Projects opened MSG_NoExternalRoots=Projects with external roots are not supported. MSG_NoProjectSelected=A project needs to be selected. ERR_Category_Invalid=Category is malformed. ERR_Name_Prefix_Empty=Template Name is empty. ERR_Name_Prefix_Invalid=Template Name is invalid, not a Java identifier. ERR_Package_Invalid=Package is blank or malformed. ERR_ToBeCreateFileExists=The file {0} already exists. ERR_Missing_Modules=The NetBeans platform is missing required modules. ERR_No_Platform=No NetBeans Platform defined. LBL_Name_1=Prefix: LBL_DisplayName_1=Data Source: LBL_ProjectName_1=Project Name: LBL_PackageName_1=Package Name: LBL_CreatedFiles_1=Created Files: LBL_ModifiedFiles_1=Modified Files: LBL_Name_1_1=Type Name: LBL_DisplayName_1_1=Main Class: LBL_ProjectName_1_1=Project Name: LBL_PackageName_1_1=Package Name: LBL_CreatedFiles_1_1=Created Files: LBL_ModifiedFiles_1_1=Modified Files: visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/0000755000175000017500000000000013767155557026461 5ustar apoapo././@LongLink0000644000000000000000000000015200000000000011601 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/NameAndLocationPanel.formvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/NameAndLocationPanel0000644000175000017500000002743613767155557032374 0ustar apoapo
././@LongLink0000644000000000000000000000015200000000000011601 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/NameAndLocationPanel.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/NameAndLocationPanel0000644000175000017500000003557013767155557032372 0ustar apoapo package org.graalvm.visualvm.apisupport.actions; import java.awt.Color; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.netbeans.api.project.ProjectUtils; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.NbModuleProject; import org.netbeans.modules.apisupport.project.ui.UIUtil; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.netbeans.modules.apisupport.project.universe.ModuleEntry; import org.netbeans.modules.apisupport.project.universe.NbPlatform; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.Utilities; /** * The second panel in project template wizard. * * @author Milos Kleint */ final class NameAndLocationPanel extends BasicWizardIterator.Panel { private static final String PROJECT_TEMPLATES_DIR = "Templates/Project"; // NOI18N private static final String DEFAULT_CATEGORY_PATH = PROJECT_TEMPLATES_DIR + "/Other"; // NOI18N private NewActionIterator.DataModel data; /** Creates new NameAndLocationPanel */ NameAndLocationPanel(WizardDescriptor setting, NewActionIterator.DataModel data) { super(setting); this.data = data; initComponents(); initAccessibility(); Color lblBgr = UIManager.getColor("Label.background"); // NOI18N putClientProperty("NewFileWizard_Title", getMessage("LBL_ProjectWizardTitle")); modifiedFilesValue.setBackground(lblBgr); createdFilesValue.setBackground(lblBgr); modifiedFilesValue.setEditable(false); createdFilesValue.setEditable(false); DocumentListener dListener = new UIUtil.DocumentAdapter() { public void insertUpdate(DocumentEvent e) { if (checkValidity()) { updateData(); } } }; txtName.getDocument().addDocumentListener(dListener); if (comCategory.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField) comCategory.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) { JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent(); txt.getDocument().addDocumentListener(dListener); } } protected void storeToDataModel() { updateData(); } private void updateData() { data.setPackageName(comPackageName.getEditor().getItem().toString()); data.setName(txtName.getText().trim()); data.setCategory(comCategory.getEditor().getItem().toString()); NewActionIterator.generateFileChanges(data); CreatedModifiedFiles fls = data.getCreatedModifiedFiles(); createdFilesValue.setText(generateText(fls.getCreatedPaths())); modifiedFilesValue.setText(generateText(fls.getModifiedPaths())); //#68294 check if the paths for newly created files are valid or not.. String[] invalid = data.getCreatedModifiedFiles().getInvalidPaths(); if (invalid.length > 0) { setError(NbBundle.getMessage(NameAndLocationPanel.class, "ERR_ToBeCreateFileExists", invalid[0])); } } protected void readFromDataModel() { checkValidity(); } protected String getPanelName() { return getMessage("LBL_NameLocation_Title"); } private boolean checkValidity() { // if (!checkPlatformValidity()) { // return false; // } if (txtName.getText().trim().length() == 0) { setError(getMessage("ERR_Name_Prefix_Empty")); return false; } if (!Utilities.isJavaIdentifier(txtName.getText().trim())) { setError(getMessage("ERR_Name_Prefix_Invalid")); return false; } String packageName = comPackageName.getEditor().getItem().toString().trim(); if (packageName.length() == 0 || !UIUtil.isValidPackageName(packageName)) { setError(getMessage("ERR_Package_Invalid")); return false; } markValid(); return true; } // private boolean checkPlatformValidity() { // NbModuleProject nbprj = data.getProject().getLookup().lookup(NbModuleProject.class); // if (nbprj == null) { // //ignore this check for non default netbeans projects. // return true; // } // NbPlatform platform = nbprj.getPlatform(false); // if (platform == null) { // setError(getMessage("ERR_No_Platform")); // return false; // } // ModuleEntry[] entries = platform.getModules(); // Collection modules = new HashSet(Arrays.asList(NewActionIterator.MODULES)); // // for (int i = 0; i < entries.length; i++) { // modules.remove(entries[i].getCodeNameBase()); // } // if (modules.size() > 0) { // setError(getMessage("ERR_Missing_Modules")); // return false; // } // return true; // } protected HelpCtx getHelp() { return new HelpCtx(NameAndLocationPanel.class); } private static String getMessage(String key) { return NbBundle.getMessage(NameAndLocationPanel.class, key); } /** 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. */ // //GEN-BEGIN:initComponents private void initComponents() { lblName = new javax.swing.JLabel(); txtName = new javax.swing.JTextField(); lblDisplayName = new javax.swing.JLabel(); lblProjectName = new javax.swing.JLabel(); txtProjectName = new JTextField(ProjectUtils.getInformation(this.data.getProject()).getDisplayName()); lblPackageName = new javax.swing.JLabel(); comPackageName = UIUtil.createPackageComboBox(this.data.getSourceRootGroup()); createdFiles = new javax.swing.JLabel(); modifiedFiles = new javax.swing.JLabel(); filler = new javax.swing.JLabel(); createdFilesValue = new javax.swing.JTextArea(); modifiedFilesValue = new javax.swing.JTextArea(); comCategory = new javax.swing.JComboBox(); lblName.setLabelFor(txtName); org.openide.awt.Mnemonics.setLocalizedText(lblName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_Name_1")); // NOI18N lblDisplayName.setLabelFor(comCategory); org.openide.awt.Mnemonics.setLocalizedText(lblDisplayName, org.openide.util.NbBundle.getMessage(NameAndLocationPanel.class, "LBL_DisplayName_1")); // NOI18N lblProjectName.setLabelFor(txtProjectName); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/graalvm/visualvm/apisupport/actions/Bundle"); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lblProjectName, bundle.getString("LBL_ProjectName_1")); // NOI18N txtProjectName.setEditable(false); lblPackageName.setLabelFor(comPackageName); org.openide.awt.Mnemonics.setLocalizedText(lblPackageName, bundle.getString("LBL_PackageName_1")); // NOI18N comPackageName.setEditable(true); createdFiles.setLabelFor(createdFilesValue); org.openide.awt.Mnemonics.setLocalizedText(createdFiles, bundle.getString("LBL_CreatedFiles_1")); // NOI18N modifiedFiles.setLabelFor(modifiedFilesValue); org.openide.awt.Mnemonics.setLocalizedText(modifiedFiles, bundle.getString("LBL_ModifiedFiles_1")); // NOI18N createdFilesValue.setColumns(20); createdFilesValue.setRows(5); createdFilesValue.setBorder(null); modifiedFilesValue.setColumns(20); modifiedFilesValue.setRows(5); modifiedFilesValue.setToolTipText("modifiedFilesValue"); modifiedFilesValue.setBorder(null); comCategory.setEditable(true); comCategory.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Application", "CoreDump", "DataSource", "HeapDump", "Host", "Snapshot", "ThreadDump" })); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(filler, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 400, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, lblProjectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, lblPackageName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, createdFiles, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, modifiedFiles, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, lblName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE) .add(lblDisplayName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)) .add(12, 12, 12) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(txtName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) .add(comCategory, 0, 300, Short.MAX_VALUE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) .add(comPackageName, 0, 300, Short.MAX_VALUE) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE))) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(txtName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(layout.createSequentialGroup() .add(2, 2, 2) .add(lblName))) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER) .add(lblDisplayName) .add(comCategory, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(lblProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(txtProjectName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(lblPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(comPackageName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(36, 36, 36) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(createdFiles) .add(createdFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)) .add(6, 6, 6) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(modifiedFiles) .add(modifiedFilesValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)) .add(filler, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 92, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(20, 20, 20)) ); }// //GEN-END:initComponents private void initAccessibility() { this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_NameAndLocationPanel")); comPackageName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_PackageName")); comCategory.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_DisplayName")); txtName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_Name")); txtProjectName.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ProjectName")); createdFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_CreatedFilesValue")); modifiedFilesValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ModifiedFilesValue")); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox comCategory; private javax.swing.JComboBox comPackageName; private javax.swing.JLabel createdFiles; private javax.swing.JTextArea createdFilesValue; private javax.swing.JLabel filler; private javax.swing.JLabel lblDisplayName; private javax.swing.JLabel lblName; private javax.swing.JLabel lblPackageName; private javax.swing.JLabel lblProjectName; private javax.swing.JLabel modifiedFiles; private javax.swing.JTextArea modifiedFilesValue; private javax.swing.JTextField txtName; private javax.swing.JTextField txtProjectName; // End of variables declaration//GEN-END:variables private static String generateText(String[] relPaths) { StringBuffer sb = new StringBuffer(); if (relPaths.length > 0) { for (int i = 0; i < relPaths.length; i++) { if (i > 0) { sb.append('\n'); } sb.append(relPaths[i]); } } return sb.toString(); } } ././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootvisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/NewActionIterator.javavisualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/NewActionIterator.ja0000644000175000017500000001247013767155557032402 0ustar apoapopackage org.graalvm.visualvm.apisupport.actions; import java.io.IOException; import java.util.HashMap; import java.util.Set; import org.netbeans.api.project.Project; import org.netbeans.modules.apisupport.project.CreatedModifiedFiles; import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; final class NewActionIterator extends BasicWizardIterator { static final String OPENIDE_MODULE_INSTALL = "OpenIDE-Module-Install"; // NOI18N private NewActionIterator.DataModel data; public static final String[] MODULES = { "org.openide.util", // NOI18N "org.openide.modules", // NOI18N "org.graalvm.visualvm.core", // NOI18N "org.graalvm.visualvm.application", // NOI18N "org.graalvm.visualvm.coredump", // NOI18N "org.graalvm.visualvm.heapdump", // NOI18N "org.graalvm.visualvm.threaddump", // NOI18N "org.graalvm.visualvm.host" // NOI18N }; public static NewActionIterator createIterator() { return new NewActionIterator(); } public Set instantiate() throws IOException { CreatedModifiedFiles cmf = data.getCreatedModifiedFiles(); cmf.run(); return getCreatedFiles(cmf, data.getProject()); } protected BasicWizardIterator.Panel[] createPanels(WizardDescriptor wiz) { data = new NewActionIterator.DataModel(wiz); return new BasicWizardIterator.Panel[]{ new NameAndLocationPanel(wiz, data) }; } public @Override void uninitialize( WizardDescriptor wiz) { super.uninitialize(wiz); data = null; } static final class DataModel extends BasicWizardIterator.BasicDataModel { private Project template; private String name; private String displayName; private String category; private CreatedModifiedFiles files; DataModel(WizardDescriptor wiz) { super(wiz); } public CreatedModifiedFiles getCreatedModifiedFiles() { return getFiles(); } public void setCreatedModifiedFiles(CreatedModifiedFiles files) { this.setFiles(files); } public Project getTemplate() { return template; } public void setTemplate(Project template) { this.template = template; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public CreatedModifiedFiles getFiles() { return files; } public void setFiles(CreatedModifiedFiles files) { this.files = files; } } public static void generateFileChanges(DataModel model) { CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject()); NbModuleProvider moduleInfo = model.getModuleInfo(); final String category = model.getCategory(); final String name = model.getName(); final String packageName = model.getPackageName(); HashMap replaceTokens = new HashMap(); replaceTokens.put("DISPLAYNAME", category);//NOI18N replaceTokens.put("TEMPLATENAME", name);//NOI18N replaceTokens.put("PACKAGENAME", packageName);//NOI18N // Update project dependencies for (int i = 0; i < MODULES.length; i++) { fileChanges.add(fileChanges.addModuleDependency(MODULES[i])); } // Generate action class: String iteratorName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName, name, "Action.java"); //NOI18N FileObject template = CreatedModifiedFiles.getTemplate("templateAction.java");//NOI18N fileChanges.add(fileChanges.createFileWithSubstitutions(iteratorName, template, replaceTokens)); //Layer entry: fileChanges.add(fileChanges.createLayerEntry("VisualVM/" + "ExplorerPopupSelection/" + packageName.replace(".", "-") + "-" + name + "Action.instance", //NOI18N null, null, "", null)); //Layer attr: fileChanges.add(fileChanges.createLayerAttribute( "VisualVM/" + "ExplorerPopupSelection/" + packageName.replace(".", "-") + "-" + name + "Action.instance", "position", 3000)); model.setCreatedModifiedFiles(fileChanges); } private static String getRelativePath(String rootPath, String fullyQualifiedPackageName, String prefix, String postfix) { StringBuffer sb = new StringBuffer(); sb.append(rootPath).append('/'). append(fullyQualifiedPackageName.replace('.', '/')). append('/').append(prefix).append(postfix); return sb.toString(); } } visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/visualVMAction.html0000644000175000017500000000043413767155557032254 0ustar apoapo Creates a skeleton VisualVM shared action. visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/templateAction.javx0000644000175000017500000000263413767155557032331 0ustar apoapo<#assign licenseFirst = "/*"> <#assign licensePrefix = " * "> <#assign licenseLast = " */"> <#include "../Licenses/license-${project.license}.txt"> package ${PACKAGENAME}; import org.graalvm.visualvm.application.Application; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.snapshot.Snapshot; import org.graalvm.visualvm.core.ui.actions.SingleDataSourceAction; import org.graalvm.visualvm.coredump.CoreDump; import org.graalvm.visualvm.heapdump.HeapDump; import org.graalvm.visualvm.host.Host; import org.graalvm.visualvm.threaddump.ThreadDump; import java.awt.event.ActionEvent; import javax.swing.Action; import javax.swing.JOptionPane; public class ${TEMPLATENAME}Action extends SingleDataSourceAction<${DISPLAYNAME}> { public ${TEMPLATENAME}Action() { super(${DISPLAYNAME}.class); putValue(Action.NAME, "${TEMPLATENAME}"); putValue(Action.SHORT_DESCRIPTION, "Demoes a menu item"); } @Override protected void actionPerformed(${DISPLAYNAME} arg0, ActionEvent arg1) { JOptionPane.showMessageDialog(null, "hello"); } //Here you can determine whether the menu item is enabled, //depending on the data source type that is selected. In this //example, the menu item is enabled for all types within //the current data source: @Override protected boolean isEnabled(${DISPLAYNAME} arg0) { return true; } } visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/actions/Bundle.properties0000644000175000017500000000322613767155557032013 0ustar apoapo# To change this template, choose Tools | Templates # and open the template in the editor. Templates/VisualVMPluginDevelopment/action=Action LBL_ProjectWizardTitle=VisualVM Action LBL_ProjectSelection_Title=Select Project LBL_NameLocation_Title=Name and Location LBL_ProjectName=&Project\: LBL_PackageName=Pac&kage\: LBL_CreatedFiles=&Created Files\: LBL_ModifiedFiles=&Modified Files\: ACS_SelectProjectPanel=Select Project panel ACS_CTL_btnProject=Browse Project button ACS_CTL_comProject=Select from opened projects combobox LBL_Name=&Template Name \: LBL_DisplayName=D&isplay Name \: LBL_Category=C&ategory LBL_Project_Label=&Project \: LBL_Browse=Bro&wse... ACS_NameAndLocationPanel=Name and Location Panel ACS_CTL_PackageName=Package Name ACS_CTL_Category=Category ACS_CTL_DisplayName=Display Name ACS_CTL_Name=Template Name ACS_CTL_ProjectName=Project Name ACS_CTL_CreatedFilesValue=Created Files ACS_CTL_ModifiedFilesValue=Modified Files MSG_No_Projects=No Projects opened MSG_NoExternalRoots=Projects with external roots are not supported. MSG_NoProjectSelected=A project needs to be selected. ERR_Category_Invalid=Category is malformed. ERR_Name_Prefix_Empty=Template Name is empty. ERR_Name_Prefix_Invalid=Template Name is invalid, not a Java identifier. ERR_Package_Invalid=Package is blank or malformed. ERR_ToBeCreateFileExists=The file {0} already exists. ERR_Missing_Modules=The NetBeans platform is missing required modules. ERR_No_Platform=No NetBeans Platform defined. LBL_Name_1=Action Name: LBL_DisplayName_1=Data Source: LBL_ProjectName_1=Project Name: LBL_PackageName_1=Package Name: LBL_CreatedFiles_1=Created Files: LBL_ModifiedFiles_1=Modified Files:visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/layer.xml0000644000175000017500000001513513767155557026664 0ustar apoapo visualvm-2.0.6/templates/apisupport/src/org/graalvm/visualvm/apisupport/Bundle.properties0000644000175000017500000000055413767155557030354 0ustar apoapoOpenIDE-Module-Display-Category=Developing VisualVM OpenIDE-Module-Long-Description=\ This module adds wizards for the extension points most frequently used while developing VisualVM plugins. OpenIDE-Module-Name=VisualVM API Support OpenIDE-Module-Short-Description=Support for developing VisualVM plugins Templates/VisualVMPluginDevelopment=VisualVM Plugins visualvm-2.0.6/templates/apisupport/nbproject/0000755000175000017500000000000013767155557017724 5ustar apoapovisualvm-2.0.6/templates/apisupport/nbproject/project.xml0000644000175000017500000000714513767155557022123 0ustar apoapo org.netbeans.modules.apisupport.project org.graalvm.visualvm.apisupport org.jdesktop.beansbinding 1 1.9.0.121 org.jdesktop.layout 1 1.15 org.netbeans.modules.apisupport.project 1 org.netbeans.modules.projectapi 1 1.34 org.openide.awt 7.29 org.openide.dialogs 7.17 org.openide.filesystems 7.42 org.openide.util 8.9 visualvm-2.0.6/templates/apisupport/nbproject/build-impl.xml0000644000175000017500000000371513767155557022512 0ustar apoapo visualvm-2.0.6/templates/apisupport/nbproject/project.properties0000644000175000017500000000041213767155557023505 0ustar apoapojavac.source=1.6 javac.compilerargs=-Xlint -Xlint:-serial license.file=../../visualvm/startup/src/org/graalvm/visualvm/modules/startup/LICENSE.txt nbm.homepage=http://visualvm.dev.java.net nbm.module.author=Geertjan Wielenga, Jaroslav Bachorik spec.version.base=1.1 visualvm-2.0.6/templates/apisupport/nbproject/genfiles.properties0000644000175000017500000000071113767155557023635 0ustar apoapobuild.xml.data.CRC32=40e350c9 build.xml.script.CRC32=7e378f36 build.xml.stylesheet.CRC32=a56c6a5b@1.44 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=40e350c9 nbproject/build-impl.xml.script.CRC32=1fb79f12 nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.44 visualvm-2.0.6/templates/apisupport/nbproject/platform.properties0000644000175000017500000000140213767155557023663 0ustar apoapocluster.path=\ ${nbplatform.active.dir}/groovy:\ ${nbplatform.active.dir}/nb:\ ${nbplatform.active.dir}/cnd:\ ${nbplatform.active.dir}/enterprise:\ ${nbplatform.active.dir}/apisupport:\ ${nbplatform.active.dir}/harness:\ ${nbplatform.active.dir}/profiler:\ ${nbplatform.active.dir}/javacard:\ ${nbplatform.active.dir}/dlight:\ ${nbplatform.active.dir}/ergonomics:\ ${nbplatform.active.dir}/php:\ ${nbplatform.active.dir}/identity:\ ${nbplatform.active.dir}/ide:\ ${nbplatform.active.dir}/ruby:\ ${nbplatform.active.dir}/mobility:\ ${nbplatform.active.dir}/java:\ ${nbplatform.active.dir}/platform:\ ${nbplatform.active.dir}/websvccommon nbplatform.active=NetBeans_IDE_7.0_Beta_(Build_201011152355) visualvm-2.0.6/visualvm/0000755000175000017500000000000014013574141013353 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/0000755000175000017500000000000013767155557015574 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/build.xml0000644000175000017500000000100713767155557017413 0ustar apoapo Builds, tests, and runs the project org.graalvm.visualvm.jfr.generic. visualvm-2.0.6/visualvm/jfr.generic/LICENSE.txt0000644000175000017500000005427113767155557017430 0ustar apoapoParts of this work are licensed: The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. Parts of this work are licensed: The Universal Permissive License (UPL), Version 1.0 Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this software, associated documentation and/or data (collectively the "Software"), free of charge and under any and all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or (ii) the Larger Works (as defined below), to deal in both (a) the Software, and (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software (each a “Larger Work” to which the Software is contributed by such licensors), without restriction, including without limitation the rights to copy, create derivative works of, display, perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms. This license is subject to the following condition: The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Copyright (c) 2018 Oracle America, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. visualvm-2.0.6/visualvm/jfr.generic/release/0000755000175000017500000000000013767155557017214 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/release/modules/0000755000175000017500000000000013767155557020664 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/release/modules/ext/0000755000175000017500000000000014013574100021432 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/manifest.mf0000644000175000017500000000060013767155557017722 0ustar apoapoManifest-Version: 1.0 AutoUpdate-Show-In-Client: false AutoUpdate-Essential-Module: true OpenIDE-Module: org.graalvm.visualvm.jfr.generic/2 OpenIDE-Module-Install: org/graalvm/visualvm/jfr/generic/Installer.class OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/jfr/generic/Bundle.properties OpenIDE-Module-Specification-Version: 2.1 OpenIDE-Module-Provides: jfr.implementation visualvm-2.0.6/visualvm/jfr.generic/src/0000755000175000017500000000000013767155557016363 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/src/org/0000755000175000017500000000000013767155557017152 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/0000755000175000017500000000000013767155557020603 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/0000755000175000017500000000000013767155557022451 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/0000755000175000017500000000000013767155557023232 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/0000755000175000017500000000000013767155557024646 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/0000755000175000017500000000000013767155557025746 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/0000755000175000017500000000000013767155557026707 5ustar apoapo././@LongLink0000644000000000000000000000016000000000000011600 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericEventFactory.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericEventF0000644000175000017500000000460113767155557031661 0ustar apoapo/* * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import org.openjdk.jmc.common.item.IItem; import org.openjdk.jmc.common.item.IType; import org.openjdk.jmc.flightrecorder.JfrAttributes; import org.openjdk.jmc.flightrecorder.internal.EventArray; /** * * @author Jiri Sedlacek */ abstract class JFRGenericEventFactory { abstract JFRGenericEvent createEvent(IItem item, long id); static JFRGenericEventFactory resolve(EventArray[] types) { for (EventArray typeA : types) { IType type = typeA.getType(); if (type.getAccessor(JfrAttributes.END_TIME.getKey()) != null) return new V0(); if (type.getAccessor(JfrAttributes.DURATION.getKey()) != null) return new V1(); } throw new RuntimeException("No JFRGenericEventFactory resolved!"); } static class V0 extends JFRGenericEventFactory { @Override JFRGenericEvent createEvent(IItem item, long id) { return new JFRGenericEvent.V0(item, id); } } static class V1 extends JFRGenericEventFactory { @Override JFRGenericEvent createEvent(IItem item, long id) { return new JFRGenericEvent.V1(item, id); } } } ././@LongLink0000644000000000000000000000015200000000000011601 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericMethod.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericMethod0000644000175000017500000000434713767155557031721 0ustar apoapo/* * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import org.graalvm.visualvm.jfr.model.JFRClass; import org.graalvm.visualvm.jfr.model.JFRMethod; import org.openjdk.jmc.common.IMCMethod; import org.openjdk.jmc.common.IMCType; /** * * @author Jiri Sedlacek */ final class JFRGenericMethod extends JFRMethod { private final IMCMethod method; JFRGenericMethod(IMCMethod method) { this.method = method; } @Override public String getName() { return method.getMethodName(); } @Override public String getDescriptor() { return method.getFormalDescriptor(); } @Override public JFRClass getType() { IMCType type = method.getType(); return type == null ? null : new JFRGenericClass(type); } @Override public int hashCode() { return method.hashCode(); } @Override public boolean equals(Object o) { return o instanceof JFRGenericMethod ? method.equals(((JFRGenericMethod)o).method) : false; } } ././@LongLink0000644000000000000000000000015100000000000011600 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericClass.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericClass.0000644000175000017500000000354413767155557031622 0ustar apoapo/* * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import org.graalvm.visualvm.jfr.model.JFRClass; import org.openjdk.jmc.common.IMCType; /** * * @author Jiri Sedlacek */ final class JFRGenericClass extends JFRClass { private final IMCType type; JFRGenericClass(IMCType type) { this.type = type; } @Override public String getName() { return type.getFullName(); } @Override public int hashCode() { return type.hashCode(); } @Override public boolean equals(Object o) { return o instanceof JFRGenericClass ? type.equals(((JFRGenericClass)o).type) : false; } } ././@LongLink0000644000000000000000000000015500000000000011604 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericEventType.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericEventT0000644000175000017500000000675013767155557031706 0ustar apoapo/* * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.graalvm.visualvm.jfr.model.JFRDataDescriptor; import org.graalvm.visualvm.jfr.model.JFREventType; import org.openjdk.jmc.common.item.IAccessorKey; import org.openjdk.jmc.common.item.IItem; import org.openjdk.jmc.common.item.IType; import org.openjdk.jmc.flightrecorder.messages.internal.Messages; /** * * @author Jiri Sedlacek */ final class JFRGenericEventType extends JFREventType { static final String EXPERIMENTAL_PREFIX = Messages.getString(Messages.TypeManager_EXPERIMENTAL_TYPE).replace("{0}", "").trim(); // NOI18N private final long typeId; private final IType type; private final String[] category; JFRGenericEventType(long typeId, IType type, String[] category) { this.typeId = typeId; this.type = type; this.category = category; } @Override public long getId() { return typeId; } @Override public String getName() { return type.getIdentifier(); } @Override public String getDisplayName() { return type.getName(); } @Override public String getDescription() { return type.getDescription(); } @Override public List getCategory() { return Arrays.asList(category); } @Override public List getDisplayableDataDescriptors(boolean includeExperimental) { List descriptors = new ArrayList(); Iterator keys = DisplayableSupport.displayableAccessorKeys(type, includeExperimental); while (keys.hasNext()) descriptors.add(DisplayableSupport.getDataDescriptor(keys.next())); return descriptors; } @Override public boolean isExperimental() { // TODO: should be turned into regexp and test matching, not startsWith! return type.getName().startsWith(EXPERIMENTAL_PREFIX); } @Override public int hashCode() { return type.hashCode(); } @Override public boolean equals(Object o) { return o instanceof JFRGenericEventType ? type.equals(((JFRGenericEventType)o).type) : false; } } ././@LongLink0000644000000000000000000000015200000000000011601 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericThread.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericThread0000644000175000017500000000407713767155557031710 0ustar apoapo/* * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import org.graalvm.visualvm.jfr.model.JFRThread; import org.openjdk.jmc.common.IMCThread; /** * * @author Jiri Sedlacek */ final class JFRGenericThread extends JFRThread { private final IMCThread thread; public JFRGenericThread(IMCThread thread) { this.thread = thread; } @Override public long getId() { // VM Thread throws NPE here try { return thread.getThreadId(); } catch (NullPointerException e) { return 0; } } @Override public String getName() { return thread.getThreadName(); } @Override public int hashCode() { return thread.hashCode(); } @Override public boolean equals(Object o) { return o instanceof JFRGenericThread ? thread.equals(((JFRGenericThread)o).thread) : false; } } ././@LongLink0000644000000000000000000000016100000000000011601 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericModelProvider.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericModelP0000644000175000017500000000434713767155557031661 0ustar apoapo/* * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import java.io.File; import java.io.IOException; import org.graalvm.visualvm.jfr.model.JFRModel; import org.graalvm.visualvm.jfr.model.JFRModelFactory; import org.graalvm.visualvm.jfr.model.JFRModelProvider; import org.openjdk.jmc.flightrecorder.CouldNotLoadRecordingException; import org.openjdk.jmc.flightrecorder.internal.NotEnoughMemoryException; /** * * @author Jiri Sedlacek */ public final class JFRGenericModelProvider extends JFRModelProvider { private JFRGenericModelProvider() { super("generic loader", 10); // NOI18N } public static void register() { JFRModelFactory.getDefault().registerProvider(new JFRGenericModelProvider()); } @Override protected JFRModel createModel(String id, File file) throws IOException, CouldNotLoadRecordingException { try { return new JFRGenericModel(id, file); } catch (NotEnoughMemoryException e) { throw new OutOfMemoryError(e.getMessage()); } } } ././@LongLink0000644000000000000000000000015100000000000011600 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericEvent.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericEvent.0000644000175000017500000003354413767155557031641 0ustar apoapo/* * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.graalvm.visualvm.jfr.model.JFRClass; import org.graalvm.visualvm.jfr.model.JFREvent; import org.graalvm.visualvm.jfr.model.JFRPropertyNotAvailableException; import org.graalvm.visualvm.jfr.model.JFRStackTrace; import org.graalvm.visualvm.jfr.model.JFRThread; import org.openjdk.jmc.common.IMCStackTrace; import org.openjdk.jmc.common.IMCThread; import org.openjdk.jmc.common.IMCType; import org.openjdk.jmc.common.item.IAccessorKey; import org.openjdk.jmc.common.item.IAttribute; import org.openjdk.jmc.common.item.IItem; import org.openjdk.jmc.common.item.IMemberAccessor; import org.openjdk.jmc.common.item.IType; import org.openjdk.jmc.common.unit.IQuantity; import org.openjdk.jmc.common.unit.QuantityConversionException; import org.openjdk.jmc.common.unit.UnitLookup; import org.openjdk.jmc.flightrecorder.JfrAttributes; /** * * @author Jiri Sedlacek */ abstract class JFRGenericEvent extends JFREvent { final IItem item; protected JFRGenericEvent(IItem event, long id) { super(id); this.item = event; } protected abstract IQuantity getEventStartTime() throws JFRPropertyNotAvailableException; protected abstract IQuantity getEventEndTime() throws JFRPropertyNotAvailableException; protected abstract IQuantity getEventDuration() throws JFRPropertyNotAvailableException; protected abstract Object getThreadThread() throws JFRPropertyNotAvailableException; @Override public Instant getInstant(String key) throws JFRPropertyNotAvailableException { switch (key) { case "eventTime": // NOI18N case "startTime": // NOI18N IQuantity startTime = getEventStartTime(); return startTime == null ? null : instantFromQuantity(startTime); case "endTime": // NOI18N IQuantity endTime = getEventStartTime(); return endTime == null ? null : instantFromQuantity(endTime); } Object time = getValue(key); if (time instanceof IQuantity) return instantFromQuantity((IQuantity)time); else if (time == null) return null; else throw new JFRPropertyNotAvailableException("No instant value available: " + key); } private static Instant instantFromQuantity(IQuantity quantity) { // TimestampUnit ms = null; // for (Object u : quantity.getType().getCommonUnits()) { // if (u instanceof TimestampUnit) { // TimestampUnit lu = (TimestampUnit)u; // if ("epochms".equals(lu.getIdentifier())) { // ms = lu; // break; // } // } // } // // try { // return Instant.ofEpochMilli(quantity.longValueIn(ms)); // } catch (QuantityConversionException ex) { //// System.err.println(">>> " + ex); // return null; // } // quantity expected to be always in epochns or epochms try { long nanos = quantity.longValueIn(UnitLookup.EPOCH_NS); return Instant.EPOCH.plusNanos(nanos); } catch (QuantityConversionException ex1) { try { long millis = quantity.longValueIn(UnitLookup.EPOCH_MS); return Instant.ofEpochMilli(millis); } catch (QuantityConversionException ex3) { long seconds = quantity.clampedLongValueIn(UnitLookup.EPOCH_S); return Instant.ofEpochSecond(seconds); } } // IQuantity seconds = quantity.in(UnitLookup.EPOCH_S); // IQuantity nanos = quantity.subtract(seconds).in(UnitLookup.NANOSECOND); // // return Instant.ofEpochSecond(seconds.longValue(), nanos.longValue()); } @Override public Duration getDuration(String key) throws JFRPropertyNotAvailableException { if ("eventDuration".equals(key)) { // NOI18N IQuantity duration = getEventDuration(); return duration == null ? null : durationFromQuantity(duration); } Object duration = getValue(key); if (duration instanceof IQuantity) return durationFromQuantity((IQuantity)duration); else if (duration == null) return null; else throw new JFRPropertyNotAvailableException("No duration value available: " + key); // NOI18N } private static Duration durationFromQuantity(IQuantity quantity) { // quantity can be in ticks or time units - ms, us, ns etc. try { long nanos = quantity.longValueIn(UnitLookup.NANOSECOND); return Duration.ofNanos(nanos); } catch (QuantityConversionException ex1) { // try { // long micros = quantity.longValueIn(UnitLookup.MICROSECOND); // return Duration.ofNanos(micros * 1000); // } catch (QuantityConversionException ex2) { try { long millis = quantity.longValueIn(UnitLookup.MILLISECOND); return Duration.ofMillis(millis); } catch (QuantityConversionException ex3) { long seconds = quantity.clampedLongValueIn(UnitLookup.SECOND); return Duration.ofSeconds(seconds); } // } } } @Override public JFRClass getClass(String key) throws JFRPropertyNotAvailableException { Object value = getValue(key); if (value instanceof IMCType) return new JFRGenericClass((IMCType)value); else if (value == null) return null; else throw new JFRPropertyNotAvailableException("No class value available: " + key); } @Override public JFRThread getThread(String key) throws JFRPropertyNotAvailableException { Object thread; switch (key) { case "eventThread": // NOI18N IMCThread eventThread = getValue(JfrAttributes.EVENT_THREAD); return eventThread == null ? null : new JFRGenericThread(eventThread); case "sampledThread": // NOI18N switch (item.getType().getIdentifier()) { case "jdk.ExecutionSample": // NOI18N case "jdk.NativeMethodSample": // NOI18N IMCThread sampledThread = getValue(JfrAttributes.EVENT_THREAD); return sampledThread == null ? null : new JFRGenericThread(sampledThread); default: thread = getValue(key); break; } break; case "thread": // NOI18N switch (item.getType().getIdentifier()) { case "jdk.ThreadStart": // NOI18N case "jdk.ThreadEnd": // NOI18N thread = getThreadThread(); break; case "jdk.ThreadAllocationStatistics": // NOI18N IMCThread sampledThread = getValue(JfrAttributes.EVENT_THREAD); return sampledThread == null ? null : new JFRGenericThread(sampledThread); default: thread = getValue(key); break; } break; default: thread = getValue(key); } if (thread instanceof IMCThread) return new JFRGenericThread((IMCThread)thread); else if (thread == null) return null; else throw new JFRPropertyNotAvailableException("No thread value available: " + key); } @Override public JFRStackTrace getStackTrace(String key) throws JFRPropertyNotAvailableException { if ("eventStackTrace".equals(key)) { // NOI18N IMCStackTrace stackTrace = getValue(JfrAttributes.EVENT_STACKTRACE); return stackTrace == null ? null : new JFRGenericStackTrace(stackTrace); } Object stackTrace = getValue(key); if (stackTrace instanceof IMCStackTrace) return new JFRGenericStackTrace((IMCStackTrace)stackTrace); else if (stackTrace == null) return null; else throw new JFRPropertyNotAvailableException("No stacktrace value available: " + key); } @Override public Object getValue(String key) throws JFRPropertyNotAvailableException { key = key.replace('.', ':'); // NOI18N IType type = item.getType(); for (IAccessorKey accessor : type.getAccessorKeys().keySet()) { if (key.equals(accessor.getIdentifier())) return type.getAccessor(accessor).getMember(item); } throw new JFRPropertyNotAvailableException("No value available: " + key); } protected T getValue(IAttribute attribute) throws JFRPropertyNotAvailableException { IType type = item.getType(); IMemberAccessor accessor = type.getAccessor(attribute.getKey()); if (accessor == null) throw new JFRPropertyNotAvailableException("No value available: " + attribute.getIdentifier()); return accessor.getMember(item); } @Override public List getDisplayableValues(boolean includeExperimental) { IType type = item.getType(); List values = new ArrayList(); Iterator keys = DisplayableSupport.displayableAccessorKeys(type, includeExperimental); while (keys.hasNext()) { IAccessorKey key = keys.next(); Object value = type.getAccessor(key).getMember(item); if (value instanceof Comparable) values.add((Comparable)value); else values.add(key.getContentType().getDefaultFormatter().format(value)); } return values; } @Override public int hashCode() { return item.hashCode(); } @Override public boolean equals(Object o) { return o instanceof JFRGenericEvent ? item.equals(((JFRGenericEvent)o).item) : false; } @Override public String toString() { return item.toString() + " [" + item.getType().getAccessorKeys().keySet() + "]"; // NOI18N } // JFREvent for .jfr v0 (JDK 7 & 8) static final class V0 extends JFRGenericEvent { V0(IItem event, long id) { super(event, id); } @Override protected IQuantity getEventStartTime() throws JFRPropertyNotAvailableException { IType type = item.getType(); IMemberAccessor startAccessor = type.getAccessor(JfrAttributes.START_TIME.getKey()); return startAccessor != null ? startAccessor.getMember(item) : getEventEndTime(); } @Override protected IQuantity getEventEndTime() throws JFRPropertyNotAvailableException { return getValue(JfrAttributes.END_TIME); } @Override protected IQuantity getEventDuration() throws JFRPropertyNotAvailableException { IQuantity startTime = getValue(JfrAttributes.START_TIME); if (startTime == null) throw new JFRPropertyNotAvailableException("No start time to compute event duration"); IQuantity endTime = getValue(JfrAttributes.END_TIME); if (endTime == null) throw new JFRPropertyNotAvailableException("No end time to compute event duration"); return endTime.subtract(startTime); } @Override protected Object getThreadThread() throws JFRPropertyNotAvailableException { return getValue("javalangthread"); // NOI18N } } // JFREvent for .jfr v1 and v2 (JDK 9+) static final class V1 extends JFRGenericEvent { V1(IItem event, long id) { super(event, id); } @Override protected IQuantity getEventStartTime() throws JFRPropertyNotAvailableException { return getValue(JfrAttributes.START_TIME); } @Override protected IQuantity getEventEndTime() throws JFRPropertyNotAvailableException { return getEventStartTime().add(getEventDuration()); } @Override protected IQuantity getEventDuration() throws JFRPropertyNotAvailableException { return getValue(JfrAttributes.DURATION); } @Override protected Object getThreadThread() throws JFRPropertyNotAvailableException { return getValue("thread"); // NOI18N } } } ././@LongLink0000644000000000000000000000015400000000000011603 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/DisplayableSupport.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/DisplayableSuppo0000644000175000017500000001137313767155557032117 0ustar apoapo/* * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import java.text.FieldPosition; import java.text.Format; import java.text.ParsePosition; import java.util.Iterator; import org.graalvm.visualvm.jfr.model.JFRDataDescriptor; import org.openjdk.jmc.common.item.IAccessorKey; import org.openjdk.jmc.common.item.IType; import org.openjdk.jmc.common.unit.ContentType; import org.openjdk.jmc.common.unit.IFormatter; import org.openjdk.jmc.common.unit.LinearKindOfQuantity; import org.openjdk.jmc.common.util.TypeHandling; import org.openjdk.jmc.flightrecorder.JfrAttributes; /** * * @author Jiri Sedlacek */ final class DisplayableSupport { static Iterator displayableAccessorKeys(final IType type, final boolean includeExperimental) { return new Iterator() { private final String ID_STACKTRACE; private final Iterator master; private IAccessorKey next; { ID_STACKTRACE = JfrAttributes.EVENT_STACKTRACE.getIdentifier(); master = type.getAccessorKeys().keySet().iterator(); next = computeNext(); } @Override public boolean hasNext() { return next != null; } @Override public IAccessorKey next() { IAccessorKey ret = next; next = computeNext(); return ret; } private IAccessorKey computeNext() { while (master.hasNext()) { IAccessorKey _next = master.next(); if (isDisplayable(_next)) return _next; } return null; } private boolean isDisplayable(IAccessorKey key) { if (ID_STACKTRACE.equals(key.getIdentifier())) return false; return includeExperimental || !isExperimental(key); } }; } static JFRDataDescriptor getDataDescriptor(IAccessorKey key) { String dataName = TypeHandling.getValueString(key); String dataDescription = TypeHandling.getVerboseString(key); ContentType contentType = key.getContentType(); Format dataFormat = new DataFormat(contentType.getDefaultFormatter()); boolean isNumericData = contentType instanceof LinearKindOfQuantity; return new JFRDataDescriptor(dataName, dataDescription, dataFormat, null, isNumericData); } private static boolean isExperimental(IAccessorKey key) { // TODO: should be turned into regexp and test matching, not startsWith! String accessorName = TypeHandling.getValueString(key); return accessorName.startsWith(JFRGenericEventType.EXPERIMENTAL_PREFIX); } private DisplayableSupport() {} private static class DataFormat extends Format { private final IFormatter formatter; DataFormat(IFormatter formatter) { this.formatter = formatter; } @Override public StringBuffer format(Object o, StringBuffer b, FieldPosition p) { if (o == null) return b.append(""); // NOI18N if (o instanceof String) return b.append(o.toString()); return b.append(formatter.format(o)); } @Override public Object parseObject(String source, ParsePosition pos) { throw new UnsupportedOperationException("Not supported."); // NOI18N } } } ././@LongLink0000644000000000000000000000015600000000000011605 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericStackFrame.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericStackF0000644000175000017500000000521313767155557031645 0ustar apoapo/* * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import org.graalvm.visualvm.jfr.model.JFRMethod; import org.graalvm.visualvm.jfr.model.JFRStackFrame; import org.openjdk.jmc.common.IMCFrame; import org.openjdk.jmc.common.IMCMethod; /** * * @author Jiri Sedlacek */ final class JFRGenericStackFrame extends JFRStackFrame { private final IMCFrame stackFrame; JFRGenericStackFrame(IMCFrame stackFrame) { this.stackFrame = stackFrame; } @Override public JFRMethod getMethod() { IMCMethod method = stackFrame.getMethod(); return method == null ? null : new JFRGenericMethod(method); } @Override public int getLine() { return stackFrame.getFrameLineNumber(); } @Override public int getBCI() { return stackFrame.getBCI(); } @Override public String getType() { switch (stackFrame.getType()) { case JIT_COMPILED: return "JIT compiled"; // NOI18 case INTERPRETED: return "Interpreted"; // NOI18 case INLINED: return "Inlined"; // NOI18 default: return "Native"; // NOI18N // ?? } } @Override public int hashCode() { return stackFrame.hashCode(); } @Override public boolean equals(Object o) { return o instanceof JFRGenericStackFrame ? stackFrame.equals(((JFRGenericStackFrame)o).stackFrame) : false; } } ././@LongLink0000644000000000000000000000015600000000000011605 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericStackTrace.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericStackT0000644000175000017500000000472613767155557031673 0ustar apoapo/* * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import java.util.ArrayList; import java.util.List; import org.graalvm.visualvm.jfr.model.JFRStackFrame; import org.graalvm.visualvm.jfr.model.JFRStackTrace; import org.openjdk.jmc.common.IMCFrame; import org.openjdk.jmc.common.IMCStackTrace; /** * * @author Jiri Sedlacek */ final class JFRGenericStackTrace extends JFRStackTrace { private final IMCStackTrace stackTrace; JFRGenericStackTrace(IMCStackTrace stackTrace) { this.stackTrace = stackTrace; } @Override public List getFrames() { List imcFrames = stackTrace.getFrames(); List frames = new ArrayList(imcFrames.size()); for (IMCFrame imcFrame : imcFrames) frames.add(new JFRGenericStackFrame(imcFrame)); return frames; } @Override public boolean isTruncated() { return stackTrace.getTruncationState().isTruncated(); } @Override public int hashCode() { return stackTrace.hashCode(); } @Override public boolean equals(Object o) { return o instanceof JFRGenericStackTrace ? stackTrace.equals(((JFRGenericStackTrace)o).stackTrace) : false; } } ././@LongLink0000644000000000000000000000015100000000000011600 Lustar rootrootvisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericModel.javavisualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/model/impl/JFRGenericModel.0000644000175000017500000001333513767155557031614 0ustar apoapo/* * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic.model.impl; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.graalvm.visualvm.jfr.model.JFREvent; import org.graalvm.visualvm.jfr.model.JFREventType; import org.graalvm.visualvm.jfr.model.JFREventTypeVisitor; import org.graalvm.visualvm.jfr.model.JFREventVisitor; import org.graalvm.visualvm.jfr.model.JFRModel; import org.openjdk.jmc.common.io.IOToolkit; import org.openjdk.jmc.common.item.IItem; import org.openjdk.jmc.common.item.IType; import org.openjdk.jmc.flightrecorder.CouldNotLoadRecordingException; import org.openjdk.jmc.flightrecorder.internal.EventArray; import org.openjdk.jmc.flightrecorder.internal.FlightRecordingLoader; /** * * @author Jiri Sedlacek */ final class JFRGenericModel extends JFRModel { private static final Logger LOGGER = Logger.getLogger(JFRModel.class.getName()); private final EventArray[] types; private final JFRGenericEventFactory factory; JFRGenericModel(String id, File snapshotFile) throws IOException, CouldNotLoadRecordingException { super(id); types = loadFile(snapshotFile); factory = JFRGenericEventFactory.resolve(types); initialize(); } @Override public void visitEvents(JFREventVisitor... visitors) { // Notify all visitors 'init' for (JFREventVisitor visitor : visitors) visitor.init(); // Notify visitors that are not done 'visit' try { List _visitors = new ArrayList(Arrays.asList(visitors)); Iterator iterables = Arrays.asList(types).iterator(); long id = 0; while (!_visitors.isEmpty() && iterables.hasNext()) { EventArray type = iterables.next(); String typeId = type.getType().getIdentifier(); Iterator items = Arrays.asList(type.getEvents()).iterator(); while (!_visitors.isEmpty() && items.hasNext()) { JFREvent event = factory.createEvent(items.next(), id++); Iterator _visitorsI = _visitors.iterator(); while (_visitorsI.hasNext()) if (_visitorsI.next().visit(typeId, event)) _visitorsI.remove(); } } } catch (Exception e) { LOGGER.log(Level.INFO, "Error visiting JFR events (generic loader)", e); // NOI18N } finally { // Notify all visitors 'done' for (JFREventVisitor visitor : visitors) visitor.done(); } } @Override public void visitEventTypes(JFREventTypeVisitor... visitors) { // Notify all visitors 'init' for (JFREventTypeVisitor visitor : visitors) visitor.initTypes(); // Notify visitors that are not done 'visitType' try { List _visitors = new ArrayList(Arrays.asList(visitors)); int typeIdx = 0; while (!_visitors.isEmpty() && typeIdx < types.length) { EventArray type = types[typeIdx]; IType itype = type.getType(); String typeId = itype.getIdentifier(); String[] typeCategory = type.getTypeCategory(); if (typeCategory == null) typeCategory = new String[] { "Uncategorized" }; JFREventType event = new JFRGenericEventType(typeIdx++, itype, typeCategory); Iterator _visitorsI = _visitors.iterator(); while (_visitorsI.hasNext()) if (_visitorsI.next().visitType(typeId, event)) _visitorsI.remove(); } } catch (Exception e) { LOGGER.log(Level.INFO, "Error visiting JFR event types (generic loader)", e); // NOI18N } finally { // Notify all visitors 'done' for (JFREventTypeVisitor visitor : visitors) visitor.doneTypes(); } } private static EventArray[] loadFile(File file) throws IOException, CouldNotLoadRecordingException { InputStream stream = IOToolkit.openUncompressedStream(file); try { return FlightRecordingLoader.loadStream(stream, false, true); } finally { IOToolkit.closeSilently(stream); } } } visualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/Installer.java0000644000175000017500000000301013767155557027440 0ustar apoapo/* * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.jfr.generic; import org.graalvm.visualvm.jfr.generic.model.impl.JFRGenericModelProvider; import org.openide.modules.ModuleInstall; /** * * @author Jiri Sedlacek */ final class Installer extends ModuleInstall { public void restored() { JFRGenericModelProvider.register(); } } visualvm-2.0.6/visualvm/jfr.generic/src/org/graalvm/visualvm/jfr/generic/Bundle.properties0000644000175000017500000000363013767155557030177 0ustar apoapo# # Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. OpenIDE-Module-Display-Category=JFR Loaders OpenIDE-Module-Long-Description=Generic JFR loader reading all JFR snapshots. #

For better performance and lower memory consumption when running VisualVM on JDK 9 and newer, please install also one of the following JFR loaders:

VisualVM-JFR-JDK9: Support for the JFR loader bundled with JDK 9 and JDK 10 (requires running VisualVM on JDK 9/10) reading JFR snapshots created from JDK 9 and JDK 10\n

VisualVM-JFR-JDK11: Support for the JFR loader bundled with JDK 11 and newer (requires running VisualVM on JDK 11+) reading JFR snapshots created from JDK 9 and newer OpenIDE-Module-Name=VisualVM-JFR-Generic OpenIDE-Module-Short-Description=Generic JFR loader reading all JFR snapshots visualvm-2.0.6/visualvm/jfr.generic/nbproject/0000755000175000017500000000000013767155557017562 5ustar apoapovisualvm-2.0.6/visualvm/jfr.generic/nbproject/project.xml0000644000175000017500000000503613767155557021756 0ustar apoapo org.netbeans.modules.apisupport.project org.graalvm.visualvm.jfr.generic org.graalvm.visualvm.core 2 2.0 org.graalvm.visualvm.jfr 2 2.1 org.openide.modules 7.49 org.openide.util.ui 9.8 ext/common-7.1.1.jar release/modules/ext/common-7.1.1.jar ext/flightrecorder-7.1.1.jar release/modules/ext/flightrecorder-7.1.1.jar visualvm-2.0.6/visualvm/jfr.generic/nbproject/build-impl.xml0000644000175000017500000000277613767155557022356 0ustar apoapo You must set 'suite.dir' to point to your containing module suite visualvm-2.0.6/visualvm/jfr.generic/nbproject/project.properties0000644000175000017500000000030313767155557023342 0ustar apoapois.autoload=true javac.compilerargs=-Xlint -Xlint:-serial javac.source=1.8 license.file=LICENSE.txt nbm.homepage=https://visualvm.github.io nbm.module.author=Jiri Sedlacek nbm.needs.restart=true visualvm-2.0.6/visualvm/jfr.generic/nbproject/suite.properties0000644000175000017500000000003013767155557023022 0ustar apoaposuite.dir=${basedir}/.. visualvm-2.0.6/visualvm/jfr.generic/nbproject/genfiles.properties0000644000175000017500000000071513767155557023477 0ustar apoapobuild.xml.data.CRC32=56e1456d build.xml.script.CRC32=8bce95d6 build.xml.stylesheet.CRC32=15ca8a54@2.76.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=56e1456d nbproject/build-impl.xml.script.CRC32=53506612 nbproject/build-impl.xml.stylesheet.CRC32=1016842c@2.76.1 visualvm-2.0.6/visualvm/core/0000755000175000017500000000000013767155557014330 5ustar apoapovisualvm-2.0.6/visualvm/core/build.xml0000644000175000017500000000321613767155557016153 0ustar apoapo Builds, tests, and runs the project org.graalvm.visualvm.core. visualvm-2.0.6/visualvm/core/test/0000755000175000017500000000000013767155557015307 5ustar apoapovisualvm-2.0.6/visualvm/core/test/unit/0000755000175000017500000000000013767155557016266 5ustar apoapovisualvm-2.0.6/visualvm/core/test/unit/src/0000755000175000017500000000000013767155557017055 5ustar apoapovisualvm-2.0.6/visualvm/core/test/unit/src/com/0000755000175000017500000000000013767155557017633 5ustar apoapovisualvm-2.0.6/visualvm/core/test/unit/src/com/sun/0000755000175000017500000000000013767155557020440 5ustar apoapovisualvm-2.0.6/visualvm/core/test/unit/src/com/sun/tools/0000755000175000017500000000000013767155557021600 5ustar apoapovisualvm-2.0.6/visualvm/core/test/unit/src/com/sun/tools/visualvm/0000755000175000017500000000000013767155557023446 5ustar apoapovisualvm-2.0.6/visualvm/core/test/unit/src/com/sun/tools/visualvm/core/0000755000175000017500000000000013767155557024376 5ustar apoapovisualvm-2.0.6/visualvm/core/test/unit/src/com/sun/tools/visualvm/core/scheduler/0000755000175000017500000000000013767155557026354 5ustar apoapo././@LongLink0000644000000000000000000000015700000000000011606 Lustar rootrootvisualvm-2.0.6/visualvm/core/test/unit/src/com/sun/tools/visualvm/core/scheduler/DefaultScheduledTaskTest.javavisualvm-2.0.6/visualvm/core/test/unit/src/com/sun/tools/visualvm/core/scheduler/DefaultScheduledTas0000644000175000017500000000702213767155557032155 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; /** * * @author Jaroslav Bachorik */ public class DefaultScheduledTaskTest { private SchedulerTask dummyTask = new SchedulerTask() { public void onSchedule(long timeStamp) { // do nothing } }; private DefaultScheduledTask instance; final private static Quantum DEFAULT_INTERVAL = Quantum.seconds(10); public DefaultScheduledTaskTest() { } @BeforeClass public static void setUpClass() throws Exception { } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { instance = new DefaultScheduledTask(DEFAULT_INTERVAL, dummyTask); } @After public void tearDown() { instance = null; } /** * Test of setInterval method, of class DefaultScheduledTask. */ @Test public void setInterval() { System.out.println("setInterval"); Quantum interval = Quantum.SUSPENDED; assertEquals(DEFAULT_INTERVAL, instance.getInterval()); instance.setInterval(interval); assertEquals(interval, instance.getInterval()); } /** * Test of suspend method, of class DefaultScheduledTask. */ @Test public void suspend() { System.out.println("suspend"); instance.suspend(); assertEquals(Quantum.SUSPENDED, instance.getInterval()); } /** * Test of resume method, of class DefaultScheduledTask. */ @Test public void resume() { System.out.println("resume"); instance.suspend(); instance.resume(); assertEquals(DEFAULT_INTERVAL, instance.getInterval()); } /** * Test of isSuspended method, of class DefaultScheduledTask. */ @Test public void isSuspended() { System.out.println("isSuspended"); assertFalse(instance.isSuspended()); instance.suspend(); assertTrue(instance.isSuspended()); instance.resume(); assertFalse(instance.isSuspended()); } }visualvm-2.0.6/visualvm/core/test/unit/src/com/sun/tools/visualvm/core/scheduler/QuantumTest.java0000644000175000017500000000467413767155557031524 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; /** * * @author Jaroslav Bachorik */ public class QuantumTest { public QuantumTest() { } @BeforeClass public static void setUpClass() throws Exception { } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { } @After public void tearDown() { } /** * Test of equals method, of class Quantum. */ @Test public void equalsBasic() { System.out.println("basic equals"); Quantum instance1 = Quantum.seconds(10); Quantum instance2 = Quantum.seconds(10); Quantum instance3 = Quantum.seconds(20); assertFalse(instance1 == instance2 || instance2 == instance3 || instance1 == instance3); assertTrue(instance1.equals(instance2)); assertTrue(instance2.equals(instance1)); assertFalse(instance2.equals(instance3)); assertFalse(instance3.equals(instance2)); assertFalse(instance1.equals(instance3)); assertFalse(instance3.equals(instance1)); } }visualvm-2.0.6/visualvm/core/test/unit/src/com/sun/tools/visualvm/core/scheduler/SchedulerTest.java0000644000175000017500000002647513767155557032013 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.Collection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; /** * * @author Jaroslav Bachorik */ public class SchedulerTest { private final Collection stasks = new ArrayList(); public SchedulerTest() { } @BeforeClass public static void setUpClass() throws Exception { } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { stasks.clear(); } @After public void tearDown() { for(ScheduledTask stask : stasks) { Scheduler.sharedInstance().unschedule(stask); } } /** * Test of sharedInstance method, of class Scheduler. */ @Test public void sharedInstance() { System.out.println("sharedInstance"); Scheduler result1 = Scheduler.sharedInstance(); Scheduler result2 = Scheduler.sharedInstance(); assertTrue(result1 == result2); // shared instance MUST remain the same across all calls } /** * Test of schedule method, immediate execution, of class Scheduler. */ @Test public void scheduleImmediate() { System.out.println("schedule, immediate"); final CountDownLatch barrier = new CountDownLatch(1); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { barrier.countDown(); } }; Quantum interval = Quantum.seconds(2000); Scheduler instance = Scheduler.sharedInstance(); ScheduledTask scheduled = instance.schedule(task, interval, true); stasks.add(scheduled); try { boolean executed = barrier.await(1000, TimeUnit.SECONDS); assertTrue(executed); } catch (InterruptedException e) { fail(e.getMessage()); } } /** * Test of schedule method, immediate execution, blocking in the scheduled task, of class Scheduler. */ @Test public void scheduleImmediateBlocking() { System.out.println("schedule, immediate, blocking"); final CountDownLatch barrier = new CountDownLatch(1); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { try { barrier.countDown(); Thread.sleep(10000000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }; Quantum interval = Quantum.seconds(2000); Scheduler instance = Scheduler.sharedInstance(); ScheduledTask scheduled = instance.schedule(task, interval, true); stasks.add(scheduled); try { boolean executed = barrier.await(1000, TimeUnit.SECONDS); assertTrue(executed); } catch (InterruptedException e) { fail(e.getMessage()); } } /** * Test of schedule method of class Scheduler. */ @Test public void schedule() { System.out.println("schedule"); final CountDownLatch barrier = new CountDownLatch(1); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { barrier.countDown(); } }; Quantum interval = Quantum.seconds(5); Scheduler instance = Scheduler.sharedInstance(); ScheduledTask scheduled = instance.schedule(task, interval, false); stasks.add(scheduled); try { boolean executed = barrier.await(8, TimeUnit.SECONDS); assertTrue(executed); } catch (InterruptedException e) { fail(e.getMessage()); } } /** * Test of unschedule method, of class Scheduler. */ @Test public void unschedule() { System.out.println("unschedule"); final AtomicBoolean executed = new AtomicBoolean(false); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { executed.set(true); } }; Scheduler instance = Scheduler.sharedInstance(); ScheduledTask scheduled = instance.schedule(task, Quantum.seconds(3), false); instance.unschedule(scheduled); try { Thread.sleep(5000); } catch (InterruptedException e) { fail(e.getMessage()); } assertFalse(executed.get()); } /** * Test of dynamic rescheduling capability of class Scheduler. */ @Test public void dynamicReschedule() { System.out.println("dynamicReschedule"); final CountDownLatch barrier1 = new CountDownLatch(1); final CountDownLatch barrier2 = new CountDownLatch(2); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { System.out.println("dynamicReschedule; executing periodic task"); barrier1.countDown(); barrier2.countDown(); } }; final ScheduledTask scheduled = Scheduler.sharedInstance().schedule(task, Quantum.seconds(7), false); stasks.add(scheduled); try { if (!barrier1.await(10, TimeUnit.SECONDS)) { fail(); } scheduled.setInterval(Quantum.seconds(2)); if (!barrier2.await(5, TimeUnit.SECONDS)) { fail(); } } catch (InterruptedException e) { fail(e.getMessage()); } } @Test public void dynamicRescheduleSuspended() { System.out.println("dynamicReschedule suspended"); final CountDownLatch barrier1 = new CountDownLatch(1); final CountDownLatch barrier2 = new CountDownLatch(5); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { System.out.println("dynamicReschedule; executing periodic task"); barrier1.countDown(); barrier2.countDown(); } }; final ScheduledTask scheduled = Scheduler.sharedInstance().schedule(task, Quantum.SUSPENDED, false); stasks.add(scheduled); try { if (barrier1.await(5, TimeUnit.SECONDS)) { fail(); } scheduled.resume(); if (barrier2.await(2, TimeUnit.SECONDS)) { fail(); } scheduled.setInterval(Quantum.seconds(1)); if (!barrier2.await(8, TimeUnit.SECONDS)) { fail(); } } catch (InterruptedException e) { fail(e.getMessage()); } } @Test public void suspendResume() { System.out.println("suspend-resume"); final CountDownLatch barrier1 = new CountDownLatch(1); final CountDownLatch barrier2 = new CountDownLatch(5); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { barrier1.countDown(); barrier2.countDown(); } }; final ScheduledTask scheduled = Scheduler.sharedInstance().schedule(task, Quantum.seconds(2), false); stasks.add(scheduled); try { if (!barrier1.await(3, TimeUnit.SECONDS)) { fail(); } scheduled.suspend(); if (barrier2.await(3, TimeUnit.SECONDS)) { fail(); } scheduled.resume(); if (!barrier2.await(10, TimeUnit.SECONDS)) { fail(); } } catch (InterruptedException e) { fail(e.getMessage()); } } @Test public void suspendSuspend() { System.out.println("suspend-suspend"); final CountDownLatch barrier1 = new CountDownLatch(1); final CountDownLatch barrier2 = new CountDownLatch(2); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { barrier1.countDown(); barrier2.countDown(); } }; final ScheduledTask scheduled = Scheduler.sharedInstance().schedule(task, Quantum.seconds(2), false); stasks.add(scheduled); try { if (!barrier1.await(3, TimeUnit.SECONDS)) { fail(); } scheduled.suspend(); if (barrier2.await(3, TimeUnit.SECONDS)) { fail(); } scheduled.suspend(); if (barrier2.await(3, TimeUnit.SECONDS)) { fail(); } } catch (InterruptedException e) { fail(e.getMessage()); } } @Test public void suspendSuspendResume() { System.out.println("suspend-suspend-resume"); final CountDownLatch barrier1 = new CountDownLatch(1); final CountDownLatch barrier2 = new CountDownLatch(2); SchedulerTask task = new SchedulerTask() { public void onSchedule(long timeStamp) { barrier1.countDown(); barrier2.countDown(); } }; final ScheduledTask scheduled = Scheduler.sharedInstance().schedule(task, Quantum.seconds(2), false); stasks.add(scheduled); try { if (!barrier1.await(3, TimeUnit.SECONDS)) { fail(); } scheduled.suspend(); if (barrier2.await(3, TimeUnit.SECONDS)) { fail(); } scheduled.suspend(); if (barrier2.await(3, TimeUnit.SECONDS)) { fail(); } scheduled.resume(); if (!barrier2.await(3, TimeUnit.SECONDS)) { fail(); } } catch (InterruptedException e) { fail(e.getMessage()); } } } visualvm-2.0.6/visualvm/core/manifest.mf0000644000175000017500000000057513767155557016471 0ustar apoapoManifest-Version: 1.0 AutoUpdate-Show-In-Client: false AutoUpdate-Essential-Module: true OpenIDE-Module: org.graalvm.visualvm.core/2 OpenIDE-Module-Layer: org/graalvm/visualvm/core/layer.xml OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/core/Bundle.properties OpenIDE-Module-Install: org/graalvm/visualvm/core/Install$Impl.class OpenIDE-Module-Specification-Version: 2.2 visualvm-2.0.6/visualvm/core/src/0000755000175000017500000000000013767155557015117 5ustar apoapovisualvm-2.0.6/visualvm/core/src/META-INF/0000755000175000017500000000000013767155557016257 5ustar apoapovisualvm-2.0.6/visualvm/core/src/META-INF/services/0000755000175000017500000000000013767155557020102 5ustar apoapovisualvm-2.0.6/visualvm/core/src/META-INF/services/org.netbeans.spi.sendopts.OptionProcessor0000644000175000017500000000006413767155557030211 0ustar apoapoorg.graalvm.visualvm.core.snapshot.options.Openfile visualvm-2.0.6/visualvm/core/src/org/0000755000175000017500000000000013767155557015706 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/0000755000175000017500000000000013767155557017337 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/0000755000175000017500000000000013767155557021205 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/0000755000175000017500000000000013767155557022135 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/0000755000175000017500000000000013767155557022552 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceWindowListener.java0000644000175000017500000000314213767155557030345 0ustar apoapo/* * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; /** * Listener for tracking opening and closing window of a DataSource. * * @param DataSource type * * @author Jiri Sedlacek */ public interface DataSourceWindowListener { public default void windowOpened(X dataSource) {} public default void windowClosed(X dataSource) {}; } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceWindowTabbedPane.java0000644000175000017500000002147213767155557030553 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.ui.components.DataViewComponent; import org.graalvm.visualvm.uisupport.UISupport; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Insets; import javax.swing.ImageIcon; import java.util.ArrayList; import java.util.List; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.UIManager; import org.graalvm.visualvm.uisupport.ProfilerTabbedPane; import org.openide.util.NbBundle; /** * TabbedPane container allowing to control if tabs can be closed or not * * @author Jiri Sedlacek * */ abstract class DataSourceWindowTabbedPane extends JPanel { private final ProfilerTabbedPane tabpane; // --- Workaround to use the correct Close button on Windows 10 -------------- // static { // if (isWindows10() && isWindowsXPLaF()) { // UIManager.put( "nb.close.tab.icon.enabled.name", "org/openide/awt/resources/win8_bigclose_enabled.png"); // NOI18N // UIManager.put( "nb.close.tab.icon.pressed.name", "org/openide/awt/resources/win8_bigclose_pressed.png"); // NOI18N // UIManager.put( "nb.close.tab.icon.rollover.name", "org/openide/awt/resources/win8_bigclose_rollover.png"); // NOI18N // } // } // private static boolean isWindows10() { // String osName = System.getProperty ("os.name"); // NOI18N // return osName.indexOf("Windows 10") >= 0 // NOI18N // || (osName.equals( "Windows NT (unknown)" ) && "10.0".equals( System.getProperty("os.version") )); // NOI18N // } // private static boolean isWindowsXPLaF() { // Boolean isXP = (Boolean)Toolkit.getDefaultToolkit(). // getDesktopProperty("win.xpstyle.themeActive"); // NOI18N // return isWindowsLaF() && (isXP == null ? false : isXP.booleanValue()); // } // private static boolean isWindowsLaF () { // String lfID = UIManager.getLookAndFeel().getID(); // return lfID.endsWith("Windows"); // NOI18N // } // --------------------------------------------------------------------------- DataSourceWindowTabbedPane() { super(new BorderLayout()); tabpane = new ProfilerTabbedPane() { @Override protected void closeTab(Component component) { closeView((ViewContainer)component); } }; // tabpane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); // GH-52 - true would break Tab navigation tabpane.setFocusCycleRoot(false); // Clear default border for fill up the entire DataSourceWindow tabpane.setOpaque(false); if (UIManager.getLookAndFeel().getID().equals("Aqua")) { // NOI18N tabpane.setBorder(BorderFactory.createEmptyBorder(0, -11, -13, -10)); } else { tabpane.setBorder(BorderFactory.createEmptyBorder()); Insets i = UIManager.getInsets("TabbedPane.contentBorderInsets"); // NOI18N if (i != null) tabpane.setBorder(BorderFactory.createEmptyBorder(0, -i.left, -i.bottom, -i.right)); } add(tabpane, BorderLayout.CENTER); } public final boolean requestFocusInWindow() { Component sel = tabpane.getSelectedComponent(); if (sel != null) return sel.requestFocusInWindow(); else return super.requestFocusInWindow(); } public void addView(DataSource dataSource, DataSourceView view) { ViewContainer container = new ViewContainer(new DataSourceCaption(view.getDataSource()), view); tabpane.addTab(view.getName(), new ImageIcon(view.getImage()), container, null, view.isClosable()); } public void insertView(DataSource dataSource, DataSourceView view, int index) { ViewContainer container = new ViewContainer(new DataSourceCaption(view.getDataSource()), view); tabpane.insertTab(view.getName(), new ImageIcon(view.getImage()), container, null, view.isClosable(), index); } public void removeView(int index) { ViewContainer container = (ViewContainer)tabpane.getComponentAt(index); tabpane.removeTabAt(index); container.getCaption().finish(); } void clearView(int index) { ViewContainer container = (ViewContainer)tabpane.getComponentAt(index); container.removeAll(); if (container.caption != null) container.caption.finish(); container.setReloading(); container.doLayout(); container.repaint(); } ViewContainer getContainer(DataSourceView view) { String name = view.getName(); // int position = view.getPreferredPosition(); for (int i = 0; i < tabpane.getTabCount(); i++) if (tabpane.getTitleAt(i).equals(name)) return (ViewContainer)tabpane.getComponentAt(i); return null; } public DataSourceView getView(ViewContainer container) { return container.getView(); } public int indexOfView(final DataSourceView view) { final int[] index = new int[1]; index[0] = -1; UISupport.runInEventDispatchThreadAndWait(new Runnable() { public void run() { for (int i = 0; i < tabpane.getTabCount(); i++) if (((ViewContainer)tabpane.getComponentAt(i)).getViewComponent() == view.getView()) index[0] = i; } }); return index[0]; } public List getViews() { List views = new ArrayList(); for (int i = 0; i < tabpane.getTabCount(); i++) { ViewContainer container = (ViewContainer)tabpane.getComponentAt(i); views.add(container.getView()); } return views; } public void setViewIndex(int index) { tabpane.setSelectedIndex(index); } public void setViewBackground(int index, Color background) { tabpane.setBackgroundAt(index, background); } protected abstract void closeView(DataSourceWindowTabbedPane.ViewContainer view); static class ViewContainer extends JPanel { private DataSourceCaption caption; private DataSourceView view; private DataViewComponent viewComponent; public ViewContainer(DataSourceCaption caption, DataSourceView view) { Color backgroundColor = UISupport.getDefaultBackground(); setLayout(new BorderLayout()); setBorder(BorderFactory.createMatteBorder(0, 5, 5, 5, backgroundColor)); setBackground(backgroundColor); setFocusable(false); setView(view); setCaption(caption); } public final boolean requestFocusInWindow() { if (getComponentCount() > 0) return getComponent(0).requestFocusInWindow(); else return super.requestFocusInWindow(); } final void setCaption(DataSourceCaption caption) { this.caption = caption; if (caption != null) { caption.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); add(caption, BorderLayout.NORTH); } } public DataSourceCaption getCaption() { return caption; } final void setView(DataSourceView view) { this.view = view; this.viewComponent = view.getView(); add(viewComponent, BorderLayout.CENTER); setName(view.getName()); } public DataSourceView getView() { return view; } public DataViewComponent getViewComponent() { return viewComponent; } final void setReloading() { JLabel l = new JLabel(NbBundle.getMessage(DataSourceWindowTabbedPane.class, "DataSourceCaption_MSG_Reloading"), JLabel.CENTER); // NOI18N l.setEnabled(false); add(l, BorderLayout.CENTER); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DesktopUtils.java0000644000175000017500000001036013767155557026047 0ustar apoapo/* /* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import java.awt.Desktop; import java.io.File; import java.io.IOException; import java.net.URI; /** * Support for java.awt.Desktop * * @author Jiri Sedlacek */ public final class DesktopUtils { private static final Object allowDesktopOpen = System.getProperty("org.graalvm.visualvm.core.ui.DesktopUtils.allowDesktopOpen"); // NOI18N private static boolean desktopSupported; private static boolean desktopSupportedInitialized = false; private static boolean browseAvailable; private static boolean browseAvailableInitialized = false; private static boolean openAvailable; private static boolean openAvailableInitialized = false; /** * Returns true if java.awt.Desktop is supported on host platform. * * @return true if java.awt.Desktop is supported on host platform, false otherwise. */ public synchronized static boolean isDesktopSupported() { if (!desktopSupportedInitialized) { desktopSupported = Desktop.isDesktopSupported(); desktopSupportedInitialized = true; } return desktopSupported; } // NOTE: should always return true if in NetBeans IDE (uses its own user-customizable mechanism) /** * Returns true if opening a www address in a web browser is supported on host platform. * * @return true if opening a www address in a web browser is supported on host platform, false otherwise. */ public synchronized static boolean isBrowseAvailable() { if (!browseAvailableInitialized) { if (!isDesktopSupported()) browseAvailable = false; else browseAvailable = Desktop.getDesktop().isSupported(Desktop.Action.BROWSE); browseAvailableInitialized = true; } return browseAvailable; } /** * Returns true if opening a file in native displayer is supported on host platform. * * @return true if opening a file in native displayer is supported on host platform, false otherwise. */ public synchronized static boolean isOpenAvailable() { if (!openAvailableInitialized) { // NOTE: Open is disabled by default, crashes the VM at least on Windows if ("true".equals(allowDesktopOpen) && isDesktopSupported()) openAvailable = Desktop.getDesktop().isSupported(Desktop.Action.OPEN); // NOI18N else openAvailable = false; openAvailableInitialized = true; } return openAvailable; } // NOTE: If in NetBeans IDE use HtmlBrowser.URLDisplayer.showURL(URL u) /** * Performs Desktop.getDesktop().browse(URI). * * @param uri URI to open. * @throws java.io.IOException */ public static void browse(URI uri) throws IOException { Desktop.getDesktop().browse(uri); } /** * Performs Desktop.getDesktop().open(File). * * @param file File to open. * @throws java.io.IOException */ public static void open(File file) throws IOException { Desktop.getDesktop().open(file); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/0000755000175000017500000000000013767155557024564 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/loadSnapshot.png0000644000175000017500000000124413767155557027732 0ustar apoapoPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<6IDATxb?C~mbTE>$ 0222 ߿OW'MuUO" ` 3 ë_`2߿ v>М(@L5Ng`:3| ?dpc$ @1lyfoAubM0? LLX 8 `q0L޽}!`bmk #+ -#7m6óiK+{7~~°lK1F:f0a<q2:_ X@ .1991|À2<}h?0bVFP: .x9Ǐ|7Bӻw@~l `:k?1j > gAz߿_}E h'ÿlF; ó'O{ m}n{@$Ô(1(11`ֱtGIENDB`././@LongLink0000644000000000000000000000015000000000000011577 Lustar rootrootvisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/ExplorerTopComponentWstcref.xmlvisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/ExplorerTopComponentWstcref.0000644000175000017500000000050013767155557032264 0ustar apoapo visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon5.png0000644000175000017500000000677413767155557027305 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄKlTe~f&8it IeCL h uC*H41c4ƶ 4Rv̠ntA쓼yvZJzũg.]w !\vb'2?G H}czzWJVJiٶ#l!Z)<8ҋ{/9W JR>č2]mb6q;G|ߏٍsoZ1f"5xgT~Bœs9}ss>W 9;wBTR Gqh_W՝Zg7V= {}0tLkVcނ&&}k'(Bi:`n>q4ZkHc_eG(>?2C}=A aA3Q:VσGcϓ͔3" hNIJB1Q9zifa5VIRX2Q~۷Z`n$1Fw:?qq'S+߿Go'ebEƄi$Z?|S#0ƚRfZ*}=(3^v~&XK)Z3m[GZk H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄ]hW=y|4]Tʹz1dzSd/ZE 1NDv^TUHjjtMis{{v*l=Hk s.t>}5}.͆8٦E}@J~cp&\,f\JcʘJvn#pz_R'=+S973r|YƕJW`XK#}y-O i SO7 G9%DF"7ZJ)4tsȽH>_1 qtO[G3v)1tcT*"Eɮ+p$ řs^kBO| OQJc7 T]p ^7wGCzl'UV*Pz-kYR#u/$?5,:w쓾7~4MRBP**7$H)Qcc'91TD.>W- xcI&\c~]l]IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon1.png0000644000175000017500000000700113767155557027261 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄoSeƟ2` ۲P؆#NYe!Wxa M1xx $j4l&::֖nm=s4!$O\|GRb-b?ͽ~ձrNL1Ee9Y=&C;gҽ僋7odiP16[>:}KWSXrk\y[s3FsRLo>P`=Hl*XTkZ6}?ƹHmeu1]0hpmys_j9ABtiLdaiq8ѰU3PH)6BA1& ruzw6u]dC:Ua."#so/Ķ]L&jdc۾tMj&=U83g9Pm6< NRn:jE(i%3j^Kt mW/ َj؛tS*?u݈ /{*1F̈0͈TEe3'DRzfdx#B(%bP)h4e|l_7^;gkSJOxjOj[,iLPBe h:9[8 Hbl 4IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon13.png0000644000175000017500000000700213767155557027345 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄKlTUsνޙΝ2*8VjB`Bѝ+%jL&RDwFEÈPKRASB;{0ݐ~ɿoV2?ATZz^\JYqkfچkTO <ϯÃ=Ρ^?}S"Q%4+BP(Z_W;1(xOܩ"## a0H4J!;.fO~!CMM70)Bӗ"ؕ] 7 WDTDbagmbj3m1 @zhs{_z0sׂDTc'&AĦ3Rmmcp62{_pLq]Sc~쎫Ţ!V*8dSUh`YGO8su}* s]A4nY2T!L c9ӧy~U! \^Mʔ6#@uNkkkh4X1KXMpdmu]ʹnmZ0M3Dpb2jc|8q]@{0Ǐ`qb!_~0n@ ~`9bzCԅ I s6=c+1@, 733|4'Kr IR j 6>&Kw 6 C@^)yW1hȀ٧/߁@ qb<@Y{K İl&0_JN ?gܙp/YŶn w %@]'kҜ^d׀ H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_F)IDATxڄMleǟy?ffgۭt[ڴB-A# UhBQI BՃDS#1D [`[",Zvwvѝy?f^/`z~skJ)XOZ^<٫KFBJݝ\}L7^%ҷNR\zyqa3c|ǟ~9G~>y!mm#[pn8ͤKsj N=,K)QRJ%ܞ'?vq!HBƠp~j4ixIJV 7 QmBH@)%9|s6$V:N 4L0G[\+vWBcBM:]CyR ]._*&?l=Ssrs$Ժ?kJLTYs3|vc;~_wBT6~`LSJcwwX,-+aGۚmcmfB2-0(թy(yc visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/snapshotBadge.png0000644000175000017500000000042113767155557030051 0ustar apoapoPNG  IHDRasRGBbKGD pHYs  tIME,7=xIDAT8c@!5`XOq'4FFF|a |߿ v>sW`;~~oן~2ZIW{o_goAuI4be###C@r IԜ¤IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/explorer.png0000644000175000017500000000115513767155557027134 0ustar apoapoPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?% _iqlmq߿YDכ s1 ߿~%2020mA u Νet ;vx88Y8 H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄMh\Ussg~ɝIL231]1D]TPE mS] QBq%bIXŅX$"]$fH2M6I:{qJ65}Hk {ꏯ}Tv.ιiq=׍=A` ʸ q@pI9\q;=Ll'n3.B"s=۝==αyvkSgPPXY{g{eؐkz)P~q݃}yXpxӨ8~E) Ţlf{QW~O ߼1}?a̱۹l}4vS۹ཹbl !C}7M,.3Y2 2>CRJjpuk!`mmK~0<qTBL ~?B!p2ze)۶|~bi"Jr!D¾qũRԲj6[cNLA}Fƞ2 '3aƂJꛫ*F~''fֺO[x̲-fLPN6I7cV_+%&IбhC/#5!~^~8v9lqla45MBt4i a=)|.,VReYT9X,JT& ׭ q$3g/+ճ #J5Za* DvPj=| 7w A5G?IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon14.png0000644000175000017500000000700213767155557027346 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄ_hSWƿsν7IM IECL)4YەF:2n"†S烲 61sel u2'8jM5s^:p|o{v]7um}wcۏۮ|w?KA39'uqǩ:޶cEai١oput,@XjAٕ !T!sqjz.ㄪ% g]8_(Ea2ZL{iSKs.LÍ)9T1.(ޛFtZ ֮ њL34'?1tB%0Tr7 8G+p%k*+Tk5]:_Zh.\Ln|ݶmju:33V8/5!²>pV|^/q+!L&RNE cml Y>OL=`|<{i`a2UU9ǛJ^NVzCa04iSd}mj@4W44ܩ'Ϟm.w'elf3?)eڟr9<ȺPN$"$_ޭᱝjѣyGUewWvWg]|k4Laj03 DnI&j_{}c_wfۿG1IRBJ7ҼS!yk>4qX/->2/41J1 H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄKH\gw&QgF'0j0֪bmK]B"R"B JEUh BmQcRF㤣߽Ƃ[Rͭډ.&[=iCiꙌɅ8b˲80zK|>1p4kR;!41!cJ))KRJo7HWcco;< X'*vc-X]}s:edn瑛9DؑTk}07 H~.],+-L~`( e_h}_5E\d'rƔ5rsqK)Ij||zmFeL֌PF)Wx{JU˲q08gk\mocF6ᰡt]~kEwϜjRC:;;c|KǗR9q(c"B0TUƷ^y1N/.\awB`TsHa-H'_XIENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon10.png0000644000175000017500000000676013767155557027354 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_F IDATxڄoTUƟ{νsL)C3!B 1FI B&+ 0ia!!$Hi;3Z30sӅٽo>R ۩c+mGf/}J hqMkn*Mn* !R(Ʌ 󮐲%L8֛?ur~|<$}?)8x'B)e=[:}x.duM)յOkq>5 t9пR@Z]]+G̭>i cSG^'dS?m+p7n~povnPI)ɏhb _~^o__o睷8 Ev #OlZBJƹHť(DQJKnf5?>~nSV[P(zv`\nJ)xMƔh_x CLtF"Rsh۔sNa'/{lV ?ݝ=PTl.ѩq˲)}xͦoWD╱Q7VkziM)58|Ϩi1VO,Sg3hAp4I)Qay6R BȳWf>/c,mc[Vնe,b]Nc;-7o1RܼcnuA1& ,& X+0T<+B.ڶ9&JʩB~ڣ)#d(qĞxY29qc~-ѠIENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon12.png0000644000175000017500000000700513767155557027347 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_F IDATxڄMlTU}^gJg̴3[h+a&154w4n1(D6 ג!*IBK Zjfw_rvvia3\w@`Xg,z+Io  :g.E 6 sOJYKvYx7zƦ8ƫ+ߙ׊"!Dۑu4NkBgvfgIENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/saveSnapshot.png0000644000175000017500000000121513767155557027747 0ustar apoapoPNG  IHDRasRGBbKGD pHYs  tIME"尚 IDAT8˕MHTQ;sΌԅ1ɚ(\3%6AJjAE(Zeg*D4(6)hE{gxB:~oYC_EDXOa@9/NK{P*ʺ=(&";ɶ  Wz5ji<+z|-4j L}R/s5?,n " ~'RyWqm+>n[*ڞ L (oXO@"*B8hôO wY415ýX5|S|Hl ]w2)-3Gj1ы3njacG/BfHH,a*y^PKeYD[w #f&nrqD4DDi岫)KȌp9:goFu;YGDbz$;ۃmԧٹ=ɵu>݈m Hv) ;Z>͌gasK+IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/idle-icon.png0000644000175000017500000000644013767155557027141 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_F;IDATxڄ?hawr$BIDq) TCͥCť[7h] ]:&mCM6]r%WoyyyyJ)8i~畂5I&r63Ͳ̟z5Ш/9H(!,+?W . ,W|(p5D|8NJ)tB1=O&{f>z~z Ѳ,z:*`LS͹.?z2\5wY:_ED½yc-s>| ̏j{WvF<_A#bj*5ai KXɸ0k8?,Mrk4]H#?I 5F"~,snDRX\5^b\6+R3#am{;@uvR0E4ۋ 5" Jm#/'wk@0RZ,nJ)00ܨՏtU;HRBr8#5pHM ̤fe&/@o 05IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon8.png0000644000175000017500000000701213767155557027272 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_F%IDATxڄOh\Uſ{߻h޴M:NҴŨ3*EP+EVJv#".TP(T$m]hBi%8:1VL&$s{dxm8( CXjĵBj$&icW]Z.ΣRʹɽdWp,96s!4c !Y"qυgYV P4\!)d 1|9n4Fqo}yVa32蝵- Jkf. .TOOk@Z:;L+ _JnF =CG=3m wcW^2؎1-k*(\Y*U!ጷc!L Mspn;8ǜ Xۻ}Z7˕ E_}摾?^ z !dٲ,MO<*3A 9rRJTo~w?'ުR Py( O:᷑JmzMt!],-.nJGL3fF.%u 0 stTv]ё<ϭy;yw]ǡX!aoZH feLD{Ȏ5Vr]Gٔjjڶ-Iva@Us6T+َBkm&5qkQ(NaIENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/options.png0000644000175000017500000000233213767155557026765 0ustar apoapoPNG  IHDR szzsRGBIDATXŗKlTeδ@PJZ^F񁉐@xDb " _3Bw,$w4PcaB.TVB(Pʣm;3b 3L_r}|sHZ? GkΞi˞v߳MwOqV YAD |DӴt0jf3!"M ("H~V`lZ4'EQQM95-p\v .Nmn&i_LA  @?nΕ :o[]Hsf=͎j3T0`8pX/NDp GáAdƌ.7hcbG/m|ڸ5qDƷCLG BdTIsGَnW JC#!@_V}X2]ٻyKKeE%Ww(!1;ݸT9Y\ H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄoTUs}̫ӑBg(E-D,H T^ I0.\( 4 T(Z@)-1LiZso;;s9nH?w|w_T*-OwwsVKp FoL% R>z1 4 3ggq'c07 > ca]oE&""Z0`$Jb)9_;6(B RJ9a}+ eTkRsRJT.ˎk2ưlsx9 !p, 9EnG[t@k7B}'u?MM#)}4IX~IiocfkdI(䉣޼y5VkGۉ,۶uwmUfW=R XIJLE!@f`UԬW4@tBnnnǢH|~jjz.7_m[!~mK\$x,9}d6.=3DmY-?9[(LÌ1|pދtll*uҞza0T?^z c;Dٽ^~|鸋iҴeZe irà ]'IBiRR;2?řtOoݾ{zTJQ*2TԠR'"dChŝ ); RҨAm۬!45gb/p Bg:{fKIENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon0.png0000644000175000017500000000700413767155557027263 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄMlTU{Weʔ/-BG i0&MLLda+C0 4D$0Gj im Lyw߼{ݠ,9CR3w|/G~iA[Imvre^!~y{}5 z(bήuƏ?"v6D45M(BRP)QJQKXN//;l糧4D(`WƮ^{5~@l;ho-纻3Ry#gSa(xRvgމɩݦi"!T_<<\{,5Yޚ7 !bse2o' ڰ!SyQy)I&|8&"hTn,SX2u.“ɤG9_x^ 0feXT*9qOJI|?hԘT(:!RX]&c~~{?{]CFtS3M9sg89dnL2fH֛uIO6zBvǷZ"[RikhnN#siNgىYEs{G%=@REѡ7[u3 k{R Ð&cLv>zđϿsк"ED4 !@RjT%{rO<cƹo [3N_({c2]]; o;yS| UdIENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/saveSnapshot24.png0000644000175000017500000000172613767155557030124 0ustar apoapoPNG  IHDRw=sRGBbKGD pHYs  tIME&^VIDATHǵ_TU?:ܹޙDav?%"lb(Z f-*CP> ISB.FdfЦH-(Dek궅X;ͽ{a0wp'<~s;2iF!/`&c/  R \BF LB}x#S^:q:GE0wK!2ư",^R؉_e~xH)[s`` KP>73ƮOAkN`懀4f^ R ݃5h 6 B)E! e8`ݦD)x1lò,&|@>fUY'}wv6ϫܼK*tSW([uxsI9/3qP.ҷ~ ²[ ,n[qԵE.>Yu+%k;d²' 8JW1XIͫ5ՏnM;k:-Ir;ATK9qR{ln:mfUe-fUھ8#빧9^Ym-m9Pҟ^~i-8Du7#˥]YqoQҟls?5UxW^<<ϣyMb5^rޒu&>-qw"7r!+Wz*KKwpO\0&%=5BE@cfq6J;IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/closePanel.png0000644000175000017500000000044113767155557027356 0ustar apoapoPNG  IHDR5Y ^gAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxbr>%ť[AnGo`Fk}%eƖV%%E޷o+RUU[@`y޷nA1AM]g[1-=[`I M5haaCSKg`c_ V`HB/@IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon3.png0000644000175000017500000000676413767155557027302 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄkUƿsfLmKu{٦[+]^[C}B_ "$ R(^JMPRh5Vlmnݘf63gn`{GRX#~-7 0R55tuvnZ' 8O?_yZ- } Q쥞_ űgOyέV7hիc_:xF7gra5rm +V>x( ,/}oE&8IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/busy-icon2.png0000644000175000017500000000700113767155557027262 0ustar apoapoPNG  IHDRa pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-gAMA|Q cHRMz%u0`:o_FIDATxڄoTeƟv̙vZ /E* PBх[ݹqD!RD .rh-ô0s9M7IœMbrfg95KW )H8L¾|J6; p=ع]s\׳0R|Zm˕n * }+s#c6l{Ζww11~Eq ?kwJj5ٶ XWܜLF&#?vn}ي6ZaD(*%cuv|oݜ^oijz&aCvagKK$۾c{;.ƨi]R}] ʽL8PzPXs] (bNRK)ug0pss+KO eiۖs@2p<>T-\ !$0Tk.JM/Զ:/<`fvn[s纔2Ѧd%s Wxy_VcuȺ,Kh!Q~q;w'?99y}nLw~O1W.sY۶ c,޿&JXlmYJ_ܞ#DQ=ϏqO#ηG #)e㡓pU1[oXQzc-Kdc1fN>D@(F+hoOW|bY[X ׾:{ͥR !LL~`ڇچQoiIENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/resources/loadSnapshot24.png0000644000175000017500000000172413767155557030103 0ustar apoapoPNG  IHDRw=gAMA7tEXtSoftwareAdobe ImageReadyqe<fIDATxb?-@11 2'!2}_~ +N$nj fb$F>>>FdO>1L1 MDYP< i ?X^AB\\կ_ c@ MK8;Y_ _0 @ uH(W , {qs1s< "e`x;V t;_0 ЅqOj~܂1011/?@}0yb8Xߺ oz(&F@n'ß?>KZ2DXKwɐ͌E~ VR ĂHV|Ňń| X-#@E`o$h :$ sXYY4@!#ɚ f ޾Ō\ð~,$\ H򁸄s>ǀQb0s1xZPn  o߾fsɳp{bb N ,,x уW )Newk_ |,  @p |O/_o ?O~IxǏ/ 97v*?1>@` }_| > 4e <ٷ/R _HYB.h;`|> ؂wn"?0bvv- ß߿cYXXsU)g߽z`2* P!J>q z ^IENDB`visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceViewPlugin.java0000644000175000017500000000735413767155557027472 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.ui.components.DataViewComponent; /** * Plugin to an existing DataSourceView which adds an additional view. * * @author Jiri Sedlacek */ public abstract class DataSourceViewPlugin { private DataSource dataSource; private DataSourceViewPluginProvider controller; /** * Creates new DataSourrceViewPlugin for a DataSource. * * @param dataSource DataSource for which to add the plugin. */ public DataSourceViewPlugin(DataSource dataSource) { this.dataSource = dataSource; } /** * Returns DataSource for the plugin. * * @return DataSource for the plugin. */ public final DataSource getDataSource() { return dataSource; } /** * Creates DataViewComponent.DetailsView which will be plugged into the DataSourceView. * * @param location location where the DataViewComponent.DetailsView will be added. * @return DataViewComponent.DetailsView of the plugin for the location or null. */ public abstract DataViewComponent.DetailsView createView(int location); /** * Notification when the view is about to be added to DataSourceWindow. * This notification comes from a thread other than EDT and its main intention * is to provide a possibility to do some models inits before the actual UI is displayed. * This call is blocking (blocks opening the view, progress bar is shown) but long-running initializations should * still use separate thread and update the UI after the models are ready. */ protected void willBeAdded() { } /** * Notification when the view has been added to DataSourceWindow. * This notification comes from a thread other than EDT. */ protected void added() { } /** * Notification when the view has been either programatically removed from tabbed pane or closed by the user by clicking the X. * This notification comes from a thread other than EDT */ protected void removed() { } void pluginWillBeAdded() { willBeAdded(); controller.pluginWillBeAdded(this); } void pluginAdded() { added(); controller.pluginAdded(this); } void pluginRemoved() { removed(); controller.pluginRemoved(this); } void setController(DataSourceViewPluginProvider controller) { this.controller = controller; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceWindow.java0000644000175000017500000003525213767155557026646 0ustar apoapo/* * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptor; import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory; import org.graalvm.visualvm.core.ui.DataSourceView.Alert; import org.graalvm.visualvm.uisupport.UISupport; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Image; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JPanel; import javax.swing.SwingUtilities; import org.openide.util.RequestProcessor; import org.openide.util.WeakListeners; import org.openide.windows.TopComponent; /** * * @author Jiri Sedlacek */ class DataSourceWindow extends TopComponent implements PropertyChangeListener { private static final RequestProcessor PROCESSOR = new RequestProcessor("DataSourceWindow Processor", 5); // NOI18N private static final Logger LOGGER = Logger.getLogger(DataSourceWindow.class.getName()); private int viewsCount = 0; private DataSource dataSource; private DataSourceDescriptor dataSourceDescriptor; private DataSourceWindowTabbedPane.ViewContainer singleViewContainer; private JPanel multiViewContainer; private AlertListener alertListener; public DataSourceWindow(DataSource dataSource) { this.dataSource = dataSource; initAppearance(); initComponents(); } public DataSource getDataSource() { return dataSource; } public void addView(DataSourceView view) { if (viewsCount == 0) { singleViewContainer = new DataSourceWindowTabbedPane.ViewContainer(new DataSourceCaption(view.getDataSource()), view); add(singleViewContainer, BorderLayout.CENTER); doLayout(); alertListener = new AlertListener(); } else if (viewsCount == 1) { remove(singleViewContainer); add(multiViewContainer, BorderLayout.CENTER); tabbedContainer.addView(dataSource, singleViewContainer.getView()); tabbedContainer.addView(dataSource, view); doLayout(); singleViewContainer.getCaption().finish(); singleViewContainer = null; } else { tabbedContainer.addView(dataSource, view); } viewsCount++; view.addPropertyChangeListener(WeakListeners.propertyChange(alertListener,view)); } private void insertView(DataSourceView view, int index) { if (viewsCount == 0) { singleViewContainer = new DataSourceWindowTabbedPane.ViewContainer(new DataSourceCaption(view.getDataSource()), view); add(singleViewContainer, BorderLayout.CENTER); doLayout(); alertListener = new AlertListener(); } else if (viewsCount == 1) { remove(singleViewContainer); add(multiViewContainer, BorderLayout.CENTER); tabbedContainer.addView(dataSource, singleViewContainer.getView()); tabbedContainer.insertView(dataSource, view, index); doLayout(); singleViewContainer.getCaption().finish(); singleViewContainer = null; } else { tabbedContainer.insertView(dataSource, view, index); } viewsCount++; view.addPropertyChangeListener(WeakListeners.propertyChange(alertListener,view)); } public void selectView(DataSourceView view) { if (viewsCount > 1) { int viewIndex = indexOf(view); if (viewIndex == -1) throw new RuntimeException("View " + view + " not present in DataSourceWindow " + this); // NOI18N else tabbedContainer.setViewIndex(viewIndex); } } public void removeView(final DataSourceView view) { if (viewsCount == 1) { if (view != singleViewContainer.getView()) throw new RuntimeException("View " + view + " not present in DataSourceWindow " + this); // NOI18N view.viewWillBeRemoved(); remove(singleViewContainer); singleViewContainer.getCaption().finish(); singleViewContainer = null; } else { int viewIndex = indexOf(view); if (viewIndex == -1) throw new RuntimeException("View " + view + " not present in DataSourceWindow " + this); // NOI18N view.viewWillBeRemoved(); tabbedContainer.removeView(viewIndex); if (viewsCount == 2) { DataSourceView remaining = tabbedContainer.getViews().get(0); singleViewContainer = new DataSourceWindowTabbedPane.ViewContainer(new DataSourceCaption(remaining.getDataSource()), remaining); remove(multiViewContainer); tabbedContainer.removeView(0); add(singleViewContainer, BorderLayout.CENTER); doLayout(); } } PROCESSOR.post(new Runnable() { public void run() { try { view.viewRemoved(); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed notifying removed view " + view, e); } // NOI18N } }); DataSourceWindowManager.sharedInstance().unregisterClosedView(view); viewsCount--; if (viewsCount == 0 && isOpened()) close(); } void clearView(final DataSourceView view, RequestProcessor notificationProcessor) { if (viewsCount == 1 && Objects.equals(singleViewContainer.getName(), view.getName())) { view.viewWillBeRemoved(); singleViewContainer.removeAll(); if (singleViewContainer.getCaption() != null) singleViewContainer.getCaption().finish(); singleViewContainer.setReloading(); singleViewContainer.doLayout(); singleViewContainer.repaint(); } else { int viewIndex = indexOf(view); if (viewIndex == -1) return; view.viewWillBeRemoved(); tabbedContainer.clearView(viewIndex); } notificationProcessor.post(new Runnable() { public void run() { try { view.viewRemoved(); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed notifying removed view " + view, e); } // NOI18N } }); } void updateView(final DataSourceView view, int index) { if (viewsCount == 1 && Objects.equals(singleViewContainer.getName(), view.getName())) { singleViewContainer.removeAll(); singleViewContainer.setCaption(new DataSourceCaption(view.getDataSource())); singleViewContainer.setView(view); singleViewContainer.doLayout(); singleViewContainer.repaint(); } else { DataSourceWindowTabbedPane.ViewContainer container = tabbedContainer.getContainer(view); if (container != null) { container.removeAll(); container.setCaption(new DataSourceCaption(view.getDataSource())); container.setView(view); container.doLayout(); container.repaint(); } else { insertView(view, index); } } PROCESSOR.post(new Runnable() { public void run() { try { view.viewAdded(); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed post-initialize view " + view, e); } // NOI18N } }); } void closeUnregisteredView(final DataSourceView view) { if (viewsCount == 1) { if (view != singleViewContainer.getView()) throw new RuntimeException("View " + view + " not present in DataSourceWindow " + this); // NOI18N remove(singleViewContainer); singleViewContainer.getCaption().finish(); singleViewContainer = null; } else { int viewIndex = indexOf(view); if (viewIndex == -1) throw new RuntimeException("View " + view + " not present in DataSourceWindow " + this); // NOI18N else tabbedContainer.removeView(viewIndex); if (viewsCount == 2) { DataSourceView remaining = tabbedContainer.getViews().get(0); singleViewContainer = new DataSourceWindowTabbedPane.ViewContainer(new DataSourceCaption(remaining.getDataSource()), remaining); remove(multiViewContainer); tabbedContainer.removeView(0); add(singleViewContainer, BorderLayout.CENTER); doLayout(); } } viewsCount--; if (viewsCount == 0 && isOpened()) close(); } public void removeAllViews() { List views = getViews(); for (DataSourceView view : views) removeView(view); } public List getViews() { if (viewsCount == 1) { return Collections.singletonList(singleViewContainer.getView()); } else { return tabbedContainer.getViews(); } } public boolean containsView(DataSourceView view) { return indexOf(view) != -1; } private int indexOf(DataSourceView view) { if (viewsCount == 1) { return view == singleViewContainer.getView() ? 0 : -1; } else { return tabbedContainer.indexOfView(view); } } protected final void componentActivated() { super.componentActivated(); if (singleViewContainer != null) singleViewContainer.requestFocusInWindow(); else if (getComponentCount() > 0) getComponent(0).requestFocusInWindow(); } public final boolean canClose() { for (DataSourceView view : getViews()) view.viewWillBeRemoved(); return true; } protected final void componentClosed() { dataSourceDescriptor.removePropertyChangeListener(this); removeAllViews(); DataSourceWindowManager.sharedInstance().unregisterClosedWindow(this); super.componentClosed(); } public void propertyChange(final PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if (DataSourceDescriptor.PROPERTY_NAME.equals(propertyName)) { SwingUtilities.invokeLater(new Runnable() { public void run() { setName((String)evt.getNewValue()); } }); } else if (DataSourceDescriptor.PROPERTY_ICON.equals(propertyName)) { SwingUtilities.invokeLater(new Runnable() { public void run() { setIcon((Image)evt.getNewValue()); } }); } } private void initAppearance() { dataSourceDescriptor = DataSourceDescriptorFactory.getDescriptor(dataSource); dataSourceDescriptor.addPropertyChangeListener(this); setName(dataSourceDescriptor.getName()); setIcon(dataSourceDescriptor.getIcon()); } private void initComponents() { setLayout(new BorderLayout()); // tabbedContainer tabbedContainer = new DataSourceWindowTabbedPane() { @Override protected void closeView(DataSourceWindowTabbedPane.ViewContainer view) { DataSourceWindow.this.removeView(tabbedContainer.getView(view)); } }; // multiViewContainer multiViewContainer = new JPanel(new BorderLayout()); if (UISupport.isAquaLookAndFeel()) { multiViewContainer.setOpaque(true); multiViewContainer.setBackground(UISupport.getDefaultBackground()); } multiViewContainer.add(tabbedContainer, BorderLayout.CENTER); add(multiViewContainer, BorderLayout.CENTER); } private void setAlert(DataSourceView view, Alert alert) { int viewIndex = tabbedContainer.indexOfView(view); tabbedContainer.setViewBackground(viewIndex,getAlertColor(alert)); if (alert != Alert.OK) { requestAttention(false); } else if (getApplicationAlert(alert) == Alert.OK) { cancelRequestAttention(); } } private Color getAlertColor(final Alert alert) { Color color = null; switch (alert) { case ERROR: color = Color.RED; break; case WARNING: color = Color.YELLOW; break; case OK: color = null; break; } return color; } private Alert getApplicationAlert(Alert alert) { if (alert == Alert.ERROR) { return alert; } for (DataSourceView view : getViews()) { Alert a = view.getAlert(); if (a == Alert.ERROR) { return a; } if (a == Alert.WARNING) { alert = a; } } return alert; } private DataSourceWindowTabbedPane tabbedContainer; public int getPersistenceType() { return TopComponent.PERSISTENCE_NEVER; } protected String preferredID() { return getClass().getName(); } private class AlertListener implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent evt) { if (DataSourceView.ALERT_PROP.equals(evt.getPropertyName())) { setAlert((DataSourceView) evt.getSource(), (Alert) evt.getNewValue()); } } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceViewPluginProvider.java0000644000175000017500000001124013767155557031172 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.snapshot.Snapshot; import java.util.HashMap; import java.util.Map; /** * Provider of DataSourceViewPlugin for a DataSource. * * @author Jiri Sedlacek */ public abstract class DataSourceViewPluginProvider { private final Map pluginsCache = new HashMap(); /** * Returns true if the plugin provider provides a plugin for the DataSource. * * @param dataSource DataSource for which to provide the plugin. * @return true if the plugin provider provides a plugin for the DataSource, false otherwise. */ protected abstract boolean supportsPluginFor(X dataSource); /** * Returns DataSourceViewPlugin instance for the DataSource. * * @param dataSource DataSource for which to create the plugin. * @return DataSourceViewPlugin instance for the DataSource. */ protected abstract DataSourceViewPlugin createPlugin(X dataSource); /** * Returns true if the plugin provider supports saving DataSourceViewPlugin for the DataSource into * the Snapshot type. * * @param dataSource DataSource for which to save the plugin. * @param snapshotClass snapshot type into which to save the plugin. * @return true if the plugin provider supports saving DataSourceViewPlugin for the DataSource, false otherwise. */ protected boolean supportsSavePluginFor(X dataSource, Class snapshotClass) { return false; }; /** * Saves DataSourceViewPlugin for the DataSource into the Snapshot. * * @param dataSource DataSource for which to save the plugin. * @param snapshot Snapshot into which to save the plugin. */ protected void savePlugin(X dataSource, Snapshot snapshot) {}; /** * Returns DataSourceViewPlugin for the DataSource if already created (cached). * * @param dataSource DataSource of the plugin. * @return DataSourceViewPlugin for the DataSource if already created (cached), null otherwise. */ protected final DataSourceViewPlugin getCachedPlugin(X dataSource) { synchronized(pluginsCache) { return pluginsCache.get(dataSource); } } void pluginWillBeAdded(DataSourceViewPlugin plugin) { } void pluginAdded(DataSourceViewPlugin plugin) { } void pluginRemoved(DataSourceViewPlugin plugin) { synchronized(pluginsCache) { pluginsCache.remove((X)plugin.getDataSource()); } } /** * Returns DataSourceViewPlugin for the DataSource. Tries to resolve already * created plugin from cache, creates new DataSourceViewPlugin instance using * the createPlugin(DataSource) method if needed. * * @param dataSource * @return DataSourceViewPlugin for the DataSource. */ protected final DataSourceViewPlugin getPlugin(X dataSource) { synchronized(pluginsCache) { DataSourceViewPlugin plugin = getCachedPlugin(dataSource); if (plugin == null) { plugin = createPlugin(dataSource); if (plugin == null) throw new NullPointerException("DataSourceViewPluginProvider provides null plugin: " + this); // NOI18N plugin.setController(this); pluginsCache.put(dataSource, plugin); } return plugin; } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceViewProvider.java0000644000175000017500000001142313767155557030016 0ustar apoapo/* * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.snapshot.Snapshot; import org.graalvm.visualvm.core.ui.components.DataViewComponent; import java.util.HashMap; import java.util.Map; /** * Provider of DataSourceView for a DataSource. * * @author Jiri Sedlacek */ public abstract class DataSourceViewProvider { private final Map viewsCache = new HashMap(); /** * Returns true if the view provider provides a view for the DataSource. * * @param dataSource DataSource for which to provide the view. * @return true if the view provider provides a view for the DataSource, false otherwise. */ protected abstract boolean supportsViewFor(X dataSource); /** * Returns DataSourceView instance for the DataSource. * * @param dataSource DataSource for which to create the view. * @return DataSourceView instance for the DataSource. */ protected abstract DataSourceView createView(X dataSource); /** * Returns true if the view provider supports saving DataSourceView for the DataSource into * the Snapshot type. * * @param dataSource DataSource for which to save the view. * @param snapshotClass snapshot type into which to save the view. * @return true if the view provider supports saving DataSourceView for the DataSource, false otherwise. */ protected boolean supportsSaveViewFor(X dataSource, Class snapshotClass) { return false; }; /** * Saves DataSourceView for the DataSource into the Snapshot. * * @param dataSource DataSource for which to save the view. * @param snapshot Snapshot into which to save the view. */ protected void saveView(X dataSource, Snapshot snapshot) {}; /** * Returns DataSourceView for the DataSource if already created (cached). * * @param dataSource DataSource of the plugin. * @return DataSourceView for the DataSource if already created (cached), null otherwise. */ protected final DataSourceView getCachedView(X dataSource) { synchronized(viewsCache) { return viewsCache.get(dataSource); } } /** * Returns DataSourceView for the DataSource. Tries to resolve already * created view from cache, creates new DataSourceView instance using * the createView(DataSource) method if needed. * * @param dataSource * @return DataSourceView for the DataSource. */ protected final DataSourceView getView(X dataSource) { synchronized(viewsCache) { DataSourceView view = getCachedView(dataSource); if (view == null) { view = createView(dataSource); if (view == null) throw new NullPointerException("DataSourceViewProvider provides null view: " + this); // NOI18N view.setController(this); viewsCache.put(dataSource, view); } return view; } } void viewSaveView(X dataSource, Snapshot snapshot) { saveView(dataSource, snapshot); } void processCreatedComponent(DataSourceView view, DataViewComponent component) { } void viewWillBeAdded(DataSourceView view) { } void viewAdded(DataSourceView view) { } void viewWillBeRemoved(DataSourceView view) { } void viewRemoved(DataSourceView view) { synchronized(viewsCache) { viewsCache.remove((X)view.getDataSource()); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/0000755000175000017500000000000013767155557024212 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/MultiDataSourceAction.java0000644000175000017500000000621413767155557031263 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.uisupport.UISupport; import java.awt.event.ActionEvent; import java.util.Set; /** * Abstract DataSourceAction which can be used as a basis for any action available (enabled) just for one or more selected DataSources in Applications window.. * * @author Jiri Sedlacek */ public abstract class MultiDataSourceAction extends DataSourceAction { /** * Creates new instance of MultiDataSourceAction available for defined DataSource type. * * @param scope DataSource type for the action. */ public MultiDataSourceAction(Class scope) { super(scope); } public final void actionPerformed(ActionEvent e) { if (isEnabled()) { actionPerformed(ActionUtils.getSelectedDataSources(getScope()), e); } else { notifyCannotPerform(); } } /** * Performs the action for the DataSources. * * @param dataSources Set of DataSources for which to perform the action. * @param actionEvent ActionEvent for the action. */ protected abstract void actionPerformed(Set dataSources, ActionEvent actionEvent); /** * Returns true if the action is available (enabled) for the DataSources, false otherwise. * * @param dataSources Set of DataSources for the action. * @return true if the action is available (enabled) for the DataSources, false otherwise. */ protected abstract boolean isEnabled(Set dataSources); protected void updateState(Set selectedDataSources) { final boolean isEnabled = selectedDataSources.isEmpty() ? false : isEnabled(selectedDataSources); UISupport.runInEventDispatchThreadAndWait(new Runnable() { public void run() { setEnabled(isEnabled); } }); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/RenameConfigurator.java0000644000175000017500000001216213767155557030651 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasource.descriptor.*; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.ui.components.Spacer; import java.awt.Dialog; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek * */ class RenameConfigurator extends JPanel { public static RenameConfigurator defineName(DataSource dataSource) { RenameConfigurator hc = getDefault(); hc.setupDefineName(dataSource); final DialogDescriptor dd = new DialogDescriptor(hc, NbBundle.getMessage(RenameConfigurator.class, "LBL_Rename"), true, new Object[] { // NOI18N hc.okButton, DialogDescriptor.CANCEL_OPTION }, hc.okButton, 0, null, null); final Dialog d = DialogDisplayer.getDefault().createDialog(dd); d.pack(); d.setVisible(true); if (dd.getValue() == hc.okButton) return hc; else return null; } public String getDisplayName() { return nameField.getText().trim(); } private static RenameConfigurator defaultInstance; private RenameConfigurator() { initComponents(); update(); } private static RenameConfigurator getDefault() { if (defaultInstance == null) defaultInstance = new RenameConfigurator(); return defaultInstance; } private void setupDefineName(DataSource dataSource) { nameField.setText(DataSourceDescriptorFactory.getDescriptor(dataSource).getName()); nameField.selectAll(); } private void update() { SwingUtilities.invokeLater(new Runnable() { public void run() { okButton.setEnabled(getDisplayName().length() > 0); } }); } private void initComponents() { setLayout(new GridBagLayout()); GridBagConstraints constraints; // nameLabel nameLabel = new JLabel(NbBundle.getMessage(RenameConfigurator.class, "LBL_New_Name")); // NOI18N constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(15, 10, 0, 0); add(nameLabel, constraints); // coreDumpFileField nameField = new JTextField(); nameField.setPreferredSize(new Dimension(220, nameField.getPreferredSize().height)); nameField.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { update(); } public void removeUpdate(DocumentEvent e) { update(); } public void changedUpdate(DocumentEvent e) { update(); } }); constraints = new GridBagConstraints(); constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1; constraints.gridwidth = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(15, 5, 0, 10); add(nameField, constraints); // spacer constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weighty = 1; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(0, 0, 15, 0); add(Spacer.create(), constraints); // okButton okButton = new JButton(NbBundle.getMessage(RenameConfigurator.class, "LBL_OK")); // NOI18N } private JLabel nameLabel; private JTextField nameField; private JButton okButton; } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/LoadSnapshotAction.java0000644000175000017500000001732113767155557030616 0ustar apoapo/* * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.snapshot.RegisteredSnapshotCategories; import org.graalvm.visualvm.core.snapshot.SnapshotCategoriesListener; import org.graalvm.visualvm.core.snapshot.SnapshotCategory; import org.graalvm.visualvm.uisupport.UISupport; import java.awt.Image; import java.awt.event.ActionEvent; import java.io.File; import java.util.ArrayList; import java.util.List; import javax.swing.AbstractAction; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import javax.swing.plaf.basic.BasicFileChooserUI; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.windows.WindowManager; class LoadSnapshotAction extends AbstractAction { private static final String ICON_PATH = "org/graalvm/visualvm/core/ui/resources/loadSnapshot.png"; // NOI18N private static final Image ICON = ImageUtilities.loadImage(ICON_PATH); private String lastFile = null; private String lastFilter = null; private static LoadSnapshotAction instance; public static synchronized LoadSnapshotAction instance() { if (instance == null) { instance = new LoadSnapshotAction(); instance.updateEnabled(true); RegisteredSnapshotCategories.sharedInstance().addCategoriesListener(new SnapshotCategoriesListener() { public void categoryRegistered(SnapshotCategory category) { instance.updateEnabled(false); } public void categoryUnregistered(SnapshotCategory category) { instance.updateEnabled(false); } }); } return instance; } public void actionPerformed(ActionEvent e) { List categories = RegisteredSnapshotCategories.sharedInstance().getOpenSnapshotCategories(); if (categories.isEmpty()) return; // TODO: should display a notification dialog final List fileFilters = new ArrayList(); for (SnapshotCategory category : categories) fileFilters.add(category.getFileFilter()); JFileChooser chooser = new JFileChooser() { public void setSelectedFile(File file) { super.setSelectedFile(file); // safety check if (!(getUI() instanceof BasicFileChooserUI)) { return; } // grab the ui and set the filename BasicFileChooserUI ui = (BasicFileChooserUI) getUI(); ui.setFileName(file == null ? "" : file.getName()); // NOI18N } }; chooser.setDialogTitle(NbBundle.getMessage(LoadSnapshotAction.class, "LBL_Load")); // NOI18N chooser.setAcceptAllFileFilterUsed(false); FileFilter allFilesFilter = new FileFilter() { @Override public boolean accept(File f) { for (FileFilter ff : fileFilters) if (ff.accept(f)) return true; return false; } @Override public String getDescription() { return NbBundle.getMessage(LoadSnapshotAction.class, "LBL_All_Snapshots"); // NOI18N } }; chooser.addChoosableFileFilter(allFilesFilter); int filterIndex = -1; for (int i = 0; i < fileFilters.size(); i++) { FileFilter fileFilter = fileFilters.get(i); chooser.addChoosableFileFilter(fileFilter); if (fileFilter.getDescription().equals(lastFilter)) filterIndex = i; } if (lastFile != null) chooser.setSelectedFile(new File(lastFile)); chooser.setFileFilter(filterIndex == -1 ? allFilesFilter : fileFilters.get(filterIndex)); if (chooser.showOpenDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) { File selectedFile = chooser.getSelectedFile(); if (selectedFile == null || !selectedFile.exists()) { DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message( NbBundle.getMessage(LoadSnapshotAction.class, "MSG_Selected_file_does_not_exist"), // NOI18N NotifyDescriptor.ERROR_MESSAGE)); } else { FileFilter fileFilter = chooser.getFileFilter(); if (fileFilter == allFilesFilter) { for (FileFilter ff : fileFilters) if (ff.accept(selectedFile)) { lastFile = selectedFile.getAbsolutePath(); lastFilter = null; categories.get(fileFilters.indexOf(ff)).openSnapshot(selectedFile); LoadRecentSnapshot.instance().addFile(selectedFile); return; } } else if (fileFilter.accept(selectedFile)) { lastFile = selectedFile.getAbsolutePath(); lastFilter = fileFilter.getDescription(); categories.get(fileFilters.indexOf(fileFilter)).openSnapshot(selectedFile); LoadRecentSnapshot.instance().addFile(selectedFile); return; } DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message( NbBundle.getMessage(LoadSnapshotAction.class, "MSG_Selected_file_does_not_match_snapshot_type"), // NOI18N NotifyDescriptor.ERROR_MESSAGE)); } } } private void updateEnabled(boolean lazily) { final boolean isEnabled = !RegisteredSnapshotCategories.sharedInstance().getOpenSnapshotCategories().isEmpty(); Runnable updater = new Runnable() { public void run() { setEnabled(isEnabled); } }; if (lazily) UISupport.runInEventDispatchThread(updater); else UISupport.runInEventDispatchThreadAndWait(updater); } private LoadSnapshotAction() { putValue(NAME, NbBundle.getMessage(LoadSnapshotAction.class, "LBL_Load1")); // NOI18N putValue(SHORT_DESCRIPTION, NbBundle.getMessage(LoadSnapshotAction.class, "LBL_Load_Snapshot")); // NOI18N putValue(SMALL_ICON, new ImageIcon(ICON)); putValue("iconBase", ICON_PATH); // NOI18N } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/LoadRecentSnapshot.java0000644000175000017500000002037513767155557030624 0ustar apoapo/* * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.snapshot.RegisteredSnapshotCategories; import org.graalvm.visualvm.core.snapshot.SnapshotCategory; import java.awt.event.ActionEvent; import java.io.File; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.prefs.Preferences; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; import org.graalvm.visualvm.core.VisualVM; import org.graalvm.visualvm.lib.profiler.api.ProfilerDialogs; import org.openide.awt.Mnemonics; import org.openide.awt.StatusDisplayer; import org.openide.util.NbBundle; import org.openide.util.NbPreferences; import org.openide.util.actions.Presenter; /** * Support for reopening already opened snapshots. * * @author Jiri Sedlacek */ class LoadRecentSnapshot implements Presenter.Menu { private static final String PROP_LOAD_RECENT = "LoadRecentSnapshot.item."; // NOI18N private static final int MAX_RECENT_ITEMS = 9; private static LoadRecentSnapshot INSTANCE; private final Preferences prefs; private final List files; private JMenu menu; public static synchronized LoadRecentSnapshot instance() { if (INSTANCE == null) INSTANCE = new LoadRecentSnapshot(); return INSTANCE; } void setupMenu() { assert SwingUtilities.isEventDispatchThread(); menu.removeAll(); if (files.isEmpty()) { menu.add(new JMenuItem(NbBundle.getMessage(LoadRecentSnapshot.class, "LoadRecentSnapshot_NoRecentSnapshots")) {{ setEnabled(false); }}); // NOI18N } else { int i = 0; for (String file : files) menu.add(new RecentFileItem(file, ++i)); menu.addSeparator(); menu.add(new ClearRecentItem()); } } @Override public JMenuItem getMenuPresenter() { if (menu == null) { menu = new JMenu(); Mnemonics.setLocalizedText(menu, NbBundle.getMessage(LoadRecentSnapshot.class, "LoadRecentSnapshot_LoadRecentItem")); // NOI18N } setupMenu(); return menu; } void addFile(File file) { String path = file.getAbsolutePath(); if (files.contains(path)) { files.remove(path); files.add(0, path); } else { if (files.size() == MAX_RECENT_ITEMS) files.remove(MAX_RECENT_ITEMS - 1); files.add(0, path); } saveFiles(prefs, files); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { setupMenu(); } }); } private static List loadFiles(Preferences p) { List f = new ArrayList(MAX_RECENT_ITEMS); int i = 0; String s = p.get(PROP_LOAD_RECENT + i, null); while (s != null && i < MAX_RECENT_ITEMS) { f.add(s); s = p.get(PROP_LOAD_RECENT + ++i, null); } return f; } private static void saveFiles(Preferences p, List f) { int i = 0; while (p.get(PROP_LOAD_RECENT + i, null) != null) p.remove(PROP_LOAD_RECENT + i++); i = 0; for (String s : f) p.put(PROP_LOAD_RECENT + i++, s); } private LoadRecentSnapshot() { prefs = NbPreferences.forModule(LoadRecentSnapshot.class); files = loadFiles(prefs); } private class RecentFileItem extends JMenuItem { private final String f; private final File file; RecentFileItem(String f, int idx) { this.f = f; file = new File(f); Mnemonics.setLocalizedText(this, "&" + idx + ". " + file.getName()); // NOI18N } @Override protected void fireStateChanged() { boolean active = isSelected() || isArmed(); StatusDisplayer.getDefault().setStatusText(active ? file.getAbsolutePath() : null); super.fireStateChanged(); } @Override protected void fireActionPerformed(ActionEvent e) { VisualVM.getInstance().runTask(new Runnable() { public void run() { if (file.exists()) { List categories = RegisteredSnapshotCategories.sharedInstance().getOpenSnapshotCategories(); List fileFilters = new ArrayList(); for (SnapshotCategory category : categories) fileFilters.add(category.getFileFilter()); for (FileFilter ff : fileFilters) if (ff.accept(file)) { categories.get(fileFilters.indexOf(ff)).openSnapshot(file); SwingUtilities.invokeLater(new Runnable() { public void run() { files.remove(f); files.add(0, f); saveFiles(prefs, files); setupMenu(); } }); return; } SwingUtilities.invokeLater(new Runnable() { public void run() { // NOTE: this happens when the appropriate SnapshotCategory is not registered // should the snapshot be kept in the list? files.remove(f); saveFiles(prefs, files); setupMenu(); ProfilerDialogs.displayError(MessageFormat.format(NbBundle.getMessage(LoadRecentSnapshot.class, "LoadRecentSnapshot_CannotLoadMsg"), file.getName())); } }); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { files.remove(f); saveFiles(prefs, files); setupMenu(); ProfilerDialogs.displayError(MessageFormat.format(NbBundle.getMessage(LoadRecentSnapshot.class, "LoadRecentSnapshot_NotAvailableMsg"), file.getName())); } }); } } }); } } private class ClearRecentItem extends JMenuItem { ClearRecentItem() { Mnemonics.setLocalizedText(this, NbBundle.getMessage(LoadRecentSnapshot.class, "LoadRecentSnapshot_ClearRecentSnapshots")); // NOI18N } @Override protected void fireActionPerformed(ActionEvent e) { files.clear(); saveFiles(prefs, files); setupMenu(); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/SaveSnapshotAsAction.java0000644000175000017500000000516313767155557031122 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.snapshot.Snapshot; import java.awt.Image; import java.awt.event.ActionEvent; import javax.swing.ImageIcon; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class SaveSnapshotAsAction extends SingleDataSourceAction { private static final String ICON_PATH = "org/graalvm/visualvm/core/ui/resources/saveSnapshot.png"; // NOI18N private static final Image ICON = ImageUtilities.loadImage(ICON_PATH); private static SaveSnapshotAsAction instance; public static synchronized SaveSnapshotAsAction instance() { if (instance == null) instance = new SaveSnapshotAsAction(); return instance; } protected void actionPerformed(Snapshot snapshot, ActionEvent actionEvent) { snapshot.saveAs(); } protected boolean isEnabled(Snapshot snapshot) { return snapshot.supportsSaveAs(); } private SaveSnapshotAsAction() { super(Snapshot.class); putValue(NAME, NbBundle.getMessage(SaveSnapshotAsAction.class, "LBL_Save_As")); // NOI18N putValue(SHORT_DESCRIPTION, NbBundle.getMessage(SaveSnapshotAsAction.class, "LBL_Save_Snapshot_As")); // NOI18N putValue(SMALL_ICON, new ImageIcon(ICON)); putValue("iconBase", ICON_PATH); // NOI18N } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/SingleDataSourceAction.java0000644000175000017500000000623213767155557031412 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.uisupport.UISupport; import java.awt.event.ActionEvent; import java.util.Set; /** * Abstract DataSourceAction which can be used as a basis for any action available (enabled) just for single selected DataSource in Applications window.. * * @author Jiri Sedlacek */ public abstract class SingleDataSourceAction extends DataSourceAction { /** * Creates new instance of SingleDataSourceAction available for defined DataSource type. * * @param scope DataSource type for the action. */ public SingleDataSourceAction(Class scope) { super(scope); } public final void actionPerformed(ActionEvent e) { if (isEnabled()) { actionPerformed(ActionUtils.getSelectedDataSource(getScope()), e); } else { notifyCannotPerform(); } } /** * Performs the action for the DataSource. * * @param dataSource DataSource for which to perform the action. * @param actionEvent ActionEvent for the action. */ protected abstract void actionPerformed(X dataSource, ActionEvent actionEvent); /** * Returns true if the action is available (enabled) for the DataSource, false otherwise. * * @param dataSource DataSource for the action. * @return true if the action is available (enabled) for the DataSource, false otherwise. */ protected abstract boolean isEnabled(X dataSource); protected void updateState(Set selectedDataSources) { X selectedDataSource = selectedDataSources.size() == 1 ? selectedDataSources.iterator().next() : null; final boolean isEnabled = selectedDataSource != null ? isEnabled(selectedDataSource) : false; UISupport.runInEventDispatchThreadAndWait(new Runnable() { public void run() { setEnabled(isEnabled); } }); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/DataSourceAction.java0000644000175000017500000001047713767155557030256 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Utils; import org.graalvm.visualvm.core.explorer.ExplorerSelectionListener; import org.graalvm.visualvm.core.explorer.ExplorerSupport; import java.beans.PropertyChangeListener; import java.util.Collections; import java.util.Set; import javax.swing.AbstractAction; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.util.NbBundle; /** * Abstract Action which can be used as a basis for any DataSource-aware action. * * @author Jiri Sedlacek */ public abstract class DataSourceAction extends AbstractAction { private final Class scope; private boolean initialized = false; /** * Creates new instance of DataSourceAction available for defined DataSource type. * * @param scope DataSource type for the action. */ public DataSourceAction(Class scope) { this.scope = scope; } /** * Updates enabled state based on currently selected DataSources in Applications window. * * @param selectedDataSources currently selected DataSources in Applications window. */ protected abstract void updateState(Set selectedDataSources); /** * Displays a dialog that the action cannot be invoked in current context. */ protected void notifyCannotPerform() { DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message( NbBundle.getMessage(DataSourceAction.class, "MSG_Cannot_perform_action_in_this_context"), // NOI18N NotifyDescriptor.ERROR_MESSAGE)); } /** * Initializes the action. By default registers selection listener which invokes updateState(Set) on selection change. */ protected void initialize() { ExplorerSupport.sharedInstance().addSelectionListener(new ExplorerSelectionListener() { public void selectionChanged(Set selected) { Set selectedFiltered = Utils.getFilteredSet(selected, getScope()); if (selectedFiltered.size() == selected.size()) DataSourceAction.this.updateState(selectedFiltered); else updateState(Collections.EMPTY_SET); } }); updateState(ActionUtils.getSelectedDataSources(getScope())); } public final Object getValue(String key) { doInitialize(); return super.getValue(key); } public final boolean isEnabled() { doInitialize(); return super.isEnabled(); } public final void addPropertyChangeListener(PropertyChangeListener listener) { doInitialize(); super.addPropertyChangeListener(listener); } /** * Returns DataSource type for this action. * * @return DataSource type for this action. */ public final Class getScope() { return scope; } private synchronized void doInitialize() { if (initialized) return; initialized = true; initialize(); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/OpenDataSourceAction.java0000644000175000017500000000534513767155557031076 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Utils; import org.graalvm.visualvm.core.ui.DataSourceWindowManager; import java.awt.event.ActionEvent; import java.util.List; import java.util.Set; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class OpenDataSourceAction extends MultiDataSourceAction { private static OpenDataSourceAction instance; public static synchronized OpenDataSourceAction instance() { if (instance == null) instance = new OpenDataSourceAction(); return instance; } protected void actionPerformed(Set dataSources, ActionEvent actionEvent) { List sortedDataSources = Utils.getSortedDataSources(dataSources); for (DataSource dataSource : sortedDataSources) DataSourceWindowManager.sharedInstance().openDataSource(dataSource); } protected boolean isEnabled(Set dataSources) { for (DataSource dataSource : dataSources) if (!DataSourceWindowManager.sharedInstance().canOpenDataSource(dataSource)) return false; return true; } private OpenDataSourceAction() { super(DataSource.class); putValue(NAME, NbBundle.getMessage(OpenDataSourceAction.class, "LBL_Open")); // NOI18N putValue(SHORT_DESCRIPTION, NbBundle.getMessage(OpenDataSourceAction.class, "DESCR_Open")); // NOI18N } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/DeleteSnapshotAction.java0000644000175000017500000000547013767155557031143 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasupport.Utils; import org.graalvm.visualvm.core.snapshot.Snapshot; import java.awt.event.ActionEvent; import java.util.Set; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class DeleteSnapshotAction extends MultiDataSourceAction { // private static final Image ICON_16 = Utilities.loadImage("org/graalvm/visualvm/core/ui/resources/saveSnapshot.png"); // private static final Image ICON_24 = Utilities.loadImage("org/graalvm/visualvm/core/ui/resources/saveSnapshot24.png"); private static DeleteSnapshotAction instance; public static DeleteSnapshotAction instance() { if (instance == null) instance = new DeleteSnapshotAction(); return instance; } protected void actionPerformed(Set snapshots, ActionEvent actionEvent) { for (Snapshot snapshot : snapshots) snapshot.delete(); } protected boolean isEnabled(Set snapshots) { for (Snapshot snapshot : snapshots) if (!snapshot.supportsDelete()) return false; return Utils.areDataSourcesIndependent(snapshots); } private DeleteSnapshotAction() { super(Snapshot.class); putValue(NAME, NbBundle.getMessage(DeleteSnapshotAction.class, "LBL_Delete")); // NOI18N putValue(SHORT_DESCRIPTION, NbBundle.getMessage(DeleteSnapshotAction.class, "LBL_Delete_Snapshot")); // NOI18N // putValue(SMALL_ICON, new ImageIcon(ICON_16)); // putValue("iconBase", new ImageIcon(ICON_24)); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/VisualVMDropHandler.java0000644000175000017500000002222313767155557030707 0ustar apoapo/* * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import java.awt.Component; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.InvalidDnDOperationException; import java.io.File; import java.io.IOException; import java.net.URI; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import org.graalvm.visualvm.core.snapshot.RegisteredSnapshotCategories; import org.graalvm.visualvm.core.snapshot.SnapshotCategory; import org.openide.DialogDisplayer; import org.openide.ErrorManager; import org.openide.NotifyDescriptor; import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; import org.openide.windows.ExternalDropHandler; import org.openide.windows.TopComponent; /** * * @author S. Aubrecht * @author Tomas Hurka */ @ServiceProvider(service = ExternalDropHandler.class, position = 1000) public class VisualVMDropHandler extends ExternalDropHandler { private static final Logger LOG = Logger.getLogger(VisualVMDropHandler.class.getName()); @Override public boolean canDrop(DropTargetDragEvent e) { return canDrop(e.getCurrentDataFlavors()); } @Override public boolean canDrop(DropTargetDropEvent e) { return canDrop(e.getCurrentDataFlavors()); } private boolean canDrop(DataFlavor[] flavors) { for (DataFlavor df : flavors) { if (DataFlavor.javaFileListFlavor.equals(df) || getUriListDataFlavor().equals(df)) { return true; } } return false; } @Override public boolean handleDrop(DropTargetDropEvent e) { Transferable t = e.getTransferable(); if (t == null) { return false; } List fileList = getFileList(t); if ((fileList == null) || fileList.isEmpty()) { return false; } //#158473: Activate target TC to inform winsys in which mode new editor //component should be opened. It assumes that openFile opens new editor component //in some editor mode. If there would be problem with activating another TC first //then another way how to infrom winsys must be used. Component c = e.getDropTargetContext().getComponent(); while (c != null) { if (c instanceof TopComponent) { ((TopComponent) c).requestActive(); break; } c = c.getParent(); } Object errMsg = null; if (fileList.size() == 1) { errMsg = openFile(fileList.get(0)); } else { boolean hasSomeSuccess = false; List fileErrs = null; for (File file : fileList) { String fileErr = openFile(file); if (fileErr == null) { hasSomeSuccess = true; } else { if (fileErrs == null) { fileErrs = new ArrayList<>(); } fileErrs.add(fileErr); } } if (fileErrs != null) { //some file could not be opened String mainMsgKey; if (hasSomeSuccess) { mainMsgKey = "MSG_could_not_open_some_files"; //NOI18N } else { mainMsgKey = "MSG_could_not_open_any_file"; //NOI18N } String mainMsg = NbBundle.getMessage(VisualVMDropHandler.class, mainMsgKey); JComponent msgPanel = new JPanel(); msgPanel.setLayout(new BoxLayout(msgPanel, BoxLayout.PAGE_AXIS)); msgPanel.add(new JLabel(mainMsg)); msgPanel.add(Box.createVerticalStrut(12)); for (String fileErr : fileErrs) { msgPanel.add(new JLabel(fileErr)); } errMsg = msgPanel; } } if (errMsg != null) { showWarningMessageFileNotOpened(errMsg); return false; } return true; } private static void showWarningMessageFileNotOpened(Object errMsg) { DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message( errMsg, NotifyDescriptor.WARNING_MESSAGE)); } private List getFileList(Transferable t) { try { if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { //windows & mac try { return (List) t.getTransferData(DataFlavor.javaFileListFlavor); } catch (InvalidDnDOperationException ex) { // #212390 LOG.log(Level.FINE, null, ex); } } if (t.isDataFlavorSupported(getUriListDataFlavor())) { //linux String uriList = (String) t.getTransferData(getUriListDataFlavor()); return textURIListToFileList(uriList); } } catch (UnsupportedFlavorException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } catch (IOException ex) { // Ignore. Can be just "Owner timed out" from sun.awt.X11.XSelection.getData. LOG.log(Level.FINE, null, ex); } return null; } /** * Opens the given file. * * If the file doesn't open in a reasonable time (2 seconds), let's assume * it will open successfully later (return null). * * @param file file to be opened * @return {@code null} if the file was successfully opened; or a localized * error message in case of failure */ private String openFile(final File file) { if (file.exists() && file.canRead() && file.isFile()) { List categories = RegisteredSnapshotCategories.sharedInstance().getOpenSnapshotCategories(); for (SnapshotCategory category : categories) { if (category.getFileFilter().accept(file)) { category.openSnapshot(file); LoadRecentSnapshot.instance().addFile(file); return null; } } return MessageFormat.format(NbBundle.getMessage(VisualVMDropHandler.class, "LoadRecentSnapshot_CannotLoadMsg"), file.getName()); } return MessageFormat.format(NbBundle.getMessage(VisualVMDropHandler.class, "LoadRecentSnapshot_NotAvailableMsg"), file.getName()); } private static DataFlavor uriListDataFlavor; private DataFlavor getUriListDataFlavor() { if (null == uriListDataFlavor) { try { uriListDataFlavor = new DataFlavor("text/uri-list;class=java.lang.String"); } catch (ClassNotFoundException cnfE) { //cannot happen throw new AssertionError(cnfE); } } return uriListDataFlavor; } private List textURIListToFileList(String data) { List list = new ArrayList<>(); StringTokenizer st = new StringTokenizer(data,"\r\n\u0000"); while (st.hasMoreTokens()) { String s = st.nextToken(); if (s.startsWith("#")) { // the line is a comment (as per the RFC 2483) continue; } try { File file = new File(new URI(s)); list.add(file); } catch (java.net.URISyntaxException e) { // malformed URI } catch (IllegalArgumentException e) { // the URI is not a valid 'file:' URI } } return list; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/package-info.java0000644000175000017500000000245613767155557027410 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * APIs for UI actions in VisualVM. */ package org.graalvm.visualvm.core.ui.actions; visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/RemoveDataSourceAction.java0000644000175000017500000000620613767155557031427 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Utils; import java.awt.event.ActionEvent; import java.util.Set; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class RemoveDataSourceAction extends MultiDataSourceAction { private static RemoveDataSourceAction instance; public static synchronized RemoveDataSourceAction instance() { if (instance == null) instance = new RemoveDataSourceAction(); return instance; } protected void actionPerformed(Set dataSources, ActionEvent actionEvent) { for (DataSource dataSource : dataSources) if (checkRemove(dataSource)) dataSource.getOwner().getRepository().removeDataSource(dataSource); } protected boolean isEnabled(Set dataSources) { for (DataSource dataSource : dataSources) if (!dataSource.supportsUserRemove()) return false; return Utils.areDataSourcesIndependent(dataSources); } private static boolean checkRemove(DataSource dataSource) { // Check if the DataSource can be removed if (!dataSource.checkRemove(dataSource)) return false; // Check if all repository DataSources can be removed Set repositoryDataSources = dataSource.getRepository().getDataSources(); for (DataSource repositoryDataSource : repositoryDataSources) if (!repositoryDataSource.checkRemove(dataSource)) return false; return true; } private RemoveDataSourceAction() { super(DataSource.class); putValue(NAME, NbBundle.getMessage(RemoveDataSourceAction.class, "LBL_Remove")); // NOI18N putValue(SHORT_DESCRIPTION, NbBundle.getMessage(RemoveDataSourceAction.class, "DESCR_Remove")); // NOI18N } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/Bundle.properties0000644000175000017500000000455313767155557027550 0ustar apoapo# # Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. MSG_Cannot_perform_action_in_this_context=Cannot perform action in this context LBL_Delete=&Delete LBL_Delete_Snapshot=Delete Snapshot LBL_Load=Load MSG_Selected_file_does_not_exist=Selected file does not exist. MSG_Selected_file_does_not_match_snapshot_type=Selected file does not match snapshot type. LBL_Load1=&Load... LBL_Load_Snapshot=Load Snapshot LBL_Open=&Open DESCR_Open=Open LBL_All_Snapshots=All Supported Files LBL_Remove=&Remove DESCR_Remove=Remove LBL_Rename=Rename LBL_New_Name=New Name: LBL_OK=OK LBL_Rename1=Re&name... LBL_Save_As=&Save As... LBL_Save_Snapshot_As=Save Snapshot As LoadRecentSnapshot_LoadRecentItem=Load &Recent LoadRecentSnapshot_NoRecentSnapshots=No Recent Snapshots LoadRecentSnapshot_ClearRecentSnapshots=&Clear Recent Snapshots LoadRecentSnapshot_CannotLoadMsg=Snapshot {0} cannot be loaded. LoadRecentSnapshot_NotAvailableMsg=Snapshot {0} is not available. # if no file dropped on the editor could be opened MSG_could_not_open_any_file=The files could not be opened for the following reasons: # if some of the files dropped on the editor could be opened, but some not MSG_could_not_open_some_files=Some of the files could not be opened for the following reasons: visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/ActionUtils.java0000644000175000017500000000755113767155557027323 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Utils; import org.graalvm.visualvm.core.explorer.ExplorerSupport; import java.util.Collections; import java.util.Set; /** * Utils class providing useful methods mostly for Actions implementation. * * @author Jiri Sedlacek */ public final class ActionUtils { /** * Returns selected DataSource is exactly one DataSource is selected in Applications window, null otherwise. * @return selected DataSource is exactly one DataSource is selected in Applications window, null otherwise. */ public static DataSource getSelectedDataSource() { Set selectedDataSources = getSelectedDataSources(); return (selectedDataSources.size() == 1 ? selectedDataSources.iterator().next() : null); } /** * Returns selected DataSource is exactly one DataSource of a certain type is selected in Applications window, null otherwise. * * @param any DataSource. * @param scope DataSource type. * @return selected DataSource is exactly one DataSource of a certain type is selected in Applications window, null otherwise. */ public static X getSelectedDataSource(Class scope) { Set selectedDataSources = getSelectedDataSources(scope); return (selectedDataSources.size() == 1 ? selectedDataSources.iterator().next() : null); } /** * Returns Set of selected DataSources in Applications window or empty Set for no selection. * * @return Set of selected DataSources in Applications window or empty Set for no selection. */ public static Set getSelectedDataSources() { Set selectedDataSources = ExplorerSupport.sharedInstance().getSelectedDataSources(); return selectedDataSources; } /** * Returns Set of selected DataSources of a certain type in Applications window or empty Set if no DataSource of this type is selected. * * @param any DataSource. * @param scope DataSource type. * @return Set of selected DataSources of a certain type in Applications window or empty Set if no DataSource of this type is selected. */ public static Set getSelectedDataSources(Class scope) { Set selectedDataSources = getSelectedDataSources(); Set filteredSelectedDataSources = Utils.getFilteredSet(selectedDataSources, scope); return selectedDataSources.size() == filteredSelectedDataSources.size() ? filteredSelectedDataSources : Collections.EMPTY_SET; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/actions/RenameDataSourceAction.java0000644000175000017500000000510613767155557031377 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.actions; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory; import java.awt.event.ActionEvent; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class RenameDataSourceAction extends SingleDataSourceAction { private static RenameDataSourceAction instance; public static synchronized RenameDataSourceAction instance() { if (instance == null) instance = new RenameDataSourceAction(); return instance; } protected void actionPerformed(DataSource dataSource, ActionEvent actionEvent) { RenameConfigurator configurator = RenameConfigurator.defineName(dataSource); if (configurator != null) DataSourceDescriptorFactory.getDescriptor(dataSource).setName(configurator.getDisplayName()); } protected boolean isEnabled(DataSource dataSource) { return DataSourceDescriptorFactory.getDescriptor(dataSource).supportsRename(); } private RenameDataSourceAction() { super(DataSource.class); putValue(NAME, NbBundle.getMessage(RenameDataSourceAction.class, "LBL_Rename1")); // NOI18N putValue(SHORT_DESCRIPTION, NbBundle.getMessage(RenameDataSourceAction.class, "LBL_Rename")); // NOI18N } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceViewsManager.java0000644000175000017500000001541413767155557027765 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Positionable; import org.graalvm.visualvm.core.snapshot.Snapshot; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * Class responsible for resolving DataSourceViews for DataSources. * * @author Jiri Sedlacek */ public final class DataSourceViewsManager { private static final String APP_OVERVIEW_CLASS_workaround = "org.graalvm.visualvm.application.views.overview.ApplicationOverviewViewProvider"; // NOI18N private static DataSourceViewsManager sharedInstance; // TODO: implement some better data structure for cheaper providers query private final Map> providers = Collections.synchronizedMap(new HashMap()); /** * Returns singleton instance of DataSourceViewsManager. * * @return singleton instance of DataSourceViewsManager. */ public static synchronized DataSourceViewsManager sharedInstance() { if (sharedInstance == null) sharedInstance = new DataSourceViewsManager(); return sharedInstance; } /** * Registers new DataSourceViewProvider for given DataSource scope. * * @param provider DataSourceViewProvider to be added, * @param scope scope of DataSource types for which the provider provides views. */ public void addViewProvider(DataSourceViewProvider provider, Class scope) { providers.put(provider, scope); } /** * Unregisters DataSourceViewProvider. * * @param provider DataSourceViewProvider to be removed. */ public void removeViewProvider(DataSourceViewProvider provider) { providers.remove(provider); } /** * Returns true if there's at least one DataSourceView for the DataSource which can * be saved into the Snapshot type. * * @param dataSource DataSource for which to save the views. * @param snapshotClass Snapshot type into which to save the views. * @return true if there's at least one DataSourceView for the DataSource which can * be saved into the Snapshot type, false otherwise. */ public boolean canSaveViewsFor(DataSource dataSource, Class snapshotClass) { Set compatibleProviders = getCompatibleProviders(dataSource); if (compatibleProviders.isEmpty()) return false; // Workaround for #109 to not block synchronous actions updating in EDT for (DataSourceViewProvider compatibleProvider : compatibleProviders) if (APP_OVERVIEW_CLASS_workaround.equals(compatibleProvider.getClass().getName())) return true; // -------------------------------------------------------------------- for (DataSourceViewProvider compatibleProvider : compatibleProviders) if (compatibleProvider.supportsViewFor(dataSource) && compatibleProvider.supportsSaveViewFor(dataSource, snapshotClass)) return true; return false; } /** * Saves views for the DataSource into the Snapshot. * * @param dataSource DataSource for which to save the views. * @param snapshot Snapshot into which to save the views. */ public void saveViewsFor(DataSource dataSource, Snapshot snapshot) { Set compatibleProviders = getCompatibleProviders(dataSource); for (DataSourceViewProvider compatibleProvider : compatibleProviders) if (compatibleProvider.supportsViewFor(dataSource) && compatibleProvider.supportsSaveViewFor(dataSource, snapshot.getClass())) compatibleProvider.viewSaveView(dataSource, snapshot); } boolean hasViewsFor(DataSource dataSource) { Set compatibleProviders = getCompatibleProviders(dataSource); if (compatibleProviders.isEmpty()) return false; // Workaround for #109 to not block synchronous actions updating in EDT for (DataSourceViewProvider compatibleProvider : compatibleProviders) if (APP_OVERVIEW_CLASS_workaround.equals(compatibleProvider.getClass().getName())) return true; // -------------------------------------------------------------------- for (DataSourceViewProvider compatibleProvider : compatibleProviders) if (compatibleProvider.supportsViewFor(dataSource)) return true; return false; } List getViews(DataSource dataSource) { List views = new ArrayList(); Set compatibleProviders = getCompatibleProviders(dataSource); for (DataSourceViewProvider compatibleProvider : compatibleProviders) if (compatibleProvider.supportsViewFor(dataSource)) views.add(compatibleProvider.getView(dataSource)); Collections.sort(views, Positionable.COMPARATOR); return views; } private Set getCompatibleProviders(DataSource dataSource) { Set compatibleProviders = new HashSet(); Set providersSet = providers.keySet(); for (DataSourceViewProvider provider : providersSet) if (providers.get(provider).isInstance(dataSource)) compatibleProviders.add(provider); return compatibleProviders; } private DataSourceViewsManager() { } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/0000755000175000017500000000000013767155557024737 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/DisplayArea.java0000644000175000017500000004074513767155557030012 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import org.graalvm.visualvm.core.datasupport.Positionable; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingUtilities; import org.openide.awt.CloseButtonFactory; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class DisplayArea extends JComponent { private boolean ignoresContentsHeight = true; DisplayArea() { initComponents(); setClosable(true); setVisible(false); // No tabs added yet } void setCaption(String caption) { this.caption = caption; if (presenter != null) presenter.setCaption(caption); } String getCaption() { return caption; } void setClosable(boolean closable) { optionsContainer.setClosable(closable); updatePresenter(); } boolean isClosable() { return optionsContainer.isClosable(); } void setIgnoresContentsHeight(boolean ignoresContentsHeight) { this.ignoresContentsHeight = ignoresContentsHeight; } boolean ignoresContentsHeight() { return ignoresContentsHeight; } Presenter getPresenter() { if (presenter == null) { presenter = createPresenter(); updatePresenter(); } return presenter; } void addTab(Tab tab) { final DisplayAreaSupport.TabButton tabButton = tabsContainer.addTab(tab); if (tabButton != null) { optionsContainer.addOptions(tab); updateTabbed(); if (tabsContainer.indexOfTab(tab) == 0) setSelectedTab(tab); final Tab tabF = tab; tabButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (tabButton.isEnabled() && SwingUtilities.isLeftMouseButton(e)) setSelectedTab(tabF); } }); tabButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setSelectedTab(tabF); } }); } if (tabsContainer.getTabsCount() > 0) setVisible(true); updatePresenter(); } void removeTab(Tab tab) { Tab toSelect = null; boolean wasSelected = getSelectedTab() == tab; if (wasSelected) { toSelect = tabsContainer.getPreviousTab(tab); if (toSelect == null) toSelect = tabsContainer.getNextTab(tab); } if (tabsContainer.removeTab(tab)) { optionsContainer.removeOptions(tab); if (wasSelected) { if (toSelect != null) setSelectedTab(toSelect); else viewContainer.setSelectedView(null); } updateTabbed(); } if (tabsContainer.getTabsCount() == 0) setVisible(false); updatePresenter(); } boolean containsTab(Tab tab) { return tabsContainer.containsTab(tab); } void setSelectedTab(Tab tab) { if (tabsContainer.getSelectedTab() == tab) return; tabsContainer.setSelectedTab(tab); optionsContainer.setSelectedOptions(tab); viewContainer.setSelectedView(tab.getView()); } Tab getSelectedTab() { return tabsContainer.getSelectedTab(); } public Dimension getPreferredSize() { if (ignoresContentsHeight()) return new Dimension(0, tabsContainer.getPreferredSize().height); else return super.getPreferredSize(); } public Dimension getMinimumSize() { if (ignoresContentsHeight()) return getPreferredSize(); else return super.getMinimumSize(); } private void updatePresenter() { if (presenter == null) return; presenter.setVisible(tabsContainer.getTabsCount() > 0 && isClosable()); } private void updateTabbed() { boolean tabbed = tabsContainer.getTabsCount() > 1; middleSpacer.updateTabbed(tabbed); optionsContainer.updateTabbed(tabbed); } private Presenter createPresenter() { final Presenter presenter = new Presenter(); presenter.setCaption(caption); presenter.setOpaque(false); final boolean[] internalChange = new boolean[1]; internalChange[0] = false; presenter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { internalChange[0] = true; setVisible(presenter.isSelected()); internalChange[0] = false; } }); addHierarchyListener(new HierarchyListener() { public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { boolean isShowing = isShowing(); presenter.setToolTipText(isShowing ? NbBundle.getMessage( DisplayArea.class, "ToolTip_HideSection", caption) : // NOI18N NbBundle.getMessage(DisplayArea.class, "ToolTip_ShowSection", caption)); // NOI18N if (!internalChange[0]) presenter.setSelected(isShowing); } } }); return presenter; } private void initComponents() { viewContainer = new ViewArea(); tabsContainer = new TabsContainer(); middleSpacer = new MiddleSpacer(); optionsContainer = new OptionsContainer(); JPanel captionArea = new JPanel(); captionArea.setLayout(new BorderLayout()); captionArea.setOpaque(false); captionArea.add(tabsContainer, BorderLayout.WEST); captionArea.add(middleSpacer, BorderLayout.CENTER); captionArea.add(optionsContainer, BorderLayout.EAST); setLayout(new BorderLayout()); add(captionArea, BorderLayout.NORTH); add(viewContainer, BorderLayout.CENTER); } private String caption = ""; // NOI18N private Presenter presenter; private ViewArea viewContainer; private TabsContainer tabsContainer; private MiddleSpacer middleSpacer; private OptionsContainer optionsContainer; static class Presenter extends JCheckBox { void setCaption(String caption) { setText(caption); } String getCaption() { return getText(); } void setDescription(String description) { setToolTipText(description); } String getDescription() { return getToolTipText(); } } static class Tab implements Positionable { private String name; private String description; private int preferredPosition; private JComponent view; private JComponent[] options; Tab(String name, JComponent view) { this(name, null, POSITION_AT_THE_END, view, null); } Tab(String name, String description, int preferredPosition, JComponent view, JComponent[] options) { setName(name); setDescription(description); setPreferredPosition(preferredPosition); setView(view); setOptions(options); } void setName(String name) { this.name = name; } String getName() { return name; } void setDescription(String description) { this.description = description; } String getDescription() { return description; } void setPreferredPosition(int preferredPosition) { this.preferredPosition = preferredPosition; } public int getPreferredPosition() { return preferredPosition; } void setView(JComponent view) { this.view = view; } JComponent getView() { return view; } void setOptions(JComponent[] options) { this.options = options != null ? options.clone() : null; } JComponent[] getOptions() { return options != null ? options.clone() : null; } } private static class TabsContainer extends JPanel { private List tabs = new ArrayList(); private Tab selectedTab; private TabsContainer() { setLayout(null); setOpaque(true); setBackground(DisplayAreaSupport.BACKGROUND_COLOR_NORMAL); } private DisplayAreaSupport.TabButton addTab(Tab tab) { if (tabs.contains(tab)) return null; if (getLayout() == null) setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); tabs.add(tab); Collections.sort(tabs, Positionable.COMPARATOR); DisplayAreaSupport.TabButton tabButton = new DisplayAreaSupport.TabButton(tab.getName(), tab.getDescription()); DisplayAreaSupport.TabButtonContainer tabButtonContainer = new DisplayAreaSupport.TabButtonContainer(tabButton); tabButtonContainer.setAlignmentY(JComponent.TOP_ALIGNMENT); add(tabButtonContainer, tabs.indexOf(tab)); updateTabButtons(); return tabButton; } private int indexOfTab(Tab tab) { return tabs.indexOf(tab); } private boolean removeTab(Tab tab) { int index = indexOfTab(tab); if (index != -1) { tabs.remove(index); remove(index); if (tab == selectedTab) selectedTab = null; updateTabButtons(); return true; } return false; } private boolean containsTab(Tab tab) { return tabs.contains(tab); } private void setSelectedTab(Tab tab) { selectedTab = tab; updateTabButtons(); } private Tab getSelectedTab() { return selectedTab; } private Tab getPreviousTab(Tab tab) { int index = tabs.indexOf(tab); return index > 0 ? tabs.get(--index) : null; } private Tab getNextTab(Tab tab) { int index = tabs.indexOf(tab); return index < tabs.size() - 1 ? tabs.get(++index) : null; } private int getTabsCount() { return tabs.size(); } private void updateTabButtons() { int tabIndex = tabs.indexOf(selectedTab); Component[] components = getComponents(); int componentsCount = components.length; for (int i = 0; i < componentsCount; i++) ((DisplayAreaSupport.TabButtonContainer)components[i]).updateTabButton(i, tabIndex, componentsCount); } } private static class MiddleSpacer extends JPanel { private MiddleSpacer() { setLayout(null); setOpaque(true); setBackground(DisplayAreaSupport.BACKGROUND_COLOR_NORMAL); } private void updateTabbed(boolean tabbed) { if (tabbed) setBorder(DisplayAreaSupport.TabbedCaptionBorder.get( DisplayAreaSupport.BORDER_COLOR_NORMAL, DisplayAreaSupport.COLOR_NONE, DisplayAreaSupport.BORDER_COLOR_HIGHLIGHT, DisplayAreaSupport.COLOR_NONE)); else setBorder(DisplayAreaSupport.TabbedCaptionBorder.get( DisplayAreaSupport.BORDER_COLOR_NORMAL, DisplayAreaSupport.COLOR_NONE, DisplayAreaSupport.BACKGROUND_COLOR_NORMAL, DisplayAreaSupport.COLOR_NONE)); } } private static class OptionsContainer extends JPanel { private JPanel contentsPanel; private JButton closeButton; private CardLayout layout = new CardLayout(0, 0); private Map tabsMapper = new HashMap(); private OptionsContainer() { initComponents(); } private void setClosable(boolean closable) { closeButton.setVisible(closable); } private boolean isClosable() { return closeButton.isVisible(); } private void addOptions(Tab tab) { JPanel optionsContainer = new JPanel(); optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.X_AXIS)); optionsContainer.setOpaque(false); JComponent[] options = tab.getOptions(); if (options != null) for (JComponent option : options) { option.setBorder(BorderFactory.createEmptyBorder(3, 5, 2, DisplayAreaSupport.TABBUTTON_MARGIN_RIGHT)); option.setAlignmentY(JComponent.CENTER_ALIGNMENT); optionsContainer.add(option); } tabsMapper.put(tab, optionsContainer); contentsPanel.add(optionsContainer, tab.getName()); } private void removeOptions(Tab tab) { JPanel optionsContainer = tabsMapper.remove(tab); if (optionsContainer != null) contentsPanel.remove(optionsContainer); } private void setSelectedOptions(Tab tab) { layout.show(contentsPanel, tab.getName()); } private void updateTabbed(boolean tabbed) { if (tabbed) setBorder(DisplayAreaSupport.TabbedCaptionBorder.get( DisplayAreaSupport.BORDER_COLOR_NORMAL, DisplayAreaSupport.COLOR_NONE, DisplayAreaSupport.BORDER_COLOR_HIGHLIGHT, DisplayAreaSupport.BORDER_COLOR_NORMAL)); else setBorder(DisplayAreaSupport.TabbedCaptionBorder.get( DisplayAreaSupport.BORDER_COLOR_NORMAL, DisplayAreaSupport.COLOR_NONE, DisplayAreaSupport.COLOR_NONE, DisplayAreaSupport.BORDER_COLOR_NORMAL)); } private void initComponents() { setLayout(new BorderLayout()); setOpaque(true); setBackground(DisplayAreaSupport.BACKGROUND_COLOR_NORMAL); // ImageIcon closeIcon = new ImageIcon(DisplayArea.class.getResource("/org/graalvm/visualvm/core/ui/resources/closePanel.png")); // NOI18N // closeButton = new DisplayAreaSupport.ImageIconButton(closeIcon); closeButton = CloseButtonFactory.createBigCloseButton(); closeButton.setFocusable(true); // GH-52 - enable closing the view using keyboard closeButton.setToolTipText(NbBundle.getMessage(DisplayArea.class, "ToolTip_Hide")); // NOI18N closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getParent().getParent().setVisible(false); } }); contentsPanel = new JPanel(layout); contentsPanel.setOpaque(false); add(contentsPanel, BorderLayout.WEST); add(closeButton, BorderLayout.EAST); } } private static class ViewArea extends JPanel { private ViewArea() { setLayout(new BorderLayout()); setOpaque(false); } private void setSelectedView(JComponent component) { synchronized (getTreeLock()) { removeAll(); if (component != null) add(component, BorderLayout.CENTER); revalidate(); repaint(); } } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/DataViewComponent.java0000644000175000017500000006263113767155557031201 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import org.graalvm.visualvm.uisupport.UISupport; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneUI; /** * UI component displaying single subtab for opened DataSource. * * @author Jiri Sedlacek */ public final class DataViewComponent extends JPanel { /** * Top left details area of the view. */ public static final int TOP_LEFT = 1; /** * Top right details area of the view. */ public static final int TOP_RIGHT = 2; /** * Bottom left details area of the view. */ public static final int BOTTOM_LEFT = 3; /** * Bottom right details area of the view. */ public static final int BOTTOM_RIGHT = 4; private boolean isMasterViewResizable; private JPanel masterPanel; private JPanel detailsPanel; private JExtendedSplitPane detailsTopHorizontalSplitter; private JExtendedSplitPane detailsBottomHorizontalSplitter; private JExtendedSplitPane detailsVerticalSplitter; private DisplayArea masterArea; private DisplayArea detailsTopLeftArea; private DisplayArea detailsTopRightArea; private DisplayArea detailsBottomLeftArea; private DisplayArea detailsBottomRightArea; private static final Color BACKGROUND_COLOR; private static final Color HIGHLIGHT_BACKGROUND; static { BACKGROUND_COLOR = UISupport.getDefaultBackground(); int darkerR = BACKGROUND_COLOR.getRed() - 20; if (darkerR < 0) darkerR += 40; int darkerG = BACKGROUND_COLOR.getGreen() - 20; if (darkerG < 0) darkerG += 40; int darkerB = BACKGROUND_COLOR.getBlue() - 20; if (darkerB < 0) darkerB += 40; HIGHLIGHT_BACKGROUND = new Color(darkerR, darkerG, darkerB); } /** * Creates new instance of DataViewComponent. * * @param masterView MasterView for the component. * @param masterAreaConfiguration MasterAreaConfiguration for the component. */ public DataViewComponent(MasterView masterView, MasterViewConfiguration masterAreaConfiguration) { initComponents(); createMasterView(masterView); configureMasterView(masterAreaConfiguration); } private void configureMasterView(MasterViewConfiguration masterViewConfiguration) { setMasterViewResizable(masterViewConfiguration.isMasterViewResizable()); } /** * Configures properties of the details view. * * @param detailsViewConfiguration configuration for the details view. */ public void configureDetailsView(DetailsViewConfiguration detailsViewConfiguration) { double topHorizontalDividerResizeWeight = detailsViewConfiguration.getTopHorizontalDividerResizeWeight(); if (topHorizontalDividerResizeWeight != -1) detailsTopHorizontalSplitter.setResizeWeight(topHorizontalDividerResizeWeight); double topHorizontalDividerLocation = detailsViewConfiguration.getTopHorizontalDividerLocation(); if (topHorizontalDividerLocation != -1) detailsTopHorizontalSplitter.setDividerLocation(topHorizontalDividerLocation); double bottomHorizontalDividerResizeWeight = detailsViewConfiguration.getBottomHorizontalDividerResizeWeight(); if (bottomHorizontalDividerResizeWeight != -1) detailsBottomHorizontalSplitter.setResizeWeight(bottomHorizontalDividerResizeWeight); double bottomHorizontalDividerLocation = detailsViewConfiguration.getBottomHorizontalDividerLocation(); if (bottomHorizontalDividerLocation != -1) detailsBottomHorizontalSplitter.setDividerLocation(bottomHorizontalDividerLocation); double verticalDividerResizeWeight = detailsViewConfiguration.getVerticalDividerResizeWeight(); if (verticalDividerResizeWeight != -1) detailsVerticalSplitter.setResizeWeight(verticalDividerResizeWeight); double verticalDividerLocation = detailsViewConfiguration.getVerticalDividerLocation(); if (verticalDividerLocation != -1) detailsVerticalSplitter.setDividerLocation(verticalDividerLocation); } /** * Shows details area on provided location. * * @param location location to be shown. */ public void showDetailsArea(int location) { DisplayArea displayArea = getDisplayArea(location); if (displayArea != null) displayArea.setVisible(true); } /** * Hides details area on provided location. * * @param location location to be hidden. */ public void hideDetailsArea(int location) { DisplayArea displayArea = getDisplayArea(location); if (displayArea != null) displayArea.setVisible(false); } /** * Returns true if the details area on provided location is currently shown, false otherwise. * @param location location to be checked. * @return true if the details area on provided location is currently shown, false otherwise. */ public boolean isDetailsAreaShown(int location) { DisplayArea displayArea = getDisplayArea(location); return displayArea != null ? displayArea.isVisible() : false; } /** * Configures properties of the details area. * * @param detailsAreaConfiguration configuration for the details area. * @param location location of the details area to be configured. */ public void configureDetailsArea(DetailsAreaConfiguration detailsAreaConfiguration, int location) { DisplayArea displayArea = getDisplayArea(location); if (displayArea != null) { displayArea.setCaption(detailsAreaConfiguration.getName()); displayArea.setClosable(detailsAreaConfiguration.isClosable()); } } private void createMasterView(MasterView masterView) { masterPanel.setVisible(true); JComponent[] options = new JComponent[] { detailsTopLeftArea.getPresenter(), detailsTopRightArea.getPresenter(), detailsBottomLeftArea.getPresenter(), detailsBottomRightArea.getPresenter() }; masterArea.addTab(new DisplayArea.Tab(masterView.getName(), masterView.getDescription(), 0, masterView.getView(), options)); } /** * Adds new details view. * * @param detailsView DetailsView to be added. * @param location location where the DetailsView will be added. */ public void addDetailsView(DetailsView detailsView, int location) { DisplayArea displayArea = getDisplayArea(location); if (displayArea != null) { if ("".equals(displayArea.getCaption())) displayArea.setCaption(detailsView.getTab().getName()); displayArea.addTab(detailsView.getTab()); revalidate(); repaint(); } } /** * Removes details view. * * @param detailsView DetailsView to be removed. */ public void removeDetailsView(DetailsView detailsView) { DisplayArea displayArea = getDisplayArea(detailsView.getTab()); if (displayArea != null) displayArea.removeTab(detailsView.getTab()); } /** * Returns true if DataViewComponent contains the DetailsView, false otherwise. * * @param detailsView DetailsView to check. * @return true if DataViewComponent contains the DetailsView, false otherwise. */ public boolean containsDetailsView(DetailsView detailsView) { return getDisplayArea(detailsView.getTab()) != null; } /** * Selects the DetailsView. * * @param detailsView DetailsView to be selected. */ public void selectDetailsView(DetailsView detailsView) { DisplayArea displayArea = getDisplayArea(detailsView.getTab()); if (displayArea != null) displayArea.setSelectedTab(detailsView.getTab()); } private void setMasterViewResizable(boolean isMasterViewResizable) { this.isMasterViewResizable = isMasterViewResizable; masterArea.setIgnoresContentsHeight(isMasterViewResizable); JComponent contents = null; if (isMasterViewResizable) { final CustomizedSplitPaneUI mainVerticalSplitterUI = new CustomizedSplitPaneUI(); JExtendedSplitPane mainVerticalSplitter = new JExtendedSplitPane(JSplitPane.VERTICAL_SPLIT, masterPanel, detailsPanel){ public void updateUI() { if (getUI() != mainVerticalSplitterUI) setUI(mainVerticalSplitterUI); setBorder(null); setOpaque(false); setDividerSize(6); setContinuousLayout(true); final BasicSplitPaneDivider divider = ((BasicSplitPaneUI) getUI()).getDivider(); divider.setBackground(BACKGROUND_COLOR); divider.setBorder(null); divider.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { divider.setBackground(HIGHLIGHT_BACKGROUND); divider.repaint(); } public void mouseExited(MouseEvent e) { divider.setBackground(BACKGROUND_COLOR); divider.repaint(); } }); } }; mainVerticalSplitter.setDividerLocation(0.5d); contents = mainVerticalSplitter; } else { JPanel containerPanel = new JPanel(new BorderLayout()); containerPanel.setOpaque(false); containerPanel.add(masterPanel, BorderLayout.NORTH); containerPanel.add(detailsPanel, BorderLayout.CENTER); contents = containerPanel; } synchronized (getTreeLock()) { removeAll(); add(contents, BorderLayout.CENTER); } revalidate(); repaint(); } private boolean isMasterAreaResizable() { return isMasterViewResizable; } private DisplayArea getDisplayArea(int location) { switch (location) { case TOP_LEFT: return detailsTopLeftArea; case TOP_RIGHT: return detailsTopRightArea; case BOTTOM_LEFT: return detailsBottomLeftArea; case BOTTOM_RIGHT: return detailsBottomRightArea; default: return null; } } private DisplayArea getDisplayArea(DisplayArea.Tab tab) { if (detailsTopLeftArea.containsTab(tab)) return detailsTopLeftArea; if (detailsTopRightArea.containsTab(tab)) return detailsTopRightArea; if (detailsBottomLeftArea.containsTab(tab)) return detailsBottomLeftArea; if (detailsBottomRightArea.containsTab(tab)) return detailsBottomRightArea; return null; } private void initComponents() { // Top details area detailsTopLeftArea = new DisplayArea(); detailsTopRightArea = new DisplayArea(); final JPanel detailsTopPanel = new JPanel(new BorderLayout()); detailsTopPanel.setOpaque(false); final CustomizedSplitPaneUI detailsTopHorizontalSplitterUI = new CustomizedSplitPaneUI(); detailsTopHorizontalSplitter = new JExtendedSplitPane(JSplitPane.HORIZONTAL_SPLIT, detailsTopLeftArea, detailsTopRightArea) { public void setVisible(boolean visible) { super.setVisible(visible); detailsTopPanel.setVisible(visible); revalidate(); repaint(); } public void updateUI() { if (getUI() != detailsTopHorizontalSplitterUI) setUI(detailsTopHorizontalSplitterUI); setBorder(null); setOpaque(false); setDividerSize(6); setContinuousLayout(true); final BasicSplitPaneDivider divider = ((BasicSplitPaneUI) getUI()).getDivider(); divider.setBackground(BACKGROUND_COLOR); divider.setBorder(null); divider.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { divider.setBackground(HIGHLIGHT_BACKGROUND); divider.repaint(); } public void mouseExited(MouseEvent e) { divider.setBackground(BACKGROUND_COLOR); divider.repaint(); } }); } }; detailsTopHorizontalSplitter.setResizeWeight(0.5d); detailsTopHorizontalSplitter.setDividerLocation(0.5d); detailsTopPanel.add(detailsTopHorizontalSplitter, BorderLayout.CENTER); // Bottom details area detailsBottomLeftArea = new DisplayArea(); detailsBottomRightArea = new DisplayArea(); final JPanel detailsBottomPanel = new JPanel(new BorderLayout()); detailsBottomPanel.setOpaque(false); final CustomizedSplitPaneUI detailsBottomHorizontalSplitterUI = new CustomizedSplitPaneUI(); detailsBottomHorizontalSplitter = new JExtendedSplitPane(JSplitPane.HORIZONTAL_SPLIT, detailsBottomLeftArea, detailsBottomRightArea) { public void setVisible(boolean visible) { super.setVisible(visible); detailsBottomPanel.setVisible(visible); revalidate(); repaint(); } public void updateUI() { if (getUI() != detailsBottomHorizontalSplitterUI) setUI(detailsBottomHorizontalSplitterUI); setBorder(null); setOpaque(false); setDividerSize(6); setContinuousLayout(true); final BasicSplitPaneDivider divider = ((BasicSplitPaneUI) getUI()).getDivider(); divider.setBackground(BACKGROUND_COLOR); divider.setBorder(null); divider.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { divider.setBackground(HIGHLIGHT_BACKGROUND); divider.repaint(); } public void mouseExited(MouseEvent e) { divider.setBackground(BACKGROUND_COLOR); divider.repaint(); } }); } }; detailsBottomHorizontalSplitter.setResizeWeight(0.5d); detailsBottomHorizontalSplitter.setDividerLocation(0.5d); detailsBottomPanel.add(detailsBottomHorizontalSplitter, BorderLayout.CENTER); // Details area detailsPanel = new JPanel(new BorderLayout()); detailsPanel.setOpaque(false); detailsPanel.setVisible(false); final CustomizedSplitPaneUI detailsVerticalSplitterUI = new CustomizedSplitPaneUI(); detailsVerticalSplitter = new JExtendedSplitPane(JSplitPane.VERTICAL_SPLIT, detailsTopPanel, detailsBottomPanel) { public void setVisible(boolean visible) { super.setVisible(visible); detailsPanel.setVisible(visible); revalidate(); repaint(); } public void updateUI() { if (getUI() != detailsVerticalSplitterUI) setUI(detailsVerticalSplitterUI); setBorder(null); setOpaque(false); setDividerSize(6); setContinuousLayout(true); final BasicSplitPaneDivider divider = ((BasicSplitPaneUI) getUI()).getDivider(); divider.setBackground(BACKGROUND_COLOR); divider.setBorder(null); divider.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { divider.setBackground(HIGHLIGHT_BACKGROUND); divider.repaint(); } public void mouseExited(MouseEvent e) { divider.setBackground(BACKGROUND_COLOR); divider.repaint(); } }); } }; detailsVerticalSplitter.setResizeWeight(0.5d); detailsVerticalSplitter.setDividerLocation(0.5d); detailsPanel.add(detailsVerticalSplitter, BorderLayout.CENTER); // Master area masterArea = new DisplayArea(); masterArea.setClosable(false); masterPanel = new JPanel(new BorderLayout()); masterPanel.setOpaque(false); masterPanel.setVisible(false); masterPanel.add(masterArea, BorderLayout.CENTER); // DataView setOpaque(true); setBackground(BACKGROUND_COLOR); setLayout(new BorderLayout()); } private static class CustomizedSplitPaneUI extends BasicSplitPaneUI { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { public void paint(Graphics g) { Dimension size = getSize(); g.setColor(getBackground()); g.fillRect(0, 0, size.width, size.height); } }; } } /** * Master view of DataViewComponent. This is the upper part of the component showing the master contents and/or * controls for details views. Master view is always shown for each DataViewComponent. */ public static class MasterView { private String name; private String description; private JComponent view; /** * Creates new instance of MasterView. * * @param name name of the view. * @param description description of the view. * @param view UI component to be shown. */ public MasterView(String name, String description, JComponent view) { this.name = name; this.description = description; this.view = view; } private String getName() { return name; } private String getDescription() { return description; } private JComponent getView() { return view; } } /** * Details view of DataViewComponent. This is an optional view of the DataViewComponent which can be hidden or * not used at all. */ public static class DetailsView { private DisplayArea.Tab tab; /** * Creates new instance of DetailsView. * * @param name name of the view. * @param description description of the view. * @param preferredPosition preferred position of the view among other views. * @param view UI component to be shown. * @param options components to be shown in view's caption. */ public DetailsView(String name, String description, int preferredPosition, JComponent view, JComponent[] options) { tab = new DisplayArea.Tab(name, description, preferredPosition, view, options); } private DisplayArea.Tab getTab() { return tab; } } /** * Configuration of the MasterView. */ public static class MasterViewConfiguration { private boolean isMasterViewResizable; /** * Creates new instance of MasterViewConfiguration. * * @param isMasterAreaResizable controls if master area can be dynamically resized in the UI (effective only if at least one details view is displayed). */ public MasterViewConfiguration(boolean isMasterAreaResizable) { this.isMasterViewResizable = isMasterAreaResizable; } private boolean isMasterViewResizable() { return isMasterViewResizable; } } /** * Configuration of the DetailsView. */ public static class DetailsViewConfiguration { private double topHorizontalDividerLocation; private double topHorizontalDividerResizeWeight; private double bottomHorizontalDividerLocation; private double bottomHorizontalDividerResizeWeight; private double verticalDividerLocation; private double verticalDividerResizeWeight; /** * Creates new instance of DetailsViewConfiguration. * * @param topHorizontalDividerLocation preferred relative location of top horizontal divider. * @param topHorizontalDividerResizeWeight preferred resize weight of top horizontal divider. * @param bottomHorizontalDividerLocation preferred relative location of bottom horizontal divider. * @param bottomHorizontalDividerResizeWeight preferred resize weight of bottom horizontal divider. * @param verticalDividerLocation preferred location of vertical divider. * @param verticalDividerResizeWeight preferred resize weight of vertical divider. */ public DetailsViewConfiguration(double topHorizontalDividerLocation, double topHorizontalDividerResizeWeight, double bottomHorizontalDividerLocation, double bottomHorizontalDividerResizeWeight, double verticalDividerLocation, double verticalDividerResizeWeight) { this.topHorizontalDividerLocation = topHorizontalDividerLocation; this.topHorizontalDividerResizeWeight = topHorizontalDividerResizeWeight; this.bottomHorizontalDividerLocation = bottomHorizontalDividerLocation; this.bottomHorizontalDividerResizeWeight = bottomHorizontalDividerResizeWeight; this.verticalDividerLocation = verticalDividerLocation; this.verticalDividerResizeWeight = verticalDividerResizeWeight; } /** * Returns preferred relative location of top horizontal divider. * @return preferred relative location of top horizontal divider. */ public double getTopHorizontalDividerLocation() { return topHorizontalDividerLocation; }; /** * Returns preferred resize weight of top horizontal divider. * @return preferred resize weight of top horizontal divider. */ public double getTopHorizontalDividerResizeWeight() { return topHorizontalDividerResizeWeight; }; /** * Returns preferred relative location of bottom horizontal divider. * @return preferred relative location of bottom horizontal divider. */ public double getBottomHorizontalDividerLocation() { return bottomHorizontalDividerLocation; }; /** * Returns preferred resize weight of bottom horizontal divider. * @return preferred resize weight of bottom horizontal divider. */ public double getBottomHorizontalDividerResizeWeight() { return bottomHorizontalDividerResizeWeight; }; /** * Returns preferred relative location of vertical divider. * @return preferred relative location of vertical divider. */ public double getVerticalDividerLocation() { return verticalDividerLocation; }; /** * Returns preferred resize weight of vertical divider. * @return preferred resize weight of vertical divider. */ public double getVerticalDividerResizeWeight() { return verticalDividerResizeWeight; }; } /** * Configuration for details area. */ public static class DetailsAreaConfiguration { private String name; private boolean closable; /** * Creates new instance of DetailsAreaConfiguration. * * @param name name of the details area. * @param closable controls if the details area is closable or always shown. */ public DetailsAreaConfiguration(String name, boolean closable) { this.name = name; this.closable = closable; } private String getName() { return name; } private boolean isClosable() { return closable; } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/LevelIndicator.java0000644000175000017500000003044613767155557030515 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import java.awt.AWTException; import java.awt.Color; import java.awt.Dimension; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.ImageCapabilities; import java.awt.Insets; import java.awt.image.VolatileImage; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JComponent.AccessibleJComponent; import javax.swing.border.BevelBorder; /** * Graphical component for fall-off level indicator * @author Jaroslav Bachorik */ public class LevelIndicator extends JComponent { //~ Static fields/initializers ----------------------------------------------------------------------------------------------- private static final Insets NULL_INSETS = new Insets(0, 0, 0, 0); private static final Dimension PREFERRED_SIZE = new Dimension(40, 20); //~ Instance fields ---------------------------------------------------------------------------------------------------------- private Color maximumColor = Color.RED; private Color minimumColor = Color.GREEN; private Color peakColor = null; private Dimension canvasDimension = null; private Insets canvasInsets = NULL_INSETS; private boolean autoRepaint = true; private boolean followPeak; private int peakMarkSize = 8; // peak mark size in pixels private long max = 0; private long min = 0; private long peak = Long.MIN_VALUE; private long val = min; //~ Constructors ------------------------------------------------------------------------------------------------------------- public LevelIndicator() { setPreferredSize(PREFERRED_SIZE); setMinimumSize(PREFERRED_SIZE); setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); } //~ Methods ------------------------------------------------------------------------------------------------------------------ /** * Sets the auto repainting of the component on/off * @param autoRepaint The auto repainting on/off */ public void setAutoRepaint(boolean autoRepaint) { this.autoRepaint = autoRepaint; } /** * Status of the component auto repainting * @return Returns the status of the component auto repainting */ public boolean isAutoRepaint() { return autoRepaint; } /** * When set the component will mark the so-far highest value * @param markPeaks Set peak following on/off */ public void setFollowPeak(boolean markPeaks) { this.followPeak = markPeaks; } /** * Status of the follow-peak * @return Returns the status of the follow-peak property */ public boolean isFollowPeak() { return followPeak; } /** * Sets the component maximum value * Will repaint the component if {@linkplain #isAutoRepaint() } is on * @param max The maximum value the component would display */ public void setMaximum(long max) { this.max = max; if (autoRepaint) { repaint(); } } /** * Returns the component maximum value * @return Returns the component maximum value */ public long getMaximum() { return max; } /** * With this property you can control the {@linkplain Color} of the highest value * Will repaint the component if {@linkplain #isAutoRepaint() } is on * @param maximumColor The {@linkplain Color} to be used for the highest values */ public void setMaximumColor(Color maximumColor) { this.maximumColor = maximumColor; } /** * Returns the {@linkplain Color} of the highest values * @return Returns the {@linkplain Color} of the highest values */ public Color getMaximumColor() { return maximumColor; } /** * Sets the minimum displayable value of the component * Will repaint the component if {@linkplain #isAutoRepaint() } is on * @param min The minimal value that should be displayed */ public void setMinimum(long min) { this.min = min; if (autoRepaint) { repaint(); } } /** * Returns the component minimal value * @return Returns the component minimal value */ public long getMinimum() { return min; } /** * Sets the {@linkplain Color} for the minimal value * Will repaint the component if {@linkplain #isAutoRepaint() } is on * @param minimumColor The {@linkplain Color} to use for the minimal value */ public void setMinimumColor(Color minimumColor) { this.minimumColor = minimumColor; } /** * Returns the {@linkplain Color} used for the minimal value * @return Returns the {@linkplain Color} used for the minimal value */ public Color getMinimumColor() { return minimumColor; } /** * Manually sets the actual value as the peak * Will repaint the component if {@linkplain #isAutoRepaint() } is on */ public void setPeak() { peak = val; if (autoRepaint) { repaint(); } } /** * Manually sets the peak * Will repaint the component if {@linkplain #isAutoRepaint() } is on * @param value The value to set as the peak */ public void setPeak(long value) { if (peak <= max) { peak = value; if (autoRepaint) { repaint(); } } } /** * Returns the current peak value * @return Returns the current peak value */ public long getPeak() { return peak; } /** * Sets the peak mark size in pixels * The peak mark is rendered in the indicator at the place of peak value * @param peakMarkSize The peak mark size in pixels */ public void setPeakMarkSize(int peakMarkSize) { this.peakMarkSize = peakMarkSize; if (autoRepaint) { repaint(); } } /** * Returns the peak mark size in pixels * The peak mark is rendered in the indicator at the place of peak value * @return Returns the peak mark size in pixels */ public int getPeakMarkSize() { return peakMarkSize; } /** * Sets the current value of the inidicator * @param value The current value */ public void setValue(long value) { val = Math.max(Math.min(value, max), 0); if (followPeak && (val > peak)) { peak = this.val; } if (autoRepaint) { repaint(); } } /** * Returns the current value * @return Returns the current value */ public long getValue() { return val; } @Override public void doLayout() { super.doLayout(); canvasInsets = getInsets(); canvasDimension = new Dimension(getBounds().width - (canvasInsets.left + canvasInsets.right), getBounds().height - (canvasInsets.top + canvasInsets.bottom)); } @Override public void paintComponent(Graphics g) { if (canvasDimension == null) { return; } if ((canvasDimension.getHeight() < 0) || (canvasDimension.getWidth() < 0)) { return; // no rendering if dimensions are negative } try { VolatileImage img = createVolatileImage(getBounds().width - (canvasInsets.left + canvasInsets.right), getBounds().height - (canvasInsets.top + canvasInsets.bottom), new ImageCapabilities(true)); Graphics2D gr = img.createGraphics(); renderLevel(gr, img); renderPeak(gr); gr.dispose(); g.drawImage(img, canvasInsets.left, canvasInsets.top, this); // // if (getBorder() != null) { // getBorder().paintBorder(this, g, 0, 0, getBounds().width, getBounds().height); // } } catch (AWTException e) { } } /** * Cleans the peak mark * Will repaint the component */ public void unsetPeak() { peak = Integer.MIN_VALUE; repaint(); } /** * Gets a dummy AccessibleContext associated with this LevelIndicator. * * @return a dummy AccessibleContext associated with this LevelIndicator */ public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleLevelIndicator(); } return accessibleContext; } private Color getColorAt(VolatileImage img, int x, int y) { if ((x <= 0) || (y < 0) || (x > img.getWidth()) || (y > img.getHeight())) { return null; } int RGB = img.getSnapshot().getRGB(x - 1, 0); int red = (RGB & 0x00ff0000) >> 16; int green = (RGB & 0x0000ff00) >> 8; int blue = RGB & 0x000000ff; // and the Java Color is ... return new Color(red, green, blue); } private int getPosition(long value) { float ratio = (float) value / (float) (max - min); return Math.round((float) (ratio * canvasDimension.getWidth())); } private void renderLevel(Graphics2D gr, VolatileImage img) { gr.setPaint(new GradientPaint(0, 0, minimumColor, canvasDimension.width, 0, maximumColor)); gr.fillRect(0, 0, canvasDimension.width, canvasDimension.height); if (peak > Integer.MIN_VALUE) { peakColor = getColorAt(img, getPosition(peak), 0); } int position = getPosition(val); gr.setPaint(getBackground()); gr.fillRect(position, 0, canvasDimension.width - position + 1, canvasDimension.height); } private void renderPeak(Graphics2D gr) { if (peakColor == null) { return; } int position = getPosition(peak); int decrement = 0; int left = 0; int right = 0; do { left = Math.round(position - ((peakMarkSize - decrement) / 2f)); right = Math.round(left + ((peakMarkSize - decrement) / 2f)); if (left < 0) { right += Math.abs(left); left = 0; } if (right > canvasDimension.getWidth()) { left -= (right - canvasDimension.getWidth()); right = (int) canvasDimension.getWidth(); } decrement++; } while (((left < 0) || (right > canvasDimension.getWidth())) && (left != right)); gr.setPaint(peakColor); gr.fillRect(left, 0, right - left + 1, canvasDimension.height); } /** * Dummy AccessibleContext implementation for the LevelIndicator. */ private class AccessibleLevelIndicator extends AccessibleJComponent { /** * Get the role of this object. * * @return an instance of AccessibleRole describing the role of the * object */ public AccessibleRole getAccessibleRole() { return AccessibleRole.SWING_COMPONENT; } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/Spacer.java0000644000175000017500000000360413767155557027022 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import java.awt.Dimension; import javax.swing.JPanel; /** * Subclass of a JPanel to be used as a spacer in GridBagLayout. Creates a * non-opaque JPanel with null Layout and zero preferred size. * * @author Jiri Sedlacek */ public final class Spacer extends JPanel { private static final Dimension DIMENSION_ZERO = new Dimension(0, 0); /** * Creates new instance of Spacer. * * @return new instance of Spacer */ public static Spacer create() { return new Spacer(); } public Dimension getPreferredSize() { return DIMENSION_ZERO; } private Spacer() { super(null); setOpaque(false); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/NotSupportedDisplayer.java0000644000175000017500000000533513767155557032133 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import java.awt.BorderLayout; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import org.openide.util.NbBundle; /** * JPanel showing a predefined message. * * @author Jiri Sedlacek */ public final class NotSupportedDisplayer extends JPanel { /** * Not supported for this application. */ public static final String APPLICATION = NbBundle.getMessage(NotSupportedDisplayer.class, "MSG_application"); // NOI18N /** * Not supported for this JVM. */ public static final String JVM = NbBundle.getMessage(NotSupportedDisplayer.class, "MSG_JVM"); // NOI18N /** * Not supported for this host. */ public static final String HOST = NbBundle.getMessage(NotSupportedDisplayer.class, "MSG_host"); // NOI18N /** * Not supported for this OS. */ public static final String OS = NbBundle.getMessage(NotSupportedDisplayer.class, "MSG_OS"); // NOI18N /** * Creates new instance of NotSupportedDisplayer. * * @param object type of the not supported object (any string or predefined constant). */ public NotSupportedDisplayer(String object) { JLabel notSupportedLabel = new JLabel(NbBundle.getMessage(NotSupportedDisplayer.class, "MSG_Not_supported", object), SwingConstants.CENTER); // NOI18N notSupportedLabel.setEnabled(false); setLayout(new BorderLayout()); setOpaque(false); add(notSupportedLabel, BorderLayout.CENTER); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/JExtendedSplitPane.java0000644000175000017500000002124413767155557031277 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import java.awt.Component; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; import javax.swing.JSplitPane; import javax.swing.plaf.basic.BasicSplitPaneUI; /** * * @author Jiri Sedlacek */ class JExtendedSplitPane extends JSplitPane { private HierarchyListener leftComponentListener; private HierarchyListener rightComponentListener; private double dividerLocation; private int customDividerSize; private double requestedDividerLocation = -1; JExtendedSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent) { this(newOrientation, false, newLeftComponent, newRightComponent); } JExtendedSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent) { super(newOrientation, newContinuousLayout, newLeftComponent, newRightComponent); updateVisibility(); if (!newLeftComponent.isVisible()) computeDividerLocationWhenInitiallyHidden(newLeftComponent); if (!newRightComponent.isVisible()) computeDividerLocationWhenInitiallyHidden(newRightComponent); } public void setDividerSize(int newSize) { super.setDividerSize(newSize); customDividerSize = newSize; } public void setDividerLocation(double requestedDividerLocation) { Component divider = getDivider(); if (isVisible() && divider.isVisible()) { // SplitPane fully visible super.setDividerLocation(requestedDividerLocation); dividerLocation = requestedDividerLocation; } else if (isVisible()) { // Divider not visible, will be updated in updateVisibility() dividerLocation = requestedDividerLocation; } else if (!isVisible()) { // SplitPane not visible, dividerLocation will be set on first reasonable getSize() this.requestedDividerLocation = requestedDividerLocation; } } public void setLeftComponent(Component newLeftComponent) { if (leftComponent != null) { leftComponent.removeHierarchyListener(leftComponentListener); leftComponentListener = null; } super.setLeftComponent(newLeftComponent); if (getLeftComponent() != null) { leftComponentListener = new VisibilityListener(newLeftComponent); newLeftComponent.addHierarchyListener(leftComponentListener); } updateVisibility(); } public void setRightComponent(Component newRightComponent) { if (rightComponent != null) { rightComponent.removeHierarchyListener(rightComponentListener); rightComponentListener = null; } super.setRightComponent(newRightComponent); if (getRightComponent() != null) { rightComponentListener = new VisibilityListener(newRightComponent); newRightComponent.addHierarchyListener(rightComponentListener); } updateVisibility(); } public void reshape(int x, int y, int width, int height) { super.reshape(x, y, width, height); if (width > 0 && height > 0 && requestedDividerLocation != -1) { super.setDividerLocation(requestedDividerLocation); dividerLocation = requestedDividerLocation; // SplitPaneUI.paint() needs to be invoked here to set the // BasicSplitPaneUI.painted flag to enable resizing the divider // even if the component hasn't been shown yet. ((BasicSplitPaneUI)getUI()).paint(getGraphics(), this); requestedDividerLocation = -1; } } private Component getDivider() { if (ui == null) return null; return ((BasicSplitPaneUI)ui).getDivider(); } private void computeDividerLocationWhenHidden(Component hiddenComponent) { if (leftComponent.isVisible() || rightComponent.isVisible()) { boolean horiz = getOrientation() == JSplitPane.HORIZONTAL_SPLIT; double size = horiz ? getSize().getWidth() : getSize().getHeight(); double csize = horiz ? hiddenComponent.getSize().getWidth() : hiddenComponent.getSize().getHeight(); computeDividerLocation(hiddenComponent, size, csize); } } private void computeDividerLocationWhenInitiallyHidden(Component hiddenComponent) { if (leftComponent.isVisible() || rightComponent.isVisible()) { boolean horiz = getOrientation() == JSplitPane.HORIZONTAL_SPLIT; double size = horiz ? getPreferredSize().getWidth() : getPreferredSize().getHeight(); double csize = horiz ? hiddenComponent.getPreferredSize().getWidth() : hiddenComponent.getPreferredSize().getHeight(); computeDividerLocation(hiddenComponent, size, csize); } } private void computeDividerLocation(Component hiddenComponent, double size, double csize) { if (hiddenComponent == leftComponent) { dividerLocation = csize / (size - customDividerSize); } else { dividerLocation = (size - customDividerSize - csize) / (size - customDividerSize); } } private void updateVisibility() { Component divider = getDivider(); // null UI, not yet set if (divider == null) return; if (leftComponent == null || rightComponent == null) return; boolean leftVisible = leftComponent.isVisible(); boolean rightVisible = rightComponent.isVisible(); if (leftVisible && rightVisible) { if (!divider.isVisible()) { JExtendedSplitPane.super.setDividerSize(customDividerSize); divider.setVisible(true); setDividerLocation(dividerLocation); } if (!isVisible()) setVisible(true); } else if (!leftVisible && !rightVisible) { if (isVisible()) setVisible(false); } else { if (divider.isVisible()) { JExtendedSplitPane.super.setDividerSize(0); divider.setVisible(false); setDividerLocation(0); } if (!isVisible()) setVisible(true); } if (getParent() != null) getParent().doLayout(); } private class VisibilityListener implements HierarchyListener { private boolean wasVisible; private final Component c; VisibilityListener(Component c) { this.c = c; wasVisible = c.isVisible(); } public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 || (e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) { boolean visible = c.isVisible(); if (wasVisible == visible) return; wasVisible = visible; if (visible) componentShown(); else componentHidden(c); } } private void componentHidden(Component c) { computeDividerLocationWhenHidden(c); // Make sure the component is visible when shown if ((dividerLocation <= 0) || (dividerLocation >= 1)) dividerLocation = 0.5; updateVisibility(); } private void componentShown() { updateVisibility(); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/DisplayAreaSupport.java0000644000175000017500000003450713767155557031406 0ustar apoapo/* * TabbedCaptionSupport.java * * Created on Dec 11, 2007, 2:20:48 PM * * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.Stroke; import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.FilteredImageSource; import java.awt.image.ImageProducer; import java.util.HashSet; import java.util.Set; import javax.swing.BorderFactory; import javax.swing.DefaultButtonModel; import javax.swing.GrayFilter; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.border.BevelBorder; import javax.swing.border.Border; import org.graalvm.visualvm.uisupport.UISupport; /** * * @author Jiri Sedlacek */ class DisplayAreaSupport { static final Color BORDER_COLOR_NORMAL = !UISupport.isDarkResultsBackground() ? new Color(192, 192, 192) : new Color(64, 64, 64); static final Color BORDER_COLOR_HIGHLIGHT = !UISupport.isDarkResultsBackground() ? new Color(128, 128, 128) : new Color(90, 90, 90); static final Color BACKGROUND_COLOR_NORMAL = !UISupport.isDarkResultsBackground() ? new Color(245, 245, 245) : new Color(50, 50, 50); static final Color BACKGROUND_COLOR_HIGHLIGHT = !UISupport.isDarkResultsBackground() ? new Color(235, 235, 235) : new Color(55, 55, 55); static final Color COLOR_NONE = new Color(0, 0, 0); static final Color TABS_SEPARATOR = new Color(UIManager.getColor("Label.foreground").getRGB()); // NOI18N static final int TABBUTTON_MARGIN_TOP = 3; static final int TABBUTTON_MARGIN_LEFT = 8; static final int TABBUTTON_MARGIN_BOTTOM = 3; static final int TABBUTTON_MARGIN_RIGHT = 8; private static final Color TABBUTTON_FOCUS_COLOR = Color.BLACK; private static final Stroke TABBUTTON_FOCUS_STROKE = new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 0, new float[] {0, 2}, 0); static class TabButton extends JButton { TabButton(String text, String description) { super(text); setModel(new DefaultButtonModel() { public boolean isPressed() { return false; } }); setOpaque(false); setFocusPainted(false); setBorderPainted(false); setContentAreaFilled(false); setBorder(BorderFactory.createEmptyBorder(TABBUTTON_MARGIN_TOP, TABBUTTON_MARGIN_LEFT, TABBUTTON_MARGIN_BOTTOM, TABBUTTON_MARGIN_RIGHT)); setToolTipText(description); } protected void paintComponent(Graphics g) { super.paintComponent(g); Dimension size = getSize(); Graphics2D g2 = (Graphics2D)g; if( hasFocus() && isEnabled() ) { g2.setStroke(TABBUTTON_FOCUS_STROKE); g2.setColor(TABBUTTON_FOCUS_COLOR); g2.drawRect(2, 2, size.width - 5, size.height - 5); } } } static class TabButtonContainer extends JPanel { private TabButton tabButton; TabButtonContainer(TabButton tabButton) { this.tabButton = tabButton; setOpaque(true); setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); setBackground(BACKGROUND_COLOR_NORMAL); setBorder(TabbedCaptionBorder.get(null, null, null, null)); add(tabButton, BorderLayout.CENTER); } public void setEnabled(boolean enabled) { super.setEnabled(enabled); tabButton.setEnabled(enabled); } void updateTabButton(int index, int selectedIndex, int buttonsCount) { if (buttonsCount == 1) { tabButton.setFocusable(false); tabButton.setCursor(Cursor.getDefaultCursor()); setBackground(BACKGROUND_COLOR_NORMAL); setBorder(TabbedCaptionBorder.get(BORDER_COLOR_NORMAL, BORDER_COLOR_NORMAL, COLOR_NONE, COLOR_NONE)); } else if (index == selectedIndex) { tabButton.setFocusable(true); tabButton.setCursor(Cursor.getDefaultCursor()); setBackground(BACKGROUND_COLOR_HIGHLIGHT); setBorder(TabbedCaptionBorder.get(BORDER_COLOR_HIGHLIGHT, BORDER_COLOR_HIGHLIGHT, COLOR_NONE, BORDER_COLOR_HIGHLIGHT)); } else { tabButton.setFocusable(true); tabButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); setBackground(BACKGROUND_COLOR_NORMAL); Color topColor = BORDER_COLOR_NORMAL; Color leftColor = index == 0 ? BORDER_COLOR_NORMAL : null; Color bottomColor = BORDER_COLOR_HIGHLIGHT; Color rightColor = index == selectedIndex - 1 ? null : index == buttonsCount - 1 ? COLOR_NONE : TABS_SEPARATOR; setBorder(TabbedCaptionBorder.get(topColor, leftColor, bottomColor, rightColor)); } } } static class TabbedCaptionBorder implements Border { private static final Set borders = new HashSet(); private Color COLOR_TOP; private Color COLOR_LEFT; private Color COLOR_BOTTOM; private Color COLOR_RIGHT; private Insets insets; static TabbedCaptionBorder get(Color colorTop, Color colorLeft, Color colorBottom, Color colorRight) { for (TabbedCaptionBorder border : borders) // Note: identity must be used for the comparison! if (border.COLOR_TOP == colorTop && border.COLOR_LEFT == colorLeft && border.COLOR_BOTTOM == colorBottom && border.COLOR_RIGHT == colorRight) return border; TabbedCaptionBorder border = new TabbedCaptionBorder(colorTop, colorLeft, colorBottom, colorRight); borders.add(border); return border; } private TabbedCaptionBorder(Color colorTop, Color colorLeft, Color colorBottom, Color colorRight) { COLOR_TOP = colorTop; COLOR_LEFT = colorLeft; COLOR_BOTTOM = colorBottom; COLOR_RIGHT = colorRight; insets = new Insets( COLOR_TOP == null ? 0 : 1, COLOR_LEFT == null ? 0 : 1, COLOR_BOTTOM == null ? 0 : 1, COLOR_RIGHT == null ? 0 : 1); } public Insets getBorderInsets(Component c) { return insets; } public boolean isBorderOpaque() { return true; } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (COLOR_LEFT != null && COLOR_LEFT != COLOR_NONE) { g.setColor(COLOR_LEFT); if (COLOR_LEFT == TABS_SEPARATOR) { g.drawLine(x, y + TABBUTTON_MARGIN_TOP + 2, x, y + height - TABBUTTON_MARGIN_BOTTOM - 4); } else { g.drawLine(x, y, x, y + height - 1); } } if (COLOR_RIGHT != null && COLOR_RIGHT != COLOR_NONE) { g.setColor(COLOR_RIGHT); if (COLOR_RIGHT == TABS_SEPARATOR) { g.drawLine(x + width - 1, y + TABBUTTON_MARGIN_TOP + 2, x + width - 1, y + height - TABBUTTON_MARGIN_BOTTOM - 4); } else { g.drawLine(x + width - 1, y, x + width - 1, y + height - 1); } } if (COLOR_TOP != null && COLOR_TOP != COLOR_NONE) { g.setColor(COLOR_TOP); g.drawLine(x, y, x + width - 1, y); } if (COLOR_BOTTOM != null && COLOR_BOTTOM != COLOR_NONE) { g.setColor(COLOR_BOTTOM); g.drawLine(x, y + height - 1, x + width - 1, y + height - 1); } } } private static class ThinBevelBorder extends BevelBorder { //~ Constructors --------------------------------------------------------------------------------------------------------- private ThinBevelBorder(int bevelType, Color highlight, Color shadow) { super(bevelType, highlight.brighter(), highlight, shadow, shadow.brighter()); } //~ Methods -------------------------------------------------------------------------------------------------------------- public Insets getBorderInsets(Component c) { return new Insets(1, 1, 1, 1); } public Insets getBorderInsets(Component c, Insets insets) { insets.left = insets.top = insets.right = insets.bottom = 1; return insets; } protected void paintLoweredBevel(Component c, Graphics g, int x, int y, int width, int height) { if (!c.isEnabled()) { return; } Color oldColor = g.getColor(); int h = height; int w = width; g.translate(x, y); g.setColor(getShadowOuterColor(c)); g.drawLine(0, 0, 0, h - 1); g.drawLine(1, 0, w - 1, 0); g.setColor(getHighlightInnerColor(c)); g.drawLine(1, h - 1, w - 1, h - 1); g.drawLine(w - 1, 1, w - 1, h - 2); g.translate(-x, -y); g.setColor(oldColor); } protected void paintRaisedBevel(Component c, Graphics g, int x, int y, int width, int height) { if (!c.isEnabled()) { return; } Color oldColor = g.getColor(); int h = height; int w = width; g.translate(x, y); g.setColor(getHighlightInnerColor(c)); g.drawLine(0, 0, 0, h - 1); g.drawLine(1, 0, w - 1, 0); g.setColor(getShadowOuterColor(c)); g.drawLine(0, h - 1, w - 1, h - 1); g.drawLine(w - 1, 0, w - 1, h - 2); g.translate(-x, -y); g.setColor(oldColor); } } static class ImageIconButton extends JButton implements MouseListener { //~ Instance fields ------------------------------------------------------------------------------------------------------ private static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(1, 1, 1, 1); private static final Border LOWERED_BORDER = new ThinBevelBorder(BevelBorder.LOWERED, Color.WHITE, Color.GRAY); private static final Border RAISED_BORDER = new ThinBevelBorder(BevelBorder.RAISED, Color.WHITE, Color.GRAY); private boolean rollover = false; private boolean pressed = false; //~ Constructors --------------------------------------------------------------------------------------------------------- ImageIconButton(ImageIcon icon) { super(); GrayFilter enabledFilter = new GrayFilter(true, 35); ImageProducer prod = new FilteredImageSource(icon.getImage().getSource(), enabledFilter); Icon grayIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(prod)); GrayFilter disabledFilter = new GrayFilter(true, 60); prod = new FilteredImageSource(icon.getImage().getSource(), disabledFilter); Icon disabledIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(prod)); setIcon(grayIcon); setRolloverIcon(icon); setPressedIcon(icon); setDisabledIcon(disabledIcon); setIconTextGap(0); setBorder(EMPTY_BORDER); setFocusPainted(false); setContentAreaFilled(false); addMouseListener(this); } //~ Methods -------------------------------------------------------------------------------------------------------------- public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { rollover = true; if (pressed) { setBorder(LOWERED_BORDER); } else { setBorder(RAISED_BORDER); } } public void mouseExited(MouseEvent e) { rollover = false; setBorder(EMPTY_BORDER); } public void mousePressed(MouseEvent e) { pressed = true; setBorder(LOWERED_BORDER); } public void mouseReleased(MouseEvent e) { pressed = false; if (rollover) { setBorder(RAISED_BORDER); } else { setBorder(EMPTY_BORDER); } } public Dimension getPreferredSize() { return new Dimension(TABBUTTON_MARGIN_LEFT + TABBUTTON_MARGIN_RIGHT, TABBUTTON_MARGIN_LEFT + TABBUTTON_MARGIN_RIGHT); } protected void paintComponent(Graphics g) { super.paintComponent(g); Dimension size = getSize(); Graphics2D g2 = (Graphics2D)g; if( hasFocus() && isEnabled() ) { g2.setStroke(TABBUTTON_FOCUS_STROKE); g2.setColor(TABBUTTON_FOCUS_COLOR); g2.drawRect(2, 2, size.width - 5, size.height - 5); } } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/package-info.java0000644000175000017500000000246713767155557030137 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Custom UI components used in VisualVM. */ package org.graalvm.visualvm.core.ui.components; visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/ScrollableContainer.java0000644000175000017500000001056313767155557031534 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.Rectangle; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.Scrollable; /** * Predefined JScrollPane to be used in VisualVM, for example in details views. * Use UISupport.createScrollableContainer() method instead of instantiating * this class directly if creating scrollable container for the Options panel. * * @author Jiri Sedlacek */ public final class ScrollableContainer extends JScrollPane { /** * Creates new instance of ScrollableContainer. * * @param view component to be displayed */ public ScrollableContainer(JComponent view) { this(view, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); } /** * Creates new instance of ScrollableContainer. * * @param view component to be displayed * @param vsbPolicy policy flag for the vertical scrollbar * @param hsbPolicy policy flag for the horizontal scrollbar */ public ScrollableContainer(JComponent view, int vsbPolicy, int hsbPolicy) { setViewportView(new ScrollableContents(view)); setVerticalScrollBarPolicy(vsbPolicy); setHorizontalScrollBarPolicy(hsbPolicy); setBorder(BorderFactory.createEmptyBorder()); setViewportBorder(BorderFactory.createEmptyBorder()); getViewport().setOpaque(false); setOpaque(false); } // --- Scrollable container ------------------------------------------------ private class ScrollableContents extends JPanel implements Scrollable { private ScrollableContents(JComponent contents) { super(new BorderLayout()); setOpaque(false); add(contents, BorderLayout.CENTER); } public Dimension getPreferredScrollableViewportSize() { return getPreferredSize(); } public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { return 20; } public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { return (int)(visibleRect.height * 0.9d); } public boolean getScrollableTracksViewportWidth() { if (getHorizontalScrollBarPolicy() == HORIZONTAL_SCROLLBAR_NEVER) return true; Container parent = getParent(); if ((parent == null) || !(parent instanceof JViewport)) return false; return getMinimumSize().width < ((JViewport)parent).getWidth(); } public boolean getScrollableTracksViewportHeight() { if (getVerticalScrollBarPolicy() == VERTICAL_SCROLLBAR_NEVER) return true; Container parent = getParent(); if ((parent == null) || !(parent instanceof JViewport)) return false; return getMinimumSize().height < ((JViewport)parent).getHeight(); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/Bundle.properties0000644000175000017500000000254513767155557030274 0ustar apoapo# # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. ToolTip_Hide=Hide ToolTip_ShowSection=Show {0} ToolTip_HideSection=Hide {0} MSG_application=application MSG_JVM=JVM MSG_host=host MSG_OS=OS MSG_Not_supported=Not supported for this {0}. visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/components/SectionSeparator.java0000644000175000017500000000732413767155557031075 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui.components; import org.graalvm.visualvm.uisupport.SeparatorLine; import java.awt.Color; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; /** * Separator-like component to be used instead of TitledBorder to keep the UI * lightweight. Use UISupport.createSectionSeparator() method instead of instantiating * this class directly if creating sections for the Options panel. * * @author Jiri Sedlacek */ public final class SectionSeparator extends JPanel { /** * Creates new instance of SectionSeparator. Uses bold font by default. * * @param text separator text */ public SectionSeparator(String text) { this(text, null); } /** * Creates new instance of SectionSeparator. Uses the provided font or default * font if no font is provided. * * @param text separator text * @param font font for the caption text or null for default font */ public SectionSeparator(String text, Font font) { if (text == null) throw new IllegalArgumentException("Text cannot be null"); // NOI18N initComponents(text, font); } public void setForeground(Color foreground) { if (label == null) super.setForeground(foreground); else label.setForeground(foreground); } public Color getForeground() { if (label == null) return super.getForeground(); else return label.getForeground(); } public void setFont(Font font) { if (label == null) super.setFont(font); else label.setFont(font); } public Font getFont() { if (label == null) return super.getFont(); else return label.getFont(); } private void initComponents(String text, Font font) { setBorder(BorderFactory.createEmptyBorder()); setLayout(new GridBagLayout()); setOpaque(false); label = new JLabel(text); label.setForeground(getForeground()); if (font != null) label.setFont(font); else label.setFont(label.getFont().deriveFont(Font.BOLD)); GridBagConstraints c1 = new GridBagConstraints(); c1.weighty = 1d; add(label, c1); GridBagConstraints c2 = new GridBagConstraints(); c2.weightx = 1d; c2.fill = GridBagConstraints.HORIZONTAL; c2.insets = new Insets(1, 4, 0, 0); add(new SeparatorLine(), c2); } private JLabel label; } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceCaption.java0000644000175000017500000003633413767155557026776 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptor; import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory; import org.graalvm.visualvm.core.datasupport.DataRemovedListener; import org.graalvm.visualvm.core.datasupport.Stateful; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.Timer; import javax.swing.UIManager; import org.graalvm.visualvm.uisupport.UISupport; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ final class DataSourceCaption extends JPanel implements PropertyChangeListener, DataRemovedListener { private static final boolean ANIMATE = Boolean.getBoolean("org.graalvm.visualvm.core.ui.DataSourceCaption.animate"); // NOI18N private static final int ANIMATION_RATE = Integer.getInteger("org.graalvm.visualvm.core.ui.DataSourceCaption.animationRate", 80); // NOI18N private static final Color DISABLED_CAPTION = new Color(128, 128, 128); private static final String APPLICATION_PID_PREFIX = "(pid"; // NOI18N private static final String APPLICATION_PID_SUFFIX = ")"; // NOI18N private final DataSource dataSourceMaster; private final DataSourceDescriptor dataSourceMasterDescriptor; private final boolean tracksChanges; private boolean isAvailable; private boolean isDirty = false; private String name; private String description; private boolean finished = false; public DataSourceCaption(X dataSource) { initComponents(); this.dataSourceMaster = DataSourceWindowManager.getViewMaster(dataSource); tracksChanges = dataSource == dataSourceMaster; dataSourceMaster.addPropertyChangeListener(this); dataSourceMasterDescriptor = DataSourceDescriptorFactory.getDescriptor(dataSourceMaster); dataSourceMasterDescriptor.addPropertyChangeListener(this); initAvailable(); name = dataSourceMasterDescriptor.getName(); description = dataSourceMasterDescriptor.getDescription(); updateCaption(); updateDescription(); updateAvailable(); dataSourceMaster.notifyWhenRemoved(this); } public void propertyChange(final PropertyChangeEvent evt) { SwingUtilities.invokeLater(new Runnable() { public void run() { String propertyName = evt.getPropertyName(); if (Stateful.PROPERTY_STATE.equals(propertyName)) { int state = (Integer)evt.getNewValue(); isAvailable = state == Stateful.STATE_AVAILABLE; if (tracksChanges && !isDirty && isAvailable && (Integer)evt.getOldValue() == Stateful.STATE_UNAVAILABLE) isDirty = true; updateAvailable(); updateCaption(); } else if (DataSourceDescriptor.PROPERTY_NAME.equals(propertyName)) { name = (String)evt.getNewValue(); updateCaption(); } else if (DataSourceDescriptor.PROPERTY_DESCRIPTION.equals(propertyName)) { description = (String)evt.getNewValue(); updateDescription(); } else if (DataSourceDescriptor.PROPERTY_ICON.equals(propertyName)) { // Could display datasource icon instead of progress icon // setIcon(new ImageIcon((Image)evt.getNewValue())); } } }); } public void dataRemoved(DataSource dataSource) { SwingUtilities.invokeLater(new Runnable() { public void run() { finish(); isAvailable = false; updateAvailable(); updateCaption(); } }); } public synchronized void finish() { if (finished) return; finished = true; dataSourceMaster.removePropertyChangeListener(this); dataSourceMasterDescriptor.removePropertyChangeListener(this); } private void updateAvailable() { if (isAvailable) { if (ANIMATE) { busyIconIndex = 0; if (busyIconTimer == null) createTimer(); busyIconTimer.start(); } else { presenter1.setIcon(new ImageIcon(getClass().getResource("/org/graalvm/visualvm/core/ui/resources/busy-icon4.png"))); // NOI18N } } else { if (busyIconTimer != null) busyIconTimer.stop(); // Stop previous animation if still running presenter1.setIcon(new ImageIcon(getClass().getResource("/org/graalvm/visualvm/core/ui/resources/idle-icon.png"))); // NOI18N } if (isDirty && !isOpaque()) { JLabel l = new JLabel(NbBundle.getMessage(DataSourceCaption.class, "DataSourceCaption_LBL_Reload")) { // NOI18N public Dimension getMinimumSize() { Dimension dim = super.getMinimumSize(); dim.height = super.getPreferredSize().height; return dim; } }; GridBagConstraints c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.weighty = 1; c.anchor = GridBagConstraints.BELOW_BASELINE; c.insets = new Insets(0, 16, 0, 0); c.fill = GridBagConstraints.NONE; add(l, c); JButton b = new JButton(NbBundle.getMessage(DataSourceCaption.class, "DataSourceCaption_BTN_Reload")) { // NOI18N protected void fireActionPerformed(ActionEvent e) { super.fireActionPerformed(e); DataSourceWindowManager.sharedInstance().reopenDataSource(dataSourceMaster); } public Dimension getMinimumSize() { Dimension dim = super.getMinimumSize(); dim.height = super.getPreferredSize().height; return dim; } }; c = new GridBagConstraints(); c.gridx = 3; c.gridy = 0; c.weighty = 0; c.anchor = GridBagConstraints.BELOW_BASELINE; c.insets = new Insets(0, 8, 0, 0); c.fill = GridBagConstraints.NONE; add(b, c); setOpaque(true); setBackground(UISupport.isDarkResultsBackground() ? new Color(150, 0, 0) : Color.YELLOW); invalidate(); revalidate(); doLayout(); repaint(); } } private void updateCaption() { // TODO: mask all html-specific characters name = name.replace(">", ">"); // NOI18N name = name.replace("<", "<"); // NOI18N Color textColor = isAvailable ? UIManager.getColor("Label.foreground") : DISABLED_CAPTION; // NOI18N presenter1.setForeground(textColor); presenter2.setForeground(textColor); if (name.contains(APPLICATION_PID_PREFIX) && name.contains(APPLICATION_PID_SUFFIX)) { // Hack to customize default Application displayname containing "(pid XXX)" int startPid = name.indexOf(APPLICATION_PID_PREFIX); presenter1.setText(name.substring(0, startPid)); presenter2.setText(name.substring(startPid)); } else { presenter1.setText(name); presenter2.setText(""); // NOI18N } } private void updateDescription() { if (description == null || description.trim().length() == 0) { presenter1.setToolTipText(null); presenter2.setToolTipText(null); } else { presenter1.setToolTipText(description); presenter2.setToolTipText(description); } } private void createTimer() { final Icon[] busyIcons = new Icon[15]; for (int i = 0; i < busyIcons.length; i++) busyIcons[i] = new ImageIcon(getClass().getResource("/org/graalvm/visualvm/core/ui/resources/busy-icon" + i + ".png")); // NOI18N busyIconTimer = new Timer(ANIMATION_RATE, new ActionListener() { public void actionPerformed(ActionEvent e) { if (!ANIMATE) { if (busyIconTimer != null) busyIconTimer.stop(); // Stop animation presenter1.setIcon(new ImageIcon(getClass().getResource("/org/graalvm/visualvm/core/ui/resources/busy-icon4.png"))); // NOI18N } else { busyIconIndex = (busyIconIndex + 1) % busyIcons.length; if (!DataSourceCaption.this.isShowing()) return; presenter1.setIcon(busyIcons[busyIconIndex]); } } }); } private void initAvailable() { if (dataSourceMaster instanceof Stateful) { Stateful statefulDataSource = (Stateful)dataSourceMaster; isAvailable = statefulDataSource.getState() == Stateful.STATE_AVAILABLE; } else { isAvailable = true; } } private void initComponents() { setLayout(new GridBagLayout()); presenter1 = new JLabel("XXX") { // NOI18N public Dimension getMinimumSize() { Dimension dim = super.getMinimumSize(); dim.height = super.getPreferredSize().height; return dim; } }; Font f = presenter1.getFont(); presenter1.setFont(f.deriveFont(Font.BOLD, f.getSize2D() * 1.2f)); presenter1.setIconTextGap(6); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weighty = 1; c.anchor = GridBagConstraints.BELOW_BASELINE; c.fill = GridBagConstraints.NONE; add(presenter1, c); presenter2 = new JLabel("(123)") { // NOI18N public Dimension getMinimumSize() { Dimension dim = super.getMinimumSize(); dim.height = super.getPreferredSize().height; return dim; } }; presenter2.setFont(presenter2.getFont().deriveFont(presenter1.getFont().getSize2D())); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.weighty = 1; c.anchor = GridBagConstraints.BELOW_BASELINE; c.fill = GridBagConstraints.NONE; add(presenter2, c); JLabel l = new JLabel(NbBundle.getMessage(DataSourceCaption.class, "DataSourceCaption_LBL_Reload")) { // NOI18N public Dimension getMinimumSize() { Dimension dim = super.getMinimumSize(); dim.height = super.getPreferredSize().height; return dim; } }; c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.weighty = 1; c.anchor = GridBagConstraints.BELOW_BASELINE; c.insets = new Insets(0, 16, 0, 0); c.fill = GridBagConstraints.NONE; add(l, c); JButton b = new JButton(NbBundle.getMessage(DataSourceCaption.class, "DataSourceCaption_BTN_Reload")) { // NOI18N public Dimension getMinimumSize() { Dimension dim = super.getMinimumSize(); dim.height = super.getPreferredSize().height; return dim; } // protected void fireActionPerformed(ActionEvent e) { // super.fireActionPerformed(e); // DataSourceWindowManager.sharedInstance().reopenDataSource(dataSource); // } }; c = new GridBagConstraints(); c.gridx = 3; c.gridy = 0; c.weighty = 0; c.anchor = GridBagConstraints.BELOW_BASELINE; c.insets = new Insets(0, 8, 0, 0); c.fill = GridBagConstraints.NONE; add(b, c); final Dimension fixedDim = new Dimension(0, getPreferredSize().height); JPanel spacer = new JPanel(null) { { setOpaque(false); } public Dimension getPreferredSize() { return fixedDim; } public Dimension getMinimumSize() { return fixedDim; } }; c = new GridBagConstraints(); c.gridx = 100; c.gridy = 0; c.weightx = 1; c.weighty = 1; c.anchor = GridBagConstraints.BELOW_BASELINE; c.fill = GridBagConstraints.HORIZONTAL; add(spacer, c); // fixedHeight = super.getPreferredSize().height; // fixedHeight = Math.max(presenter1.getPreferredSize().height, presenter2.getPreferredSize().height); // fixedHeight = Math.max(fixedHeight, new JButton(NbBundle.getMessage(DataSourceCaption.class, "DataSourceCaption_BTN_Reload")).getPreferredSize().height); setOpaque(false); remove(l); remove(b); } // public Dimension getPreferredSize() { // Dimension dim = super.getPreferredSize(); // dim.height = fixedHeight; // return dim; // } // // public Dimension getMinimumSize() { // Dimension dim = super.getMinimumSize(); // dim.height = fixedHeight; // return dim; // } // // public Dimension getMaximumSize() { // Dimension dim = super.getMaximumSize(); // dim.height = fixedHeight; // return dim; // } // // public Dimension getSize() { // Dimension dim = super.getSize(); // dim.height = fixedHeight; // return dim; // } private JLabel presenter1; private JLabel presenter2; private Timer busyIconTimer; private int busyIconIndex; // private int fixedHeight = -1; } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/package-info.java0000644000175000017500000000243313767155557025743 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * APIs for VisualVM UI. */ package org.graalvm.visualvm.core.ui; visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/PluggableDataSourceViewProvider.java0000644000175000017500000001477513767155557031656 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.snapshot.Snapshot; import org.graalvm.visualvm.core.ui.components.DataViewComponent; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; /** * Extensible DataSourceViewProvider with support for customizations via DataSourceViewPluginProvider. * * @author Jiri Sedlacek */ public abstract class PluggableDataSourceViewProvider extends DataSourceViewProvider { /** * Set defining all pluggable locations. */ public static final Set ALL_LOCATIONS; static { ALL_LOCATIONS = new HashSet(); ALL_LOCATIONS.add(DataViewComponent.TOP_LEFT); ALL_LOCATIONS.add(DataViewComponent.TOP_RIGHT); ALL_LOCATIONS.add(DataViewComponent.BOTTOM_LEFT); ALL_LOCATIONS.add(DataViewComponent.BOTTOM_RIGHT); } private final Set> pluginProviders = Collections.synchronizedSet(new HashSet()); private final Map>> pluginProvidersCache = Collections.synchronizedMap(new HashMap()); /** * Registers new DataSourceViewPluginProvider. * * @param pluginProvider DataSourceViewPluginProvider to register. */ public final void registerPluginProvider(DataSourceViewPluginProvider pluginProvider) { pluginProviders.add(pluginProvider); } /** * Unregisters DataSourceViewPluginProvider. * * @param pluginProvider DataSourceViewPluginProvider to unregister. */ public final void unregisterPluginProvider(DataSourceViewPluginProvider pluginProvider) { pluginProviders.remove(pluginProvider); } /** * Returns Set of all locations of the DataSourceView which can be customized by DataSourceViewPluginProviders. * * @param view DataSourceView to be customized. * @return Set of all locations of the DataSourceView which can be customized by DataSourceViewPluginProviders. */ public abstract Set getPluggableLocations(DataSourceView view); /** * Saves the DataSourceView for the DataSource into the Snapshot. * * @param dataSource DataSource for which to save the view. * @param snapshot Snapshot into which to save the view. */ protected void saveView(X dataSource, Snapshot snapshot) { }; void viewSaveView(X dataSource, Snapshot snapshot) { super.viewSaveView(dataSource, snapshot); Set> providers = getProviders(dataSource, false); for (DataSourceViewPluginProvider provider : providers) if (provider.supportsSavePluginFor(dataSource, snapshot.getClass())) provider.savePlugin(dataSource, snapshot); } void processCreatedComponent(DataSourceView view, DataViewComponent component) { X dataSource = (X)view.getDataSource(); Set> providers = getProviders(dataSource, true); for (DataSourceViewPluginProvider provider : providers) { Set pluggableLocations = getPluggableLocations(view); DataSourceViewPlugin plugin = provider.getPlugin(dataSource); for (int pluggableLocation : pluggableLocations) { DataViewComponent.DetailsView pluginView = plugin.createView(pluggableLocation); if (pluginView != null) component.addDetailsView(pluginView, pluggableLocation); } } } void viewWillBeAdded(DataSourceView view) { X dataSource = (X)view.getDataSource(); Set> providers = getProviders(dataSource, true); for (DataSourceViewPluginProvider provider : providers) provider.getPlugin(dataSource).pluginWillBeAdded(); } void viewAdded(DataSourceView view) { X dataSource = (X)view.getDataSource(); Set> providers = getProviders(dataSource, true); for (DataSourceViewPluginProvider provider : providers) provider.getPlugin(dataSource).pluginAdded(); } void viewRemoved(DataSourceView view) { X dataSource = (X)view.getDataSource(); Set> providers = getProviders(dataSource, true); for (DataSourceViewPluginProvider provider : providers) provider.getPlugin(dataSource).pluginRemoved(); pluginProvidersCache.remove(dataSource); super.viewRemoved(view); } private Set> getProviders(X dataSource, boolean cache) { Set> providers = pluginProvidersCache.get(dataSource); if (providers != null) return providers; providers = new HashSet(pluginProviders); Set> compatibleProviders = new HashSet(); for (DataSourceViewPluginProvider provider : providers) if (provider.supportsPluginFor(dataSource)) compatibleProviders.add(provider); if (cache) pluginProvidersCache.put(dataSource, compatibleProviders); return compatibleProviders; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceView.java0000644000175000017500000001750213767155557026307 0ustar apoapo/* * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Positionable; import org.graalvm.visualvm.core.ui.components.DataViewComponent; import java.awt.Image; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; /** * Definition of a subtab representing a concrete view of a DataSource in DataSource Window. * * @author Jiri Sedlacek */ public abstract class DataSourceView implements Positionable { protected static enum Alert { ERROR, WARNING, OK }; protected static final String ALERT_PROP = "Alert"; // NOI18N protected static final String ALERT_STRING_PROP = "Alert String"; // NOI18N private DataSource dataSource; private String name; private Image icon; private int preferredPosition; private boolean isClosable; private DataViewComponent component; private DataSourceViewProvider controller; private Alert alert; private String alertText; private PropertyChangeSupport propertyChangeSupport; /** * Creates new DataSourceView. * * Order of the notifications/queries is as follows: * willBeAdded() -> getView() -> added() -> removed() * * @param dataSource dataSource of the view * @param name name of the view as it appears in the subtab, * @param icon icon of the view as it appears in the subtab, * @param preferredPosition preferred position of the view among all other views for the DataSource, * @param isClosable true if the user is allowed to close the view, false otherwise. */ public DataSourceView(DataSource dataSource, String name, Image icon, int preferredPosition, boolean isClosable) { if (dataSource == null) throw new IllegalArgumentException("DataSource cannot be null"); // NOI18N if (name == null) throw new IllegalArgumentException("Name cannot be null"); // NOI18N if (icon == null) throw new IllegalArgumentException("Icon cannot be null"); // NOI18N this.dataSource = dataSource; this.name = name; this.icon = icon; this.preferredPosition = preferredPosition; this.isClosable = isClosable; propertyChangeSupport = new PropertyChangeSupport(this); } /** * Returns dataSource of the view. * * @return dataSource of the view. */ public final DataSource getDataSource() { return dataSource; } /** * Returns name of the view as it appears in the subtab. * * @return name of the view as it appears in the subtab. */ public final String getName() { return name; } /** * Returns icon of the view as it appears in the subtab. * * @return icon of the view as it appears in the subtab. */ public final Image getImage() { return icon; } /** * Returns DataViewComponent implementing the view. * Called from EDT. * * @return DataViewComponent implementing the view. */ protected abstract DataViewComponent createComponent(); /** * Returns preferred position of the view among all other views for the DataSource. * * @return preferred position of the view among all other views for the DataSource. */ public final int getPreferredPosition() { return preferredPosition; } /** * Returns true if the user is allowed to close the view, false otherwise. * * @return true if the user is allowed to close the view, false otherwise. */ public final boolean isClosable() { return isClosable; } protected void setAlert(Alert newAlert, String newText) { Alert oldAlert = alert; String oldText = newText; alert = newAlert; alertText = newText; propertyChangeSupport.firePropertyChange(ALERT_PROP, oldAlert, alert); propertyChangeSupport.firePropertyChange(ALERT_STRING_PROP, oldText, newText); } /** * Notification when the view is about to be added to DataSourceWindow. * This notification comes from a thread other than EDT and its main intention * is to provide a possibility to do some models inits before the actual UI is displayed. * This call is blocking (blocks opening the view, progress bar is shown) but long-running initializations should * still use separate thread and update the UI after the models are ready. */ protected void willBeAdded() { } /** * Notification when the view has been added to DataSourceWindow. * This notification comes from a thread other than EDT. */ protected void added() { } /** * Notification when the view is about to be either programmatically removed from tabbed pane or closed by the user by clicking the X. * This notification comes from the EDT thread and its main intention is to * provide a possibility to save any view data before the view is closed, if * needed. Long-running operations should use a separate thread to not block * EDT closing the view. */ protected void willBeRemoved() { } /** * Notification when the view has been either programatically removed from tabbed pane or closed by the user by clicking the X. * This notification comes from a thread other than EDT */ protected void removed() { } Alert getAlert() { return alert; } void addPropertyChangeListener(PropertyChangeListener l) { propertyChangeSupport.addPropertyChangeListener(l); } void removePropertyChangeListener(PropertyChangeListener l) { propertyChangeSupport.removePropertyChangeListener(l); } DataViewComponent getView() { if (component == null) { component = createComponent(); if (component == null) throw new NullPointerException("Null view component from " + this); // NOI18N controller.processCreatedComponent(this, component); } return component; } void viewWillBeAdded() { willBeAdded(); controller.viewWillBeAdded(this); } void viewAdded() { added(); controller.viewAdded(this); } private boolean willBeRemovedNotified; void viewWillBeRemoved() { if (willBeRemovedNotified) return; willBeRemoved(); willBeRemovedNotified = true; controller.viewWillBeRemoved(this); } void viewRemoved() { removed(); controller.viewRemoved(this); } void setController(DataSourceViewProvider controller) { this.controller = controller; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/DataSourceWindowManager.java0000644000175000017500000004421613767155557030141 0ustar apoapo/* * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.ui; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.SwingUtilities; import org.graalvm.visualvm.core.VisualVM; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; /** * Class responsible for DataSourceViews manipulation. * * @author Jiri Sedlacek */ public final class DataSourceWindowManager { private static final RequestProcessor processor = new RequestProcessor("DataSourceWindowManager Processor"); // NOI18N private static final Logger LOGGER = Logger.getLogger(DataSourceWindowManager.class.getName()); private static DataSourceWindowManager sharedInstance; private final Map> windowListeners = new WeakHashMap(); private final Map openedWindows = Collections.synchronizedMap(new HashMap()); private final Map> openedViews = Collections.synchronizedMap(new HashMap()); private final Runnable closingHandler; /** * Returns singleton instance of DataSourceWindowManager. * * @return singleton instance of DataSourceWindowManager. */ public static synchronized DataSourceWindowManager sharedInstance() { if (sharedInstance == null) sharedInstance = new DataSourceWindowManager(); return sharedInstance; } /** * Returns true if there is at least one provider providing at least one view for given DataSource, false otherwise. * * @param dataSource DataSource to open. * @return true if there is at least one provider providing at least one view for given DataSource, false otherwise. */ public boolean canOpenDataSource(DataSource dataSource) { return DataSourceViewsManager.sharedInstance().hasViewsFor(dataSource); } /** * Opens the DataSource and selects the view. * * @param dataSource DataSource to open */ public void openDataSource(final DataSource dataSource) { openDataSource(dataSource, true); } /** * Opens the DataSource and optionally selects the view. * * @param dataSource DataSource to open * @param selectView true if the view should be selected, false otherwise */ public void openDataSource(final DataSource dataSource, final boolean selectView) { processor.post(new Runnable() { public void run() { openDataSource(dataSource, selectView, 0); } }); } /** * Opens the DataSource and optionally selects the view. * * @param dataSource DataSource to open * @param selectView true if the view should be selected, false otherwise * @param viewIndex index of the view to select */ public void openDataSource(final DataSource dataSource, final boolean selectView, final int viewIndex) { processor.post(new Runnable() { public void run() { openWindowAndAddView(dataSource, null, viewIndex, selectView, selectView, selectView); } }); } /** * Checks whether the DataSource window is currently opened. * * @param dataSource DataSource to check * @return true if the DataSource window is currently opened, false otherwise. */ public boolean isDataSourceOpened(DataSource dataSource) { return openedWindows.get(dataSource) != null; } public void addWindowListener(D dataSource, DataSourceWindowListener listener) { synchronized (windowListeners) { List listeners = windowListeners.get(dataSource); if (listeners == null) { listeners = new ArrayList(); windowListeners.put(dataSource, listeners); } listeners.add(listener); } } public void removeWindowListener(D dataSource, DataSourceWindowListener listener) { synchronized (windowListeners) { List listeners = windowListeners.get(dataSource); if (listeners != null) listeners.remove(listener); } } private void notifyWindowOpened(D dataSource) { synchronized (windowListeners) { List listeners = windowListeners.get(dataSource); if (listeners != null) for (DataSourceWindowListener listener : new ArrayList(listeners)) listener.windowOpened(dataSource); } } private void notifyWindowClosed(D dataSource) { synchronized (windowListeners) { List listeners = windowListeners.get(dataSource); if (listeners != null) for (DataSourceWindowListener listener : new ArrayList(listeners)) listener.windowClosed(dataSource); } } /** * Closes the DataSource. * * @param dataSource DataSource to close. */ public void closeDataSource(final DataSource dataSource) { processor.post(new Runnable() { public void run() { // Resolve viewmaster DataSource viewMaster = getViewMaster(dataSource); // Resolve cached window final DataSourceWindow window = openedWindows.get(viewMaster); if (window == null) return; // Window not opened if (dataSource == viewMaster) { SwingUtilities.invokeLater(new Runnable() { public void run() { window.removeAllViews(); } }); } else { // Remove all views of the dataSource Set views = openedViews.get(dataSource); if (views != null) { final Set viewsF = new HashSet(views); SwingUtilities.invokeLater(new Runnable() { public void run() { for (DataSourceView view : viewsF) if (window.containsView(view)) window.removeView(view); } }); } } } }); } /** * Opens the DataSource if needed and selects the DataSourceView. * * @param view DataSourceView to select. */ public void selectView(final DataSourceView view) { processor.post(new Runnable() { public void run() { openWindowAndAddView(view.getDataSource(), view, 0, true, true, true); } }); } private boolean reloadingView; private void openWindowAndAddView(DataSource dataSource, DataSourceView view, int viewIndex, final boolean selectView, final boolean selectWindow, final boolean windowToFront) { // Resolve viewmaster final DataSource viewMaster = getViewMaster(dataSource); // Resolve cached window final DataSourceWindow[] window = new DataSourceWindow[1]; window[0] = openedWindows.get(viewMaster); final boolean wasOpened = window[0] != null; final ProgressHandle pHandle = !wasOpened || reloadingView ? ProgressHandleFactory.createHandle(NbBundle.getMessage(DataSourceWindowManager.class, "LBL_Opening", // NOI18N DataSourceDescriptorFactory.getDescriptor(dataSource).getName())) : null; try { // Viewmaster's window not cached (opened), create if (!wasOpened || reloadingView) { // Setup progress pHandle.setInitialDelay(0); pHandle.start(); if (!reloadingView) { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { window[0] = new DataSourceWindow(viewMaster); } }); } catch (Exception e) { LOGGER.severe("Failed to create window for " + dataSource); // NOI18N } openedWindows.put(viewMaster, window[0]); } else { reloadingView = false; } List views = DataSourceViewsManager.sharedInstance().getViews(viewMaster); addViews(window[0], views); } // Viewmaster opened, add views for the dataSource if (dataSource != viewMaster) { List views = DataSourceViewsManager.sharedInstance().getViews(dataSource); addViews(window[0], views); if (selectView && view == null && viewIndex >= 0) { if (viewIndex >= views.size()) viewIndex = -1; if (viewIndex != -1) view = views.get(viewIndex); } } // Resolve view to select if (selectView && view == null && viewIndex > 0) { List views = window[0].getViews(); if (viewIndex >= views.size()) viewIndex = -1; if (viewIndex != -1) view = views.get(viewIndex); } // Open window final DataSourceView viewToSelectF = selectView ? view : null; SwingUtilities.invokeLater(new Runnable() { public void run() { if (viewToSelectF != null) { if (window[0].containsView(viewToSelectF)) { window[0].selectView(viewToSelectF); } else { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Tried to select not opened view " + viewToSelectF); // NOI18N } } } if (!wasOpened) window[0].open(); if (selectWindow) window[0].requestActive(); if (windowToFront) window[0].toFront(); if (!wasOpened) notifyWindowOpened(dataSource); } }); } finally { SwingUtilities.invokeLater(new Runnable() { public void run() { if (pHandle != null) pHandle.finish(); } }); } } static DataSource getViewMaster(DataSource dataSource) { DataSource master = dataSource.getMaster(); while (master != null && master != DataSource.ROOT) { dataSource = master; master = dataSource.getMaster(); } return dataSource; } private void addViews(final DataSourceWindow window, final List views) { // Compute views to add final List newViews = new ArrayList(); for (X view : views) if (!window.containsView(view)) newViews.add(view); // Blocking notification that the view will be added for (DataSourceView view : newViews) { try { DataSource dataSource = view.getDataSource(); Set cachedViews = openedViews.get(dataSource); if (cachedViews == null) { cachedViews = new HashSet(); openedViews.put(dataSource, cachedViews); } cachedViews.add(view); view.viewWillBeAdded(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to pre-initialize view " + view, e); // NOI18N } } try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { // Blocking adding of views to the window for (DataSourceView view : newViews) { try { window.addView(view); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to initialize view " + view, e); // NOI18N } } } }); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to initialize views for " + window.getDataSource(), e); // NOI18N } // Blocking notification that the view has been added for (DataSourceView view : newViews) { try { view.viewAdded(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to post-initialize view " + view, e); // NOI18N } } } void reopenDataSource(final DataSource dataSource) { processor.post(new Runnable() { public void run() { DataSource viewMaster = getViewMaster(dataSource); final DataSourceWindow window = viewMaster == null ? null : openedWindows.get(viewMaster); if (window == null) return; Set _views = openedViews.get(dataSource); if (_views == null) return; final Map oldViews = new HashMap(); for (DataSourceView view : _views) oldViews.put(view.getName(), view); SwingUtilities.invokeLater(new Runnable () { public void run() { final Set opened = openedViews.get(dataSource); for (DataSourceView view : oldViews.values()) { window.clearView(view, processor); opened.remove(view); } processor.post(new Runnable() { public void run() { final List newViews = DataSourceViewsManager.sharedInstance().getViews(dataSource); for (DataSourceView view : newViews) { opened.add(view); try { view.viewWillBeAdded(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to pre-initialize view " + view, e); } // NOI18N oldViews.remove(view.getName()); } if (opened.isEmpty()) openedViews.remove(dataSource); SwingUtilities.invokeLater(new Runnable() { public void run() { for (DataSourceView view : oldViews.values()) window.closeUnregisteredView(view); for (int i = 0; i < newViews.size(); i++) window.updateView(newViews.get(i), i); } }); } }); } }); } }); } void unregisterClosedWindow(DataSourceWindow window) { DataSource dataSource = window.getDataSource(); openedWindows.remove(dataSource); notifyWindowClosed(dataSource); } void unregisterClosedView(DataSourceView view) { DataSource dataSource = view.getDataSource(); Set views = openedViews.get(dataSource); if (views != null) { views.remove(view); if (views.isEmpty()) openedViews.remove(dataSource); } else if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Tried to unregister not opened view " + view); // NOI18N } } private DataSourceWindowManager() { closingHandler = new Runnable() { public void run() { Collection> allViews = openedViews.values(); for (Set dataSourceViews : allViews) for (DataSourceView view : dataSourceViews) view.viewWillBeRemoved(); } }; VisualVM.getInstance().notifyWhenClosing(closingHandler); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/ui/Bundle.properties0000644000175000017500000000255613767155557026111 0ustar apoapo# # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. LBL_Opening=Opening {0}... DataSourceCaption_LBL_Reload=The view is not up to date, click to reload obsolete data\: DataSourceCaption_BTN_Reload=Reload DataSourceCaption_MSG_Reloading=Reloading view... visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/scheduler/0000755000175000017500000000000013767155557024113 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/scheduler/Quantum.java0000644000175000017500000000717013767155557026415 0ustar apoapo/* * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; import java.util.concurrent.TimeUnit; /** * This class {@linkplain TimeUnit} and provides easy conversion and comparation * between various units * @author Jaroslav Bachorik */ public class Quantum { final public static Quantum SUSPENDED = new Quantum(TimeUnit.NANOSECONDS, -1); /** * Read-only field - the {@linkplain TimeUnit} used in the Quantum */ final public TimeUnit unit; /** * Read-only field - the interval */ final public int interval; /** * Sets-up a new quantum * @param unit The {@linkplain TimeUnit} to use * @param interval The interval */ public Quantum(TimeUnit unit, int interval) { this.unit = unit; this.interval = interval; } /** * Factory method - creates a new quantum given the number of seconds * @param interval The number of seconds * @return Returns new instance of {@linkplain Quantum} */ public static Quantum seconds(int interval) { return new Quantum(TimeUnit.SECONDS, interval); } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Quantum other = (Quantum) obj; if (this.getNanos() != other.getNanos()) { return false; } return true; } @Override public int hashCode() { return (int)(getNanos() % 321721); } private long getNanos() { long multiplier = 1; switch(unit) { case MICROSECONDS: { multiplier = 1000; break; } case MILLISECONDS: { multiplier = 1000 * 1000; break; } case SECONDS: { multiplier = 1000 * 1000 * 1000; break; } case MINUTES: { multiplier = 60 * 1000 * 1000 * 1000; break; } case HOURS: { multiplier = 60 * 60 * 1000 * 1000 * 1000; break; } case DAYS: { multiplier = 24 * 60 * 1000 * 1000 * 1000; break; } } return interval * multiplier; } @Override public String toString() { return interval + unit.toString(); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/scheduler/SchedulingPipe.java0000644000175000017500000001302213767155557027657 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; import java.lang.ref.WeakReference; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.logging.Level; import java.util.logging.Logger; /** * Scheduling pipe maintains a list of {@linkplain ScheduledTask} instances * for a certain scheduling interval *

It allows addition and removal of the tasks and takes care of creating * and releasing appropriate scheduled executors

* * @author Jaroslav Bachorik */ final class SchedulingPipe { private static final Logger LOGGER = Logger.getLogger(SchedulingPipe.class.getName()); final private Object pipeLock = new Object(); final private ReadWriteLock tasksLock = new ReentrantReadWriteLock(); // @GuardedBy pipeLock private ScheduledFuture pipeFuture = null; final private static ScheduledExecutorService schedulerService = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors()); final private static ExecutorService dispatcher = Executors.newCachedThreadPool(); // @GuardedBy tasksLock final private Set> tasks = new HashSet>(); private Quantum interval; SchedulingPipe(Quantum interval) { this.interval = interval; } void addTask(DefaultScheduledTask task) { tasksLock.writeLock().lock(); try { if (tasks.isEmpty()) { startPipe(); } tasks.add(new WeakReference(task)); } finally { tasksLock.writeLock().unlock(); } } private void startPipe() { synchronized (pipeLock) { pipeFuture = schedulerService.scheduleAtFixedRate(new Runnable() { public void run() { tasksLock.writeLock().lock(); try { final long timeStamp = System.currentTimeMillis(); for (Iterator> iter = tasks.iterator(); iter.hasNext();) { WeakReference ref = iter.next(); final DefaultScheduledTask t = ref.get(); if (t != null) { dispatcher.submit(new Runnable() { public void run() { try { t.onSchedule(timeStamp); } catch (Throwable e) { LOGGER.log(Level.SEVERE, null, e); } } }); } else { iter.remove(); } } if (tasks.isEmpty()) { synchronized (pipeLock) { pipeFuture.cancel(false); pipeFuture = null; } } } finally { tasksLock.writeLock().unlock(); } } }, interval.interval, interval.interval, interval.unit); } } void removeTask(DefaultScheduledTask task) { tasksLock.writeLock().lock(); try { for(Iterator> iter = tasks.iterator();iter.hasNext();) { WeakReference ref = iter.next(); DefaultScheduledTask t = ref.get(); if (t == null || t.equals(task)) { iter.remove(); } } } finally { tasksLock.writeLock().unlock(); } if (tasks.isEmpty()) { synchronized(pipeLock) { pipeFuture.cancel(false); pipeFuture = null; } } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/scheduler/package-info.java0000644000175000017500000000275713767155557027315 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Support for executing scheduled tasks in given intervals synchronously * Eg. all tasks scheduled to execute in 5 minutes interval will be executed * in one batch once the interval times-out, thus receiving the same timestamp */ package org.graalvm.visualvm.core.scheduler; visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/scheduler/Scheduler.java0000644000175000017500000001077413767155557026705 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.logging.Logger; /** * An interval based scheduler service * Used to execute various tasks at the predefined interval * There is supposed to be only one instance of this class accesible vie getSharedInstance() * @author Jaroslav Bachorik */ public class Scheduler { //~ Static fields/initializers ----------------------------------------------------------------------------------------------- private static final Logger LOGGER = Logger.getLogger(Scheduler.class.getName()); private static final Scheduler INSTANCE = new Scheduler(); //~ Instance fields ---------------------------------------------------------------------------------------------------------- private final ExecutorService immediateTaskService = Executors.newCachedThreadPool(); //~ Constructors ------------------------------------------------------------------------------------------------------------- private Scheduler() { } //~ Methods ------------------------------------------------------------------------------------------------------------------ /** * Singleton accessor * @return Returns the shared instance of scheduler service */ public static final Scheduler sharedInstance() { return INSTANCE; } /** * Schedules a new task to be executed with the given interval * The newly scheduled task is exeucted out-of-order at the moment of scheduling it * This operation's result should be cached by the caller;otherwise the task will get unscheduled immediately * @param task The task to be executed * @param interval The interval to execute the task * @return Returns an instance of ScheduledTask that can be used to later modify the interval of execution */ public final ScheduledTask schedule(SchedulerTask task, Quantum interval) { return schedule(task, interval, true); } /** * Schedules a new task to be executed with the given interval * This operation's result should be cached by the caller;otherwise the task will get unscheduled immediately * @param task The task to be executed * @param interval The interval to execute the task * @param immediate Tells whether the newly scheduled task is exeucted out-of-order at the moment of scheduling it * @return Returns an instance of ScheduledTask that can be used to later modify the interval of execution */ public final ScheduledTask schedule(final SchedulerTask task, final Quantum interval, boolean immediate) { boolean suspended = interval.equals(Quantum.SUSPENDED); if (immediate && !suspended) { immediateTaskService.submit(new Runnable() { public void run() { task.onSchedule(System.currentTimeMillis()); } }); } DefaultScheduledTask scheduled = new DefaultScheduledTask(interval, task); return scheduled; } /** * Unschedules an instance of Scheduled class * @param task The task to be unscheduled */ public final void unschedule(final ScheduledTask task) { if (task == null) return; task.suspend(); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/scheduler/ScheduledTask.java0000644000175000017500000000465313767155557027511 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; /** * A task scheduled within the Scheduler service * @author Jaroslav Bachorik */ public interface ScheduledTask { //~ Static fields/initializers ----------------------------------------------------------------------------------------------- /** * Property-change support */ public static final String INTERVAL_PROPERTY = "Task.Interval"; // NOI18N //~ Methods ------------------------------------------------------------------------------------------------------------------ /** * Modifies the interval the task is scheduled to run at * @param quantum The new interval */ void setInterval(Quantum quantum); /** * The interval the task is scheduled to run at * @return Returns the number of seconds between two runs */ Quantum getInterval(); /** * Suspends the task * A shortcut to calling setInterval(Quantum.SUSPENDED) */ void suspend(); /** * Resumes a previously suspended task */ void resume(); /** * Indicates the suspension status of the task * @return Returns the suspension status of the task */ boolean isSuspended(); } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/scheduler/DefaultScheduledTask.java0000644000175000017500000001466313767155557031020 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.Map; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; /** * A default implementation of the ScheduledTask * @author Jaroslav Bachorik */ class DefaultScheduledTask implements ScheduledTask, SchedulerTask { static private final Map> pipeMap = new HashMap>(); //~ Instance fields ---------------------------------------------------------------------------------------------------------- private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); private final ReadWriteLock intervalLock = new ReentrantReadWriteLock(); // @GuardedBy intervalLock private Quantum interval; private SchedulerTask delegateTask; private Quantum suspendedFrom = Quantum.SUSPENDED; private SchedulingPipe pipe = null; //~ Constructors ------------------------------------------------------------------------------------------------------------- public DefaultScheduledTask(Quantum interval, SchedulerTask task) { delegateTask = task; setInterval(interval); } //~ Methods ------------------------------------------------------------------------------------------------------------------ /** * @see org.graalvm.visualvm.core.scheduler.ScheduledTask#setInterval(Quantum) */ public void setInterval(Quantum interval) { intervalLock.writeLock().lock(); Quantum oldInterval = interval; try { oldInterval = this.interval; synchronized(pipeMap) { WeakReference oldPipeRef = pipeMap.get(oldInterval); WeakReference newPipeRef = pipeMap.get(interval); SchedulingPipe oldPipe = oldPipeRef != null ? oldPipeRef.get() : null; SchedulingPipe newPipe = newPipeRef != null ? newPipeRef.get() : null; if (oldPipe != null) { oldPipe.removeTask(this); } if (newPipe == null && interval != Quantum.SUSPENDED) { newPipe = new SchedulingPipe(interval); pipeMap.put(interval, new WeakReference(newPipe)); } if (newPipe != null) { newPipe.addTask(this); } } this.interval = interval; } finally { intervalLock.writeLock().unlock(); } pcs.firePropertyChange(INTERVAL_PROPERTY, oldInterval, interval); } /** * @see org.graalvm.visualvm.core.scheduler.ScheduledTask#getInterval() */ public Quantum getInterval() { intervalLock.readLock().lock(); try { return interval; } finally { intervalLock.readLock().unlock(); } } /** * @see PropertyChangeSupport#addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) */ public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { pcs.addPropertyChangeListener(propertyName, listener); } /** * @see PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener) */ public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { pcs.addPropertyChangeListener(listener); } /** * @see PropertyChangeSupport#hasListeners(java.lang.String) */ public synchronized boolean hasListeners(String propertyName) { return pcs.hasListeners(propertyName); } /** * @see PropertyChangeSupport#removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) */ public synchronized void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { pcs.removePropertyChangeListener(propertyName, listener); } /** * @see PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener) */ public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { pcs.removePropertyChangeListener(listener); } /** * @see org.graalvm.visualvm.core.scheduler.ScheduledTask#suspend() */ public void suspend() { if (suspendedFrom.equals(Quantum.SUSPENDED)) suspendedFrom = getInterval(); setInterval(Quantum.SUSPENDED); } /** * @see ScheduledTask#resume() */ public void resume() { setInterval(suspendedFrom); suspendedFrom = Quantum.SUSPENDED; } /** * @see ScheduledTask#isSuspended() */ public boolean isSuspended() { return interval.equals(Quantum.SUSPENDED); } /** * @see org.graalvm.visualvm.core.scheduler.SchedulerTask#onSchedule(long) */ public void onSchedule(long timeStamp) { delegateTask.onSchedule(timeStamp); } void setPipe(SchedulingPipe pipe) { this.pipe = pipe; } SchedulingPipe getPipe() { return pipe; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/scheduler/SchedulerTask.java0000644000175000017500000000327413767155557027525 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.scheduler; /** * This interface represents a task that is accepted by the Scheduler service * @author Jaroslav Bachorik */ public interface SchedulerTask { //~ Methods ------------------------------------------------------------------------------------------------------------------ /** * Scheduler notification * @param timeStamp The timestamp of the moment the notification has been created */ void onSchedule(long timeStamp); } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/Install.java0000644000175000017500000000447713767155557024422 0ustar apoapo/* * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core; import org.graalvm.visualvm.core.datasource.DataSourceRepository; import org.graalvm.visualvm.core.datasource.Storage; import org.graalvm.visualvm.core.datasupport.Utils; import org.graalvm.visualvm.core.snapshot.SnapshotsSupport; import java.io.File; import org.openide.modules.ModuleInstall; /** * * @author Jiri Sedlacek */ class Install { // Class implementing logic on VisualVM module install public static class Impl extends ModuleInstall { @Override public boolean closing() { return VisualVM.getInstance().closing(); } @Override public void restored() { // NOTE: this has to be called before any of DataSourceProviders initializes cleanupPreviousSession(); DataSourceRepository.sharedInstance(); // Initialize snapshots SnapshotsSupport.getInstance(); } private void cleanupPreviousSession() { File temporaryStorage = new File(Storage.getTemporaryStorageDirectoryString()); Utils.delete(temporaryStorage, false); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/model/0000755000175000017500000000000013767155557023235 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/model/ModelCache.java0000644000175000017500000001317013767155557026066 0ustar apoapo/* * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.model; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.lang.ref.Reference; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Stateful; /** * * @author Tomas Hurka */ final class ModelCache { private final static Logger LOGGER = Logger.getLogger(ModelFactory.class.getName()); /** * special marker for null model */ final ModelReference NULL_MODEL; private final Map, ModelReference> modelCache; ModelCache() { modelCache = Collections.synchronizedMap(new HashMap()); NULL_MODEL = new ModelReference(null, 0); } Reference get(DataSourceKey key) { ModelReference valueRef = modelCache.get(key); if (valueRef != null && valueRef.modCount < key.modCount) { Reference removed = modelCache.remove(key); LOGGER.finer("Invalid mod count " + key + " " + (removed != null ? "removed" : "not removed")); return null; } return valueRef; } Reference put(DataSourceKey key, M value) { ModelReference ref; DataSource ds = key.weakReference.get(); if (ds instanceof Stateful && value != null) { ds.addPropertyChangeListener(Stateful.PROPERTY_STATE, new StateListener(key)); LOGGER.finer("Registered listener for " + key + " val " + value.getClass()); } if (value == null) { ref = NULL_MODEL; } else { ref = new ModelReference(value, key.modCount); } return modelCache.put(key, ref); } void clear() { modelCache.clear(); } /** * DataSource wrapper object, which weakly reference datasource and uses * reference-equality of DataSources when implementing hashCode and equals * this class is used as keys in modelCache */ static class DataSourceKey { Reference weakReference; int modCount; DataSourceKey(D ds) { weakReference = new WeakReference(ds); if (ds instanceof Stateful) { modCount = ((Stateful) ds).getModCount(); } } public int hashCode() { D ds = weakReference.get(); if (ds != null) { return ds.hashCode(); } return 0; } public boolean equals(Object obj) { if (obj == null) { return false; } if (obj instanceof DataSourceKey) { D ds = weakReference.get(); D otherDs = ((DataSourceKey) obj).weakReference.get(); return ds != null && ds == otherDs; } throw new IllegalArgumentException(obj.getClass().getName()); } public String toString() { DataSource ds = weakReference.get(); return "DataSourceKey for " + System.identityHashCode(this) + " for " + ds == null ? "NULL" : ds.toString(); // NOI18N } } private static class ModelReference extends SoftReference { private int modCount; private ModelReference(T ref, int count) { super(ref); modCount = count; } } private class StateListener implements PropertyChangeListener { DataSourceKey key; StateListener(DataSourceKey k) { key = k; } @Override public void propertyChange(PropertyChangeEvent evt) { int newState = (Integer) evt.getNewValue(); if (newState == Stateful.STATE_AVAILABLE) { DataSource ds = key.weakReference.get(); if (ds != null) { ds.removePropertyChangeListener(Stateful.PROPERTY_STATE, this); } if (ds == null || key.modCount < ((Stateful)ds).getModCount()) { Reference removed = modelCache.remove(key); LOGGER.finer(key + " " + (removed != null ? "removed" : "not removed")); } else { LOGGER.finer(key + " newer model found"); } } } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/model/AbstractModelProvider.java0000644000175000017500000000360413767155557030342 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.model; import org.graalvm.visualvm.core.datasource.DataSource; /** * Abstract class, which simplifies implementation of {@link ModelProvider}. * It uses class hierarchy to compute priority of providers. * @author Tomas Hurka */ public abstract class AbstractModelProvider implements ModelProvider { /** * {@inheritDoc} */ public abstract M createModelFor(B app); public int priority() { int depth = 1; Class cls = getClass(); for (;!cls.equals(AbstractModelProvider.class);cls=cls.getSuperclass()) { depth++; } return depth; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/model/package-info.java0000644000175000017500000000252513767155557026430 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * This package provides generic support for attaching Model to DataSource. * */ package org.graalvm.visualvm.core.model; visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/model/Model.java0000644000175000017500000000275713767155557025153 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.model; import org.graalvm.visualvm.core.datasource.DataSource; /** * This abstract class which serves as root object for * all models attached to {@link DataSource} instances * using {@link ModelFactory}. * @author Tomas Hurka */ public abstract class Model { } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/model/ModelFactory.java0000644000175000017500000002073213767155557026474 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.model; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.ClassNameComparator; import org.graalvm.visualvm.core.datasupport.DataChangeListener; import org.graalvm.visualvm.core.datasupport.DataChangeSupport; import java.lang.ref.Reference; import java.util.Collections; import java.util.Comparator; import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.logging.Logger; import org.graalvm.visualvm.core.model.ModelCache.DataSourceKey; /** * This is abstract factory class for getting model * for datasource. It as two functions. First it serves * as cache for the model associated with datasource. * Second, ModelFactory uses list of ModelProviders registered * via {@link #registerProvider(ModelProvider )} to * determine the order of in which they are consulted * to obtain the model for dataSource. First model * obtained from ModelProvider is associated with * dataSource and returned in the future. * @author Tomas Hurka */ public abstract class ModelFactory { final protected static Logger LOGGER = Logger.getLogger(ModelFactory.class.getName()); /** set of registered providers */ private SortedSet> providers; /** providers cannot be changed, when getModel() is running */ private ReadWriteLock providersLock; /** model cache */ private ModelCache modelCache; /** asynchronous change support */ private DataChangeSupport> factoryChange; protected ModelFactory() { providers = new TreeSet(new ModelProviderComparator()); modelCache = new ModelCache(); factoryChange = new DataChangeSupport(); providersLock = new ReentrantReadWriteLock(); } /** * Returns model for dataSource. If model is in the cache * return it, otherwise consult registered ModelProviders. * @param dataSource {@link DataSource} for which {@link Model} should be returned * @return model for dataSource or null * if there is not model associated with this dataSource. */ public final M getModel(D dataSource) { // take a read lock for providers Lock rlock = providersLock.readLock(); rlock.lock(); try { // allow concurrent access to cache for different instances of DataSource // note that DataSourceKey uses reference-equality in place of object-equality // for DataSource synchronized (dataSource) { DataSourceKey key = new DataSourceKey(dataSource); Reference modelRef = modelCache.get(key); M model = null; if (modelRef != null) { if (modelRef == modelCache.NULL_MODEL) { // cached null model, return null return null; } model = modelRef.get(); // if model is in cache return it, if (model != null) { // otherwise get it from providers return model; } } // try to get model from registered providers for (ModelProvider factory : providers) { model = factory.createModelFor(dataSource); if (model != null) { // we have model, put it into cache modelCache.put(key,model); break; } } if (model == null) { // model was not found - cache null model modelCache.put(key,null); } return model; } } finally { rlock.unlock(); } } /** * register new {@link ModelProvider}. * Model provider can be registered only once. * @param newProvider to register * @return true if this ModelFactory does not contain registered provider. */ public final boolean registerProvider(ModelProvider newProvider) { // take a write lock on providers Lock wlock = providersLock.writeLock(); wlock.lock(); try { LOGGER.finer("Registering " + newProvider.getClass().getName()); // NOI18N boolean added = providers.add(newProvider); if (added) { modelCache.clear(); factoryChange.fireChange(providers,Collections.singleton(newProvider),null); } return added; } finally { wlock.unlock(); } } /** * Unregister {@link ModelProvider}. * @param oldProvider provider, which should be unregistered * @return true if provider was unregistered. */ public final boolean unregisterProvider(ModelProvider oldProvider) { // take a write lock on providers Lock wlock = providersLock.writeLock(); wlock.lock(); try { LOGGER.finer("Unregistering " + oldProvider.getClass().getName()); // NOI18N boolean removed = providers.remove(oldProvider); if (removed) { modelCache.clear(); factoryChange.fireChange(providers,null,Collections.singleton(oldProvider)); } return removed; } finally { wlock.unlock(); } } /** * Add data change listener. Data change is fired when * {@link ModelProvider} is registered/unregister. * @param listener {@link DataChangeListener} to be added */ public final void addFactoryChangeListener(DataChangeListener> listener) { factoryChange.addChangeListener(listener); } /** * Remove data change listener. * @param listener {@link DataChangeListener} to be removed */ public final void removeFactoryChangeListener(DataChangeListener> listener) { factoryChange.removeChangeListener(listener); } /** * Default priority. Subclass of ModelFactory can implement * {@link ModelProvider}. In that case such provider should be * used as last provider. This is ensured by returning -1, since * providers, which subclass {@link AbstractModelProvider}, return * positive numbers. * @return -1 */ public int priority() { return -1; } /** compare ModelProvider-s using priority. Providers with higher priority * gets precedence over those with lower priority */ private class ModelProviderComparator implements Comparator> { public int compare(ModelProvider provider1, ModelProvider provider2) { int thisVal = provider1.priority(); int anotherVal = provider2.priority(); if (thisValanotherVal) { return -1; } // same depth -> use class name to create artifical ordering return ClassNameComparator.INSTANCE.compare(provider1, provider2); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/model/ModelProvider.java0000644000175000017500000000463113767155557026657 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.model; import org.graalvm.visualvm.core.datasource.DataSource; /** * This interface should be implemented if you want to extend ModelFactory * with your own provider. Implementors of this ModelProvider inteface * should be registered with appropriate {@link ModelFactory} using * {@link ModelFactory#registerProvider(ModelProvider)} * @author Tomas Hurka */ public interface ModelProvider { /** * This is factory method for creating new instance * of Model for DataSource. Implementation of this method * should return null if this model provider * cannot construct model for passed dataSource. * @param dataSource {@link DataSource} for which {@link Model} should be created * @return model subclass for dataSource */ M createModelFor(B dataSource); /** * Priority is used by {@link ModelFactory} to sort registered * {@link ModelProvider}. Model provider with the highest priority * will be invoked first and so no, until non-null value * is returned from {@link #createModelFor(DataSource )} * @return priority of this ModelProvider */ int priority(); } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/0000755000175000017500000000000013767155557023630 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/GeneralOptionsPanel.java0000644000175000017500000004365113767155557030415 0ustar apoapo/* * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.options; import org.graalvm.visualvm.core.ui.components.SectionSeparator; import org.graalvm.visualvm.core.ui.components.Spacer; import org.graalvm.visualvm.uisupport.JExtendedSpinner; import java.awt.BorderLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.graalvm.visualvm.lib.profiler.api.ProfilerIDESettings; import org.openide.awt.Mnemonics; import org.openide.util.NbBundle; /** * * @author Jaroslav Bachorik * @author Jiri Sedlacek */ final class GeneralOptionsPanel extends JPanel { private final GeneralOptionsPanelController controller; transient private final ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { controller.changed(); } }; GeneralOptionsPanel(GeneralOptionsPanelController controller) { this.controller = controller; initComponents(); startTrackingChanges(); } private void initComponents() { GridBagConstraints c; setLayout(new GridBagLayout()); // --- Polling --- SectionSeparator pollingSection = UISupport.createSectionSeparator(NbBundle.getMessage (GeneralOptionsPanel.class, "LBL_Polling")); // NOI18N c = new GridBagConstraints(); c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(0, 0, 5, 0); add(pollingSection, c); monitoredHostPLabel = new JLabel(); Mnemonics.setLocalizedText(monitoredHostPLabel, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_Monitored_Host")); // NOI18N c = new GridBagConstraints(); c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 15, 3, 0); add(monitoredHostPLabel, c); monitoredHostPSpinner = new JExtendedSpinner(); monitoredHostPLabel.setLabelFor(monitoredHostPSpinner); monitoredHostPSpinner.setModel(new SpinnerNumberModel(3, 1, 99999, 1)); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 40, 3, 4); add(monitoredHostPSpinner, c); monitoredHostPUnits = new JLabel(); Mnemonics.setLocalizedText(monitoredHostPUnits, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_Sec")); // NOI18N c = new GridBagConstraints(); c.gridx = 2; c.gridy = 1; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 0, 3, 0); add(monitoredHostPUnits, c); threadsPLabel = new JLabel(); Mnemonics.setLocalizedText(threadsPLabel, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_Threads")); // NOI18N c = new GridBagConstraints(); c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 15, 3, 0); add(threadsPLabel, c); threadsPSpinner = new JExtendedSpinner(); threadsPLabel.setLabelFor(threadsPSpinner); threadsPSpinner.setModel(new SpinnerNumberModel(1, 1, 99999, 1)); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 40, 3, 4); add(threadsPSpinner, c); threadsPUnits = new JLabel(); Mnemonics.setLocalizedText(threadsPUnits, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_Sec")); // NOI18N c = new GridBagConstraints(); c.gridx = 2; c.gridy = 2; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 0, 3, 0); add(threadsPUnits, c); monitoredDataPLabel = new JLabel(); Mnemonics.setLocalizedText(monitoredDataPLabel, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_Monitored_Data")); // NOI18N c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 15, 3, 0); add(monitoredDataPLabel, c); monitoredDataPSpinner = new JExtendedSpinner(); monitoredDataPLabel.setLabelFor(monitoredDataPSpinner); monitoredDataPSpinner.setModel(new SpinnerNumberModel(1, 1, 99999, 1)); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 3; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 40, 3, 4); add(monitoredDataPSpinner, c); monitoredDataPUnits = new JLabel(); Mnemonics.setLocalizedText(monitoredDataPUnits, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_Sec")); // NOI18N c = new GridBagConstraints(); c.gridx = 2; c.gridy = 3; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 0, 3, 0); add(monitoredDataPUnits, c); // --- Charts cache --- SectionSeparator chartsCacheSection = UISupport.createSectionSeparator(NbBundle.getMessage (GeneralOptionsPanel.class, "LBL_Charts_Cache")); // NOI18N c = new GridBagConstraints(); c.gridy = 4; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(15, 0, 5, 0); add(chartsCacheSection, c); monitoredHostCLabel = new JLabel(); Mnemonics.setLocalizedText(monitoredHostCLabel, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_Monitored_Host2")); // NOI18N c = new GridBagConstraints(); c.gridx = 0; c.gridy = 5; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 15, 3, 0); add(monitoredHostCLabel, c); monitoredHostCSpinner = new JExtendedSpinner(); monitoredHostCLabel.setLabelFor(monitoredHostCSpinner); monitoredHostCSpinner.setModel(new SpinnerNumberModel(60, 1, 99999, 1)); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 5; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 40, 3, 4); add(monitoredHostCSpinner, c); monitoredHostCUnits = new JLabel(); Mnemonics.setLocalizedText(monitoredHostCUnits, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_min")); // NOI18N c = new GridBagConstraints(); c.gridx = 2; c.gridy = 5; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 0, 3, 0); add(monitoredHostCUnits, c); monitoredDataCLabel = new JLabel(); Mnemonics.setLocalizedText(monitoredDataCLabel, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_Monitored_Data2")); // NOI18N c = new GridBagConstraints(); c.gridx = 0; c.gridy = 6; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 15, 3, 0); add(monitoredDataCLabel, c); monitoredDataCSpinner = new JExtendedSpinner(); monitoredDataCLabel.setLabelFor(monitoredDataCSpinner); monitoredDataCSpinner.setModel(new SpinnerNumberModel(60, 1, 99999, 1)); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 6; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 40, 3, 4); add(monitoredDataCSpinner, c); monitoredDataCUnits = new JLabel(); Mnemonics.setLocalizedText(monitoredDataCUnits, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_min")); // NOI18N c = new GridBagConstraints(); c.gridx = 2; c.gridy = 6; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(3, 0, 3, 0); add(monitoredDataCUnits, c); // --- Finished Apps --- SectionSeparator appsSection = UISupport.createSectionSeparator(NbBundle.getMessage (GeneralOptionsPanel.class, "LBL_FinishedApps")); // NOI18N c = new GridBagConstraints(); c.gridy = 7; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(15, 0, 5, 0); add(appsSection, c); JLabel appsLabel = new JLabel(); Mnemonics.setLocalizedText(appsLabel, NbBundle.getMessage( GeneralOptionsPanel.class, "MSG_FinishedApps")); // NOI18N c = new GridBagConstraints(); c.gridy = 8; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(6, 15, 6, 0); add(appsLabel, c); JPanel appsPanel = new JPanel(null); appsPanel.setLayout(new BoxLayout(appsPanel, BoxLayout.LINE_AXIS)); finishedAppsOpen = new JCheckBox(); Mnemonics.setLocalizedText(finishedAppsOpen, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_FinishedAppsOpened")); // NOI18N appsPanel.add(finishedAppsOpen); appsPanel.add(Box.createHorizontalStrut(10)); finishedAppsSnapshots = new JCheckBox(); Mnemonics.setLocalizedText(finishedAppsSnapshots, NbBundle.getMessage( GeneralOptionsPanel.class, "LBL_FinishedAppsSnapshot")); // NOI18N appsPanel.add(finishedAppsSnapshots); c = new GridBagConstraints(); c.gridy = 9; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(2, 15, 2, 0); add(appsPanel, c); // --- Misc --- SectionSeparator profilerSection = UISupport.createSectionSeparator(NbBundle.getMessage (GeneralOptionsPanel.class, "LBL_Miscellaneous")); // NOI18N c = new GridBagConstraints(); c.gridy = 10; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(15, 0, 5, 0); add(profilerSection, c); JPanel resetDNSAPanel = new JPanel(new BorderLayout()); resetDNSALabel = new JLabel(); Mnemonics.setLocalizedText(resetDNSALabel, NbBundle.getMessage( GeneralOptionsPanel.class, "MSG_Do_Not_Show_Again")); // NOI18N resetDNSAPanel.add(resetDNSALabel, BorderLayout.CENTER); resetDNSAButton = new JButton(); Mnemonics.setLocalizedText(resetDNSAButton, NbBundle.getMessage( GeneralOptionsPanel.class, "BTN_Reset")); // NOI18N resetDNSAPanel.add(resetDNSAButton, BorderLayout.EAST); c = new GridBagConstraints(); c.gridy = 11; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(2, 15, 2, 0); add(resetDNSAPanel, c); // --- Filler --- c = new GridBagConstraints(); c.gridx = 0; c.gridy = 12; c.weightx = 1; c.weighty = 1; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; add(Spacer.create(), c); } private void resetDNSAButtonAction() { ProfilerIDESettings.getInstance().clearDoNotShowAgainMap(); resetDNSAButton.setEnabled(false); } void load() { // TODO read settings and initialize GUI // Example: // someCheckBox.setSelected(Preferences.userNodeForPackage(CorePanel.class).getBoolean("someFlag", false)); // or for org.openide.util with API spec. version >= 7.4: // someCheckBox.setSelected(NbPreferences.forModule(CorePanel.class).getBoolean("someFlag", false)); // or: // someTextField.setText(SomeSystemOption.getDefault().getSomeStringProperty()); GlobalPreferences preferences = GlobalPreferences.sharedInstance(); resetDNSAButton.setEnabled(true); monitoredHostPSpinner.setValue(preferences.getMonitoredHostPoll()); monitoredDataPSpinner.setValue(preferences.getMonitoredDataPoll()); threadsPSpinner.setValue(preferences.getThreadsPoll()); monitoredHostCSpinner.setValue(preferences.getMonitoredHostCache()); monitoredDataCSpinner.setValue(preferences.getMonitoredDataCache()); finishedAppsOpen.setSelected(!preferences.autoRemoveOpenedFinishedApps()); finishedAppsSnapshots.setSelected(!preferences.autoRemoveFinishedAppsWithSnapshots()); } void store() { // TODO store modified settings // Example: // Preferences.userNodeForPackage(CorePanel.class).putBoolean("someFlag", someCheckBox.isSelected()); // or for org.openide.util with API spec. version >= 7.4: // NbPreferences.forModule(CorePanel.class).putBoolean("someFlag", someCheckBox.isSelected()); // or: // SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText()); GlobalPreferences preferences = GlobalPreferences.sharedInstance(); preferences.setMonitoredHostPoll((Integer) monitoredHostPSpinner.getValue()); preferences.setMonitoredDataPoll((Integer) monitoredDataPSpinner.getValue()); preferences.setThreadsPoll((Integer) threadsPSpinner.getValue()); preferences.setMonitoredHostCache((Integer) monitoredHostCSpinner.getValue()); preferences.setMonitoredDataCache((Integer) monitoredDataCSpinner.getValue()); preferences.setAutoRemoveOpenedFinishedApps(!finishedAppsOpen.isSelected()); preferences.setAutoRemoveFinishedAppsWithSnapshots(!finishedAppsSnapshots.isSelected()); preferences.store(); } boolean valid() { try { int mh = (Integer) monitoredHostPSpinner.getValue(); int md = (Integer) monitoredDataPSpinner.getValue(); int th = (Integer) threadsPSpinner.getValue(); int mhc = (Integer) monitoredHostCSpinner.getValue(); int mdc = (Integer) monitoredDataCSpinner.getValue(); return mh > 0 && md > 0 && th > 0 && mhc > 0 && mdc > 0; } catch (Exception e) { } return false; } private void startTrackingChanges() { monitoredHostPSpinner.getModel().addChangeListener(changeListener); threadsPSpinner.getModel().addChangeListener(changeListener); monitoredDataPSpinner.getModel().addChangeListener(changeListener); monitoredHostCSpinner.getModel().addChangeListener(changeListener); monitoredDataCSpinner.getModel().addChangeListener(changeListener); ItemListener il = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { controller.changed(); } }; finishedAppsOpen.addItemListener(il); finishedAppsSnapshots.addItemListener(il); resetDNSAButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetDNSAButtonAction(); } }); } private JLabel monitoredHostPLabel; private JSpinner monitoredHostPSpinner; private JLabel monitoredHostPUnits; private JLabel threadsPLabel; private JSpinner threadsPSpinner; private JLabel threadsPUnits; private JLabel monitoredDataPLabel; private JSpinner monitoredDataPSpinner; private JLabel monitoredDataPUnits; private JLabel monitoredHostCLabel; private JSpinner monitoredHostCSpinner; private JLabel monitoredHostCUnits; private JLabel monitoredDataCLabel; private JSpinner monitoredDataCSpinner; private JLabel monitoredDataCUnits; private JCheckBox finishedAppsOpen; private JCheckBox finishedAppsSnapshots; private JLabel resetDNSALabel; private JButton resetDNSAButton; } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/GlobalPreferences.java0000644000175000017500000003221113767155557030054 0ustar apoapo/* * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.options; import org.graalvm.visualvm.core.datasupport.ComparableWeakReference; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.logging.Level; import java.util.logging.Logger; import java.util.prefs.BackingStoreException; import java.util.prefs.PreferenceChangeEvent; import java.util.prefs.PreferenceChangeListener; import java.util.prefs.Preferences; import org.graalvm.visualvm.lib.profiler.api.ProfilerIDESettings; import org.openide.util.NbPreferences; /** * General VisualVM settings defined in Options. * * @author Jaroslav Bachorik * @author Jiri Sedlacek */ public final class GlobalPreferences implements PreferenceChangeListener { private final static Logger LOGGER = Logger.getLogger("org.graalvm.visualvm.core.options"); // NOI18N private static final String INT_KEY_MONHOST_POLL = "MonitoredHostPoll"; // NOI18N private static final String INT_KEY_THREADS_POLL = "ThreadsPoll"; // NOI18N private static final String INT_KEY_MONDATA_POLL = "MonitoredDataPoll"; // NOI18N private static final String INT_KEY_MONHOST_CACHE = "MonitoredHostCache"; // NOI18N private static final String INT_KEY_MONDATA_CACHE = "MonitoredDataCache"; // NOI18N private static final String BOOL_KEY_APPS_OPENED = "FinishedAppsOpened"; // NOI18N private static final String BOOL_KEY_APPS_SNAPSHOTS = "FinishedAppsSnapshots"; // NOI18N private final static int MONHOST_POLL_DEFAULT = 3; private final static int THREADS_POLL_DEFAULT = 1; private final static int MONDATA_POLL_DEFAULT = 1; private final static int MONHOST_CACHE_DEFAULT = 60; private final static int MONDATA_CACHE_DEFAULT = 60; private final static boolean APPS_OPENED_DEFAULT = false; private final static boolean APPS_SNAPSHOTS_DEFAULT = false; private final static GlobalPreferences INSTANCE = new GlobalPreferences(); private final Preferences prefs; private final Map>> listenerMap = new HashMap>>(); private final ExecutorService dispatcher = Executors.newCachedThreadPool(); private GlobalPreferences() { prefs = NbPreferences.forModule(GlobalPreferences.class); prefs.addPreferenceChangeListener(this); } /** * Returns singleton instance of GlobalPreferences. * * @return singleton instance of GlobalPreferences. */ public static GlobalPreferences sharedInstance() { return INSTANCE; } public void preferenceChange(final PreferenceChangeEvent evt) { synchronized(listenerMap) { Set> set = listenerMap.get(evt.getKey()); if (set != null) { final Set tmpListeners = new HashSet(); Collection> deadRefs = new ArrayList>(); for(ComparableWeakReference pclRef : set) { if (pclRef.get() != null) { tmpListeners.add(pclRef.get()); } else { deadRefs.add(pclRef); } } set.removeAll(deadRefs); dispatcher.submit(new Runnable() { public void run() { for(PreferenceChangeListener pcl : tmpListeners) { pcl.preferenceChange(evt); } } }); } } } /** * Returns polling interval for monitored host. * * @return polling interval for monitored host. */ public int getMonitoredHostPoll() { return getPollingInterval(INT_KEY_MONHOST_POLL, MONHOST_POLL_DEFAULT); } /** * Sets polling interval for monitored host. * * @param value polling interval for monitored host. */ public void setMonitoredHostPoll(int value) { setPollingInterval(INT_KEY_MONHOST_POLL, value); } /** * Registers a listener for changes of polling interval for monitored host. * * @param pcl listener for changes of polling interval for monitored host. */ public void watchMonitoredHostPoll(PreferenceChangeListener pcl) { addListener(INT_KEY_MONHOST_POLL, pcl); } /** * Returns polling interval for threads. * * @return polling interval for threads. */ public int getThreadsPoll() { return getPollingInterval(INT_KEY_THREADS_POLL, THREADS_POLL_DEFAULT); } /** * Sets polling interval for threads. * * @param value polling interval for threads. */ public void setThreadsPoll(int value) { setPollingInterval(INT_KEY_THREADS_POLL, value); } /** * Registers a listener for changes of polling interval for threads. * * @param pcl listener for changes of polling interval for threads. */ public void watchThreadsPoll(PreferenceChangeListener pcl) { addListener(INT_KEY_THREADS_POLL, pcl); } /** * Returns polling interval for monitored data. * * @return polling interval for monitored data. */ public int getMonitoredDataPoll() { return getPollingInterval(INT_KEY_MONDATA_POLL, MONDATA_POLL_DEFAULT); } /** * Sets polling interval for monitored data. * * @param value polling interval for monitored data. */ public void setMonitoredDataPoll(int value) { setPollingInterval(INT_KEY_MONDATA_POLL, value); } /** * Registers a listener for changes of polling interval for monitored data. * * @param pcl listener for changes of polling interval for monitored data. */ public void watchMonitoredDataPoll(PreferenceChangeListener pcl) { addListener(INT_KEY_MONDATA_POLL, pcl); } /** * Returns size of cache for monitored host data. * * @return size of cache for monitored host data. */ public int getMonitoredHostCache() { return getPollingInterval(INT_KEY_MONHOST_CACHE, MONHOST_CACHE_DEFAULT); } /** * Sets size of cache for monitored host data. * * @param value size of cache for monitored host data. */ public void setMonitoredHostCache(int value) { setPollingInterval(INT_KEY_MONHOST_CACHE, value); } /** * Registers a listener for changes of size of cache for monitored host data. * * @param pcl listener for changes of size of cache for monitored host data. */ public void watchMonitoredHostCache(PreferenceChangeListener pcl) { addListener(INT_KEY_MONHOST_CACHE, pcl); } /** * Returns size of cache for monitored data. * * @return size of cache for monitored data. */ public int getMonitoredDataCache() { return getPollingInterval(INT_KEY_MONDATA_CACHE, MONDATA_CACHE_DEFAULT); } /** * Sets size of cache for monitored data. * * @param value size of cache for monitored data. */ public void setMonitoredDataCache(int value) { setPollingInterval(INT_KEY_MONDATA_CACHE, value); } /** * Registers a listener for changes of size of cache for monitored data. * * @param pcl listener for changes of size of cache for monitored data. */ public void watchMonitoredDataCache(PreferenceChangeListener pcl) { addListener(INT_KEY_MONDATA_CACHE, pcl); } /** * Returns true if opened applications can be removed automatically when finished. * * @return true if opened applications can be removed automatically when finished, false otherwise. */ public boolean autoRemoveOpenedFinishedApps() { return prefs.getBoolean(BOOL_KEY_APPS_OPENED, APPS_OPENED_DEFAULT); } /** * Sets whether opened applications can be removed automatically when finished. * * @param value flag controlling whether opened applications can be removed automatically when finished. */ public void setAutoRemoveOpenedFinishedApps(boolean value) { prefs.putBoolean(BOOL_KEY_APPS_OPENED, value); } /** * Returns true if applications with snapshots can be removed automatically when finished. * * @return true if applications with snapshots can be removed automatically when finished, false otherwise. */ public boolean autoRemoveFinishedAppsWithSnapshots() { return prefs.getBoolean(BOOL_KEY_APPS_SNAPSHOTS, APPS_SNAPSHOTS_DEFAULT); } /** * Sets whether applications with snapshots can be removed automatically when finished. * * @param value flag controlling whether applications with snapshots can be removed automatically when finished. */ public void setAutoRemoveFinishedAppsWithSnapshots(boolean value) { prefs.putBoolean(BOOL_KEY_APPS_SNAPSHOTS, value); } /** * Persistently stores preferences values. This method is called automatically, * typically you don't need to call it explicitly. * * @return true if the preferences have been stored successfully, false otherwise. */ public boolean store() { try { prefs.sync(); return true; } catch (BackingStoreException ex) { LOGGER.log(Level.SEVERE, "Error saving preferences", ex); // NOI18N } return false; } private void addListener(String property, PreferenceChangeListener pcl) { synchronized(listenerMap) { if (listenerMap.containsKey(property)) { Set> set = listenerMap.get(property); set.add(new ComparableWeakReference(pcl)); } else { Set> set = new HashSet>(); set.add(new ComparableWeakReference(pcl)); listenerMap.put(property, set); } } } private int getPollingInterval(String property, int deflt) { int value = -1; synchronized (prefs) { value = prefs.getInt(property, -1); if (value == -1) { value = deflt; prefs.putInt(property, value); } } return value; } private void setPollingInterval(String property, int value) { synchronized(prefs) { prefs.putInt(property, value); } } /** * Allows to set or clear persistent do not show again value associated with given notification identified by the * provided key. * * @param key A key that uniquely identifies the notification * @param value The value that should be used without displaying the notification or null to clear the Do not show * again (i.e. start displaying the notifications again. */ public void setDoNotShowAgain(String key, String value) { ProfilerIDESettings.getInstance().setDoNotShowAgain(key, value); } /** * Allows to get persistent do not show again value associated with given notification identified by the provided key. * * @param key A key that uniquely identifies the notification * @return The value that should be used without displaying the notification or null if the notification should * be displayed */ public String getDoNotShowAgain(String key) { return ProfilerIDESettings.getInstance().getDoNotShowAgain(key); } } ././@LongLink0000644000000000000000000000014600000000000011604 Lustar rootrootvisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/GeneralOptionsPanelController.javavisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/GeneralOptionsPanelController.jav0000644000175000017500000000625013767155557032312 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.options; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import javax.swing.JComponent; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.HelpCtx; import org.openide.util.Lookup; final class GeneralOptionsPanelController extends OptionsPanelController { private GeneralOptionsPanel panel; private JComponent component; private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); private boolean changed; public void update() { getPanel().load(); changed = false; } public void applyChanges() { getPanel().store(); changed = false; } public void cancel() { // need not do anything special, if no changes have been persisted yet } public boolean isValid() { return getPanel().valid(); } public boolean isChanged() { return changed; } public HelpCtx getHelpCtx() { return null; // new HelpCtx("...ID") if you have a help set } public JComponent getComponent(Lookup masterLookup) { return getComponent(); } public void addPropertyChangeListener(PropertyChangeListener l) { pcs.addPropertyChangeListener(l); } public void removePropertyChangeListener(PropertyChangeListener l) { pcs.removePropertyChangeListener(l); } private GeneralOptionsPanel getPanel() { if (panel == null) { panel = new GeneralOptionsPanel(this); } return panel; } private JComponent getComponent() { if (component == null) { component = UISupport.createScrollableContainer(getPanel()); } return component; } void changed() { if (!changed) { changed = true; pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); } pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/UISupport.java0000644000175000017500000000543513767155557026414 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.options; import org.graalvm.visualvm.core.ui.components.ScrollableContainer; import org.graalvm.visualvm.core.ui.components.SectionSeparator; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JScrollPane; /** * Helper class to create UI components for the Options dialog. * * @author Jiri Sedlacek */ public final class UISupport { /** * Creates preformated instance of SectionSeparator to be used in Options * dialog. * * @param caption section name * @return preformated instance of SectionSeparator */ public static SectionSeparator createSectionSeparator(String caption) { return new SectionSeparator(caption); } /** * Creates preformatted instance of ScrollableContainer to be used in Options * dialog. All insets are already initialized to defaults, the client components * should have zero outer insets. * * @param contents component to be displayed * @return preformatted instance of ScrollableContainer */ public static ScrollableContainer createScrollableContainer(JComponent contents) { ScrollableContainer container = new ScrollableContainer(contents, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); container.setViewportBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5)); return container; } private UISupport() {} } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/package-info.java0000644000175000017500000000250213767155557027016 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Access to general VisualVM settings defined in Options. */ package org.graalvm.visualvm.core.options; visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/Bundle.properties0000644000175000017500000000344013767155557027160 0ustar apoapo# # Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. OptionsCategory_Name_Core=General OptionsCategory_Title_Core=VisualVM LBL_Monitored_Host=Monitored &Host\: LBL_Sec=sec. LBL_Threads=Thread&s\: LBL_Monitored_Data=Monitored &Data\: LBL_Polling=Polling LBL_Charts_Cache=Charts Cache LBL_Monitored_Host2=Monitored H&ost\: LBL_min=min. LBL_Monitored_Data2=Monitored D&ata\: LBL_FinishedApps=Finished Applications MSG_FinishedApps=Keep finished applications in the Applications view\: LBL_FinishedAppsOpened=O&pened applications LBL_FinishedAppsSnapshot=Applications with s&napshots LBL_Miscellaneous=Miscellaneous MSG_Do_Not_Show_Again=Reset Do Not Show Again confirmations\: BTN_Reset=&Resetvisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/options/GeneralOptionsCategory.java0000644000175000017500000000424313767155557031125 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.options; import javax.swing.Icon; import javax.swing.ImageIcon; import org.netbeans.spi.options.OptionsCategory; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; class GeneralOptionsCategory extends OptionsCategory { public static GeneralOptionsCategory instance() { return new GeneralOptionsCategory(); } public Icon getIcon() { return new ImageIcon(ImageUtilities.loadImage("org/graalvm/visualvm/core/ui/resources/options.png")); // NOI18N } public String getCategoryName() { return NbBundle.getMessage(GeneralOptionsCategory.class, "OptionsCategory_Name_Core"); // NOI18N } public String getTitle() { return NbBundle.getMessage(GeneralOptionsCategory.class, "OptionsCategory_Title_Core"); // NOI18N } public OptionsPanelController create() { return new GeneralOptionsPanelController(); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/0000755000175000017500000000000013767155557024331 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/PropertiesSupport.java0000644000175000017500000001557213767155557030737 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.properties; import org.graalvm.visualvm.core.datasource.DataSource; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; /** * Entrypoint for customization of DataSource properties. PropertiesProvider * instances should be registered/unregistered using the registerPropertiesProvider * and unregisterPropertiesProvider methods. * * DataSource providers displaying a dialog supporting user-customizable properties * should use getCustomizer(Class) method to get the properties UI. * * @author Jiri Sedlacek */ public final class PropertiesSupport { private static PropertiesSupport INSTANCE; private final Map> providers = Collections.synchronizedMap(new HashMap()); /** * Returns singleton instance of PropertiesSupport. * * @return singleton instance of PropertiesSupport */ public static synchronized PropertiesSupport sharedInstance() { if (INSTANCE == null) INSTANCE = new PropertiesSupport(); return INSTANCE; } /** * Registers a PropertiesProvider for a concrete DataSource type. * * @param any DataSource type * @param provider PropertiesProvider to be registered * @param scope type of DataSource supported by the PropertiesProvider */ public void registerPropertiesProvider( PropertiesProvider provider, Class scope) { providers.put(provider, scope); } /** * Unregisters the PropertiesProvider. * * @param any DataSource type * @param provider PropertiesProvider to unregister */ public void unregisterPropertiesProvider( PropertiesProvider provider) { providers.remove(provider); } /** * Returns true if there's at least one PropertiesProvider providing properties * for the DataSource type, false otherwise. * * @param any DataSource type * @param type type of the DataSource to be checked * @return true if there's at least one PropertiesProvider providing properties for the DataSource type, false otherwise */ public boolean hasProperties(Class type) { return hasProperties(null, type); } /** * Returns true if there's at least one PropertiesProvider providing properties * for the DataSource, false otherwise. * * @param any DataSource type * @param dataSource DataSource to be checked * @return true if there's at least one PropertiesProvider providing properties for the DataSource, false otherwise */ public boolean hasProperties(X dataSource) { if (dataSource == null) throw new IllegalArgumentException("DataSource cannot be null"); // NOI18N return hasProperties(dataSource, (Class)dataSource.getClass()); } /** * Returns an UI component to display user-customizable properties for the * provided DataSource type. Use hasProperties(Class) method to check if there * are any customizable properties for the given DataSource type. For no * properties available the created PropertiesCustomizer is empty. * * @param any DataSource type * @param type type of the DataSource to customize * @return UI component to display user-customizable properties for the provided DataSource type */ public PropertiesCustomizer getCustomizer(Class type) { return getCustomizer(null, type); } /** * Opens Properites window of the DataSource. The first category is selected. * * @param dataSource DataSource for which to open the Properties window */ public void openProperties(DataSource dataSource) { openProperties(dataSource, PropertiesProvider.CATEGORY_GENERAL); } /** * Opens Properites window of the DataSource and selects the provided category * if available. * * @param dataSource DataSource for which to open the Properties window */ public void openProperties(DataSource dataSource, int propertiesCategory) { if (dataSource == null) throw new IllegalArgumentException("DataSource cannot be null"); // NOI18N PropertiesConfigurator.editProperties(dataSource, propertiesCategory); } PropertiesCustomizer getCustomizer(X dataSource, Class type) { return new PropertiesCustomizer(dataSource, type); } List> getProviders(X dataSource, Class type) { Map> providersCopy = new HashMap(); synchronized(providers) { providersCopy.putAll(providers); } if (dataSource != null) type = (Class)dataSource.getClass(); List> compatibleProviders = new ArrayList(); Set>> providersSet = providersCopy.entrySet(); for (Map.Entry> entry : providersSet) { PropertiesProvider provider = entry.getKey(); if (entry.getValue().isAssignableFrom(type) && provider.supportsDataSource(dataSource)) compatibleProviders.add(provider); } return compatibleProviders; } private boolean hasProperties(X dataSource, Class type) { return !getProviders(dataSource, type).isEmpty(); } private PropertiesSupport() {} } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/PropertiesConfigurator.java0000644000175000017500000001136413767155557031720 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.properties; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory; import java.awt.BorderLayout; import java.awt.Dialog; import java.awt.Dimension; import java.util.HashMap; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class PropertiesConfigurator extends JPanel { private static Dimension MIN_SIZE = new Dimension(400, 300); private static Dimension MAX_SIZE = new Dimension(700, 600); private static Map SAVED_SIZES = new HashMap(); public static void editProperties(DataSource dataSource, int propertiesCategory) { PropertiesCustomizer customizer = PropertiesSupport.sharedInstance().getCustomizer(dataSource, null); customizer.selectCategory(propertiesCategory); PropertiesConfigurator pc = new PropertiesConfigurator(customizer); final DialogDescriptor dd = new DialogDescriptor(pc, NbBundle.getMessage( PropertiesConfigurator.class, "CAP_EditProperties", new Object[] { // NOI18N DataSourceDescriptorFactory.getDescriptor(dataSource).getName() }), true, new Object[] { pc.okButton, DialogDescriptor.CANCEL_OPTION }, pc.okButton, 0, null, null); final Dialog d = DialogDisplayer.getDefault().createDialog(dd); String className = dataSource.getClass().getName(); Dimension savedSize = SAVED_SIZES.get(className); if (savedSize != null) pc.setPreferredSize(savedSize); d.pack(); d.setVisible(true); SAVED_SIZES.put(className, pc.getSize()); pc.cleanup(); if (dd.getValue() == pc.okButton) customizer.propertiesChanged(); else customizer.propertiesCancelled(); } private PropertiesConfigurator(PropertiesCustomizer customizer) { this.customizer = customizer; initComponents(); update(); customizer.addChangeListener(listener); } private void cleanup() { customizer.removeChangeListener(listener); removeAll(); } private void update() { SwingUtilities.invokeLater(new Runnable() { public void run() { okButton.setEnabled(customizer.settingsValid()); } }); } public Dimension getPreferredSize() { Dimension prefSize = super.getPreferredSize(); prefSize.width = Math.max(prefSize.width, MIN_SIZE.width); prefSize.width = Math.min(prefSize.width, MAX_SIZE.width); prefSize.height = Math.max(prefSize.height, MIN_SIZE.height); prefSize.height = Math.min(prefSize.height, MAX_SIZE.height); return prefSize; } private void initComponents() { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); add(customizer, BorderLayout.CENTER); okButton = new JButton(NbBundle.getMessage(PropertiesConfigurator.class, "LBL_OK")); // NOI18N } private final PropertiesCustomizer customizer; private final ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { update(); } }; private JButton okButton; } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/PropertiesProvider.java0000644000175000017500000001564213767155557031053 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.properties; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Positionable; /** * A provider to provide user-customizable properties for DataSources. * * @author Jiri Sedlacek */ public abstract class PropertiesProvider implements Positionable { /** * Key for the "General" properties category (always first if provided). */ public static final int CATEGORY_GENERAL = Integer.MIN_VALUE; private final String propertiesName; private final String propertiesDescription; private final int propertiesCategory; private final int preferredPosition; /** * Creates new instance of PropertiesProvider with the provided name, optional * description, properties category and preferred position of the properties * within the category.
* The propertiesCategory value defines position of the category among other * categories. If more providers use the same category their position is * defined by the preferredPosition value. The propertiesName value defines * name of the category if this is the first provider for the category, otherwise * it's used as name for the category section. * * @param propertiesName name of the provided properties * @param propertiesDescription description of the provided properties or null * @param propertiesCategory category of the provided properties * @param preferredPosition preferred position of the properties panel in UI */ public PropertiesProvider(String propertiesName, String propertiesDescription, int propertiesCategory, int preferredPosition) { this.propertiesName = propertiesName; this.propertiesDescription = propertiesDescription; this.propertiesCategory = propertiesCategory; this.preferredPosition = preferredPosition; } /** * Returns name of the provided properties. * * @return name of the provided properties */ public final String getPropertiesName() { return propertiesName; } /** * Returns description of the provided properties or null for no description. * * @return description of the provided properties or null for no description */ public final String getPropertiesDescription() { return propertiesDescription; } /** * Returns category of the provided properties. * * @return category of the provided properties */ public final int getPropertiesCategory() { return propertiesCategory; } /** * Returns preferred position of the properties section. * * @return preferred position of the properties section */ public final int getPreferredPosition() { return preferredPosition; } /** * Returns true if this PropertiesProvider provides properties for the given * DataSource. Default implementation always returns true. Note that if this * method returns true for a given DataSource instance the createPanel(DataSource) * method for the same instance cannot return null. * * @param dataSource DataSource for which to provide the properties (null means creating new DataSource) * @return true if this PropertiesProvider provides properties for given DataSource, false otherwise */ public boolean supportsDataSource(X dataSource) { return true; } /** * Returns a PropertiesPanel instance to create or edit the properties. If * the provided DataSource is null it means that the DataSource is being * created and the properites will define the initial state. Otherwise the * DataSource properties are being edited. * * Note: if using custom JPanel instances in the PropertiesPanel be sure to use * JPanel.setOpaque(false) whenever possible to keep the settings UI consistent. * For some Look and Feels the PropertiesPanel container doesn't have a standard * JPanel background. * * @param dataSource DataSource to edit the properties or null * @return PropertiesPanel instance to create or edit the properties */ public abstract PropertiesPanel createPanel(X dataSource); /** * Called when a valid PropertiesPanel has been submitted by the user when * creating a new DataSource. At this point the provider has a chance to * store the properties for the DataSource. The properties should be stored * into the DataSource's storage (use dataSource.getStorage()) to ensure they * will be always available for persistent DataSources. * * @param panel user-submitted PropertiesPanel * @param dataSource newly created DataSource */ public abstract void propertiesDefined(PropertiesPanel panel, X dataSource); /** * Called when a valid PropertiesPanel has been submitted by the user when * editing an existing DataSource. At this point the provider has a chance * to update the properties for the DataSource. The properties should be stored * into the DataSource's storage (use dataSource.getStorage()) to ensure they * will be always available for persistent DataSources. * * @param panel user-submitted PropertiesPanel * @param dataSource edited existing DataSource */ public abstract void propertiesChanged(PropertiesPanel panel, X dataSource); /** * Called when a PropertiesPanel has been cancelled by the user. At this point * the provider has a chance to perform eventual cleanup. * * @param panel user-cancelled PropertiesPanel * @param dataSource DataSource for which the panel has been cancelled or null if no DataSource has been created */ public abstract void propertiesCancelled(PropertiesPanel panel, X dataSource); } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/package-info.java0000644000175000017500000000343413767155557027524 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Support for user-customizable properties for DataSources. * * The properties are meant to provide configuration info for DataSource setup * like jstatd connections for a Host or JMX connection setup for JMX applications. *

* The main difference between properties and DataSourceView is that the properties * define or display configuration of the DataSource whereas the DataSourceView * displays state of the DataSource typically obtained using some kind of (more or * less slow) connection to the DataSource. */ package org.graalvm.visualvm.core.properties; visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/PropertiesCustomizer.java0000644000175000017500000003170713767155557031425 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.properties; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasupport.Positionable; import org.graalvm.visualvm.core.ui.components.ScrollableContainer; import org.graalvm.visualvm.core.ui.components.SectionSeparator; import org.graalvm.visualvm.core.ui.components.Spacer; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JTabbedPane; import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; /** * UI component for presenting user-customizable properties of a DataSource. * This class is to be used by DataSource providers supporting defining the * initial DataSource properties. Use PropertiesSupport.getCustomizer(Class) * method to get an instance of PropertiesCustomizer for a concrete DataSource * type. * * @author Jiri Sedlacek */ public final class PropertiesCustomizer extends PropertiesPanel { private final X dataSource; private final List>> groups; private final List panels; private final ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { update(); } }; private JTabbedPane tabbedPane; private final Map categories; PropertiesCustomizer(X dataSource, Class type) { this.dataSource = dataSource; groups = createGroups(PropertiesSupport.sharedInstance().getProviders(dataSource, type)); panels = createPanels(groups, dataSource); categories = new HashMap(); initComponents(); update(); registerListeners(); } /** * Invokes PropertiesProvider.propertiesDefined method for every * PropertiesProvider supporting the provided DataSource. To be called by * DataSource providers when the New DataSource dialog displaying editable * properties has been accepted by the user and new DataSource has been * created. * * @param dataSource newly created DataSource */ public void propertiesDefined(X dataSource) { unregisterListeners(); for (int i = 0; i < groups.size(); i++) { List> providers = groups.get(i); List categoriesPanels = new ArrayList(); if (providers.size() == 1) { categoriesPanels.add(panels.get(i)); } else { MultiPropertiesPanel multiPanel = (MultiPropertiesPanel)panels.get(i); categoriesPanels.addAll(multiPanel.getPanels()); } for (int j = 0; j < providers.size(); j++) providers.get(j).propertiesDefined(categoriesPanels.get(j), dataSource); } } /** * Invokes PropertiesProvider.propertiesCancelled method for every * PropertiesProvider supporting the DataSource type defined for this * PropertiesCustomizer. To be called by DataSource providers when the New * DataSource dialog displaying editable properites has been cancelled and * no DataSource has been created. */ public void propertiesCancelled() { unregisterListeners(); for (int i = 0; i < groups.size(); i++) { List> providers = groups.get(i); List categoriesPanels = new ArrayList(); if (providers.size() == 1) { categoriesPanels.add(panels.get(i)); } else { MultiPropertiesPanel multiPanel = (MultiPropertiesPanel)panels.get(i); categoriesPanels.addAll(multiPanel.getPanels()); } for (int j = 0; j < providers.size(); j++) providers.get(j).propertiesCancelled(categoriesPanels.get(j), dataSource); } } void propertiesChanged() { unregisterListeners(); for (int i = 0; i < groups.size(); i++) { List> providers = groups.get(i); List categoriesPanels = new ArrayList(); if (providers.size() == 1) { categoriesPanels.add(panels.get(i)); } else { MultiPropertiesPanel multiPanel = (MultiPropertiesPanel)panels.get(i); categoriesPanels.addAll(multiPanel.getPanels()); } for (int j = 0; j < providers.size(); j++) providers.get(j).propertiesChanged(categoriesPanels.get(j), dataSource); } } void selectCategory(int category) { Integer tabIndex = categories.get(category); if (tabIndex != null) tabbedPane.setSelectedIndex(tabIndex); } private void registerListeners() { for (PropertiesPanel panel : panels) panel.addChangeListener(listener); } private void unregisterListeners() { for (PropertiesPanel panel : panels) panel.removeChangeListener(listener); } private void update() { for (PropertiesPanel panel : panels) if (!panel.settingsValid()) { setSettingsValid(false); return; } setSettingsValid(true); } private void initComponents() { tabbedPane = new JTabbedPane(); tabbedPane.setFocusable(false); for (int i = 0; i < panels.size(); i++) { PropertiesPanel panel = panels.get(i); PropertiesProvider provider = groups.get(i).get(0); ScrollableContainer c = new ScrollableContainer(panel); c.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); c.setViewportBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); categories.put(provider.getPropertiesCategory(), tabbedPane.getTabCount()); tabbedPane.addTab(provider.getPropertiesName(), null, c, provider.getPropertiesDescription()); } setLayout(new BorderLayout()); add(tabbedPane, BorderLayout.CENTER); } private static List>> createGroups(List> providers) { Collections.sort(providers, new CategoriesComparator()); List>> groupedProviders = new ArrayList(); int currentCategory = -1; List> currentGroup = null; for (PropertiesProvider provider : providers) { int providerCategory = provider.getPropertiesCategory(); if (currentGroup == null || providerCategory != currentCategory) { currentCategory = providerCategory; if (currentGroup != null) Collections.sort(currentGroup, Positionable.COMPARATOR); currentGroup = new ArrayList(); groupedProviders.add(currentGroup); } if (currentGroup != null && currentCategory == providerCategory) currentGroup.add(provider); } if (currentGroup != null) Collections.sort(currentGroup, Positionable.COMPARATOR); return groupedProviders; } private static List createPanels(List>> groups, Y dataSource) { List panels = new ArrayList(groups.size()); for (List> group : groups) if (group.size() == 1) panels.add(group.get(0).createPanel(dataSource)); else panels.add(new MultiPropertiesPanel(group, dataSource)); return panels; } private static class MultiPropertiesPanel extends PropertiesPanel { private static final Color separatorColor = separatorColor(); private static final Font separatorFont = separatorFont(); private final List panels; private final ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { update(); } }; public MultiPropertiesPanel(List> providers, Y dataSource) { panels = new ArrayList(providers.size()); for (PropertiesProvider provider : providers) panels.add(provider.createPanel(dataSource)); initComponents(providers); update(); } public List getPanels() { return panels; } private void update() { boolean valid = true; for (PropertiesPanel panel : panels) if (!panel.settingsValid()) { valid = false; break; } setSettingsValid(valid); } private void initComponents(List> providers) { setOpaque(false); setBorder(BorderFactory.createEmptyBorder()); setLayout(new GridBagLayout()); int currentRow = 0; int providerIndex = 1; GridBagConstraints constraints; for (PropertiesPanel panel : panels) { constraints = createConstraints(currentRow++); add(panel, constraints); panel.addChangeListener(listener); if (providerIndex < providers.size()) { PropertiesProvider provider = providers.get(providerIndex++); SectionSeparator separator = new SectionSeparator(provider.getPropertiesName()); separator.setForeground(separatorColor); separator.setFont(separatorFont); separator.setToolTipText(provider.getPropertiesDescription()); constraints = createConstraints(currentRow++); constraints.insets = new Insets(10, 0, 5, 0); add(separator, constraints); } } constraints = createConstraints(currentRow++); constraints.weightx = 1; constraints.weighty = 1; add(Spacer.create(), constraints); } private static GridBagConstraints createConstraints(int row) { GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; return c; } } private static Color separatorColor() { Color color = UIManager.getColor("TitledBorder.titleColor"); // NOI18N if (color == null) color = new JLabel().getForeground(); return color; } private static Font separatorFont() { Font font = UIManager.getFont("TitledBorder.font"); // NOI18N if (font == null) font = new JLabel().getFont(); return font; } private static class CategoriesComparator implements Comparator { public int compare(Object o1, Object o2) { PropertiesProvider p1 = (PropertiesProvider)o1; PropertiesProvider p2 = (PropertiesProvider)o2; int category1 = p1.getPropertiesCategory(); int category2 = p2.getPropertiesCategory(); if (category1 > category2) return 1; if (category1 < category2) return -1; return p1.getPropertiesName().compareTo(p2.getPropertiesName()); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/Bundle.properties0000644000175000017500000000241513767155557027662 0ustar apoapo# # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. LBL_OK=OK ACT_Properties=&Properties DESCR_Properties=Properties CAP_EditProperties=Properties of {0} visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/PropertiesPanel.java0000644000175000017500000000666713767155557030327 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.properties; import java.util.ArrayList; import java.util.List; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.PanelUI; /** * UI component to display and modify the properties. Provides validity * notification support to correctly handle actual state of the user-provided * data - valid or invalid. * * Note: if using custom JPanel instances in the PropertiesPanel be sure to use * JPanel.setOpaque(false) whenever possible to keep the settings UI consistent. * For some Look and Feels the PropertiesPanel container doesn't have a standard * JPanel background. * * @author Jiri Sedlacek */ public class PropertiesPanel extends JPanel { private boolean settingsValid = true; private List listeners = new ArrayList(); /** * Returns true if settings defined by this Panel are valid. * To be called in EDT. * * @return true if settings defined by this Panel are valid */ public final boolean settingsValid() { return settingsValid; } /** * Add a ChangeListener. Use settingsValid() method to read the state. * To be called in EDT. * * @param listener ChangeListener */ public final void addChangeListener(ChangeListener listener) { if (!listeners.contains(listener)) listeners.add(listener); } /** * Remove a ChangeListener. To be called in EDT. * @param listener ChangeListener */ public final void removeChangeListener(ChangeListener listener) { listeners.remove(listener); } /** * Notifies the Panel that validity of the user-provided data changed. * To be called in EDT. * * @param valid true if the current settings are valid, false otherwise */ protected final void setSettingsValid(boolean valid) { if (settingsValid != valid) { settingsValid = valid; fireStateChanged(); } } public void setUI(PanelUI ui) { super.setUI(ui); setOpaque(false); } private void fireStateChanged() { for (ChangeListener listener : listeners) listener.stateChanged(new ChangeEvent(this)); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/properties/EditPropertiesAction.java0000644000175000017500000000452713767155557031304 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.properties; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.ui.actions.SingleDataSourceAction; import java.awt.event.ActionEvent; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class EditPropertiesAction extends SingleDataSourceAction { private static EditPropertiesAction instance; public static synchronized EditPropertiesAction instance() { if (instance == null) instance = new EditPropertiesAction(); return instance; } protected void actionPerformed(DataSource dataSource, ActionEvent actionEvent) { PropertiesSupport.sharedInstance().openProperties(dataSource); } protected boolean isEnabled(DataSource dataSource) { return PropertiesSupport.sharedInstance().hasProperties(dataSource); } private EditPropertiesAction() { super(DataSource.class); putValue(NAME, NbBundle.getMessage(EditPropertiesAction.class, "ACT_Properties")); // NOI18N putValue(SHORT_DESCRIPTION, NbBundle.getMessage(EditPropertiesAction.class, "DESCR_Properties")); // NOI18N } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/0000755000175000017500000000000013767155557024267 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/DataSource.java0000644000175000017500000002700613767155557027171 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource; import org.graalvm.visualvm.core.datasupport.DataRemovedListener; import org.graalvm.visualvm.core.datasupport.ComparableWeakReference; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.lang.ref.WeakReference; import java.util.Collections; import java.util.HashSet; import java.util.Set; import org.openide.util.RequestProcessor; /** * Abstract implementation of DataSource. * DataSource is a base element of all data sources in VisualVM like applications, * hosts, thread dumps etc. * * @author Jiri Sedlacek */ public abstract class DataSource { /** * Named property for DataSource visibility. */ public static final String PROPERTY_VISIBLE = "prop_visible"; // NOI18N /** * Event dispatch thread for all DataSource events. All operations on DataSources should be invoked * in this thread - similar to UI operations performed in AWT event dispatch thread. */ public static final RequestProcessor EVENT_QUEUE = new RequestProcessor("DataSource Event Queue"); // NOI18N /** * Virtual root of DataSource tree. * ROOT corresponds to invisible root of explorer tree. */ public static final DataSource ROOT = new DataSource() {}; private DataSource owner; private boolean isRemoved = false; private DataSource master; private boolean visible = true; private Storage storage; private DataSourceContainer repository; private PropertyChangeSupport changeSupport; private Set> removedListeners; /** * Creates new instance of DataSource. */ public DataSource() { this(null); } /** * Creates new instance of DataSource with defined master. * * @param master master of the DataSource. */ public DataSource(DataSource master) { this.master = master; } /** * Returns owner (parent) DataSource of this DataSource. * @return owner (parent) DataSource of this DataSource. */ public final DataSource getOwner() { return owner; } /** * Sets visibility of the DataSource. * * @param newVisible visibility of the DataSource. */ public final synchronized void setVisible(boolean newVisible) { if (this == DataSource.ROOT && !newVisible) throw new IllegalArgumentException("DataSourceRoot cannot be hidden"); // NOI18N boolean oldVisible = visible; visible = newVisible; getChangeSupport().firePropertyChange(PROPERTY_VISIBLE, oldVisible, newVisible); } /** * Returns true if the DataSource is visible, false otherwise. * * @return true if the DataSource is visible, false otherwise. */ public final boolean isVisible() { return visible; } /** * Returns master of the DataSource. * * @return master of the DataSource. */ public final DataSource getMaster() { return master; } /** * Returns storage for the DataSource. * * @return storage for the DataSource. */ public final synchronized Storage getStorage() { if (storage == null) { storage = createStorage(); if (storage == null) throw new NullPointerException("Storage cannot be null"); // NOI18N } return storage; } /** * Returns repository of the DataSource. * Repository is a container for other DataSources, virtually building a tree * structure of DataSources. * * @return repository of the DataSource. */ public final synchronized DataSourceContainer getRepository() { if (repository == null) repository = new DataSourceContainer(this); return repository; } /** * Add a PropertyChangeListener to the listener list. * The listener is registered for all properties. * The same listener object may be added more than once, and will be called * as many times as it is added. * If listener is null, no exception is thrown and no action * is taken. * * @param listener The PropertyChangeListener to be added */ public final void addPropertyChangeListener(PropertyChangeListener listener) { getChangeSupport().addPropertyChangeListener(listener); } /** * Add a PropertyChangeListener for a specific property. The listener * will be invoked only when a call on firePropertyChange names that * specific property. * The same listener object may be added more than once. For each * property, the listener will be invoked the number of times it was added * for that property. * If propertyName or listener is null, no * exception is thrown and no action is taken. * * @param propertyName The name of the property to listen on. * @param listener The PropertyChangeListener to be added */ public final void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { getChangeSupport().addPropertyChangeListener(propertyName, listener); } /** * Remove a PropertyChangeListener from the listener list. * This removes a PropertyChangeListener that was registered * for all properties. * If listener was added more than once to the same event * source, it will be notified one less time after being removed. * If listener is null, or was never added, no exception is * thrown and no action is taken. * * @param listener The PropertyChangeListener to be removed */ public final void removePropertyChangeListener(PropertyChangeListener listener) { getChangeSupport().removePropertyChangeListener(listener); } /** * Remove a PropertyChangeListener for a specific property. * If listener was added more than once to the same event * source for the specified property, it will be notified one less time * after being removed. * If propertyName is null, no exception is thrown and no * action is taken. * If listener is null, or was never added for the specified * property, no exception is thrown and no action is taken. * * @param propertyName The name of the property that was listened on. * @param listener The PropertyChangeListener to be removed */ public final void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { getChangeSupport().removePropertyChangeListener(propertyName, listener); } /** * Returns true if the DataSource can be removed using Remove action, false otherwise. * * @return true if the DataSource can be removed using Remove action, false otherwise. */ public boolean supportsUserRemove() { return false; } /** * Adds a DataRemovedListener to be notified when the DataSource is removed from the tree. * Note that this listener cannot be explicitely unregistered, it's weakly referenced and will * be notified up to once and then unregistered automatically. * * @param listener DataRemovedListener to be notified when the DataSource is removed from the tree. */ public final void notifyWhenRemoved(DataRemovedListener listener) { if (listener == null) throw new IllegalArgumentException("Listener cannot be null"); // NOI18N if (isRemoved()) listener.dataRemoved(this); else getRemovedListeners().add(new ComparableWeakReference(listener)); } /** * Returns true if the DataSource has already been removed from DataSources tree, false otherwise. * @return true if the DataSource has already been removed from DataSources tree, false otherwise. */ public final boolean isRemoved() { return isRemoved; } /** * Returns true if the DataSource can be removed in context of removeRoot. * The check is blocking, this is a chance for example to warn the user about * possible data loss when removing the DataSource representing an unsaved snapshot. * * @param removeRoot DataSource which invoked the removal action (topmost DataSource to be removed). * @return true if the DataSource can be removed in context of removeRoot, false otherwise. */ public boolean checkRemove(DataSource removeRoot) { return true; } // Implementation of this DataSource removal // Persistent DataSources can remove appropriate entries from their storage protected void remove() { getStorage().deleteCustomPropertiesStorage(); } final void addImpl(DataSource owner) { if (isRemoved) throw new UnsupportedOperationException("DataSource can be added only once"); // NOI18N this.owner = owner; } final void removeImpl() { remove(); this.owner = null; isRemoved = true; if (!hasRemovedListeners()) return; Set> listeners = getRemovedListeners(); for (WeakReference listenerReference : listeners) { DataRemovedListener listener = listenerReference.get(); if (listener != null) listener.dataRemoved(this); } listeners.clear(); } /** * Creates Storage instance for this DataSource. * This method should never return null. * * @return Storage instance for this DataSource. */ protected Storage createStorage() { return new Storage(); } /** * Returns instance of PropertyChangeSupport used for processing property changes. * * @return instance of PropertyChangeSupport used for processing property changes. */ protected final synchronized PropertyChangeSupport getChangeSupport() { if (changeSupport == null) changeSupport = new PropertyChangeSupport(this); return changeSupport; } final boolean hasRemovedListeners() { return removedListeners != null; } final synchronized Set> getRemovedListeners() { if (!hasRemovedListeners()) removedListeners = Collections.synchronizedSet(new HashSet()); return removedListeners; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/0000755000175000017500000000000013767155557026445 5ustar apoapo././@LongLink0000644000000000000000000000016000000000000011600 Lustar rootrootvisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/GeneralPropertiesProvider.javavisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/GeneralPropertiesPr0000644000175000017500000001544113767155557032331 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource.descriptor; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.properties.PropertiesPanel; import org.graalvm.visualvm.core.properties.PropertiesProvider; import org.graalvm.visualvm.core.ui.components.Spacer; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Image; import java.awt.Insets; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import org.openide.awt.Mnemonics; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; /** * * @author Jiri Sedlacek */ class GeneralPropertiesProvider extends PropertiesProvider { public GeneralPropertiesProvider() { super(NbBundle.getMessage(GeneralPropertiesProvider.class, "CAP_GeneralProperties"), // NOI18N NbBundle.getMessage(GeneralPropertiesProvider.class, "DESCR_GeneralProperties"), // NOI18N CATEGORY_GENERAL, Integer.MIN_VALUE); } public PropertiesPanel createPanel(DataSource dataSource) { DataSourceDescriptor descriptor = DataSourceDescriptorFactory.getDescriptor(dataSource); GridBagConstraints c; PropertiesPanel panel = new PropertiesPanel(); panel.setLayout(new GridBagLayout()); Image icon = descriptor.getIcon(); if (icon == null) icon = ImageUtilities.loadImage( "org/graalvm/visualvm/core/ui/resources/empty.png"); // NOI18N JButton iconButton = new JButton(new ImageIcon(icon)); iconButton.setDisabledIcon(iconButton.getIcon()); iconButton.setEnabled(false); iconButton.setMargin(new Insets(3, 3, 3, 3)); Dimension size = iconButton.getPreferredSize(); size.width = Math.min(size.width, size.height); size.height = size.width; iconButton.setPreferredSize(size); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(0, 0, 5, 8); panel.add(iconButton, c); JTextField nameField = new JTextField(descriptor.getName()); nameField.setEditable(false); size = nameField.getPreferredSize(); size.width = 1; nameField.setPreferredSize(size); nameField.setMinimumSize(size); nameField.setCaretPosition(0); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.weightx = 1; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(0, 0, 5, 0); panel.add(nameField, c); JLabel descriptionLabel = new JLabel(); Mnemonics.setLocalizedText(descriptionLabel, NbBundle.getMessage( GeneralPropertiesProvider.class, "LBL_GeneralDescr")); // NOI18N c = new GridBagConstraints(); c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(2, 0, 3, 0); panel.add(descriptionLabel, c); JTextArea descriptionArea = new JTextArea(descriptor.getDescription()) { public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); // Workaround for JDK7 where empty text seems to break preferredSize if ("".equals(getText())) { // NOI18N size.width = 0; size.height = 0; } return size; } }; descriptionLabel.setLabelFor(descriptionArea); descriptionArea.setEditable(false); descriptionArea.setRows(4); descriptionArea.setCaretPosition(0); descriptionArea.setBackground(nameField.getBackground()); descriptionArea.setOpaque(true); descriptionArea.setLineWrap(true); descriptionArea.setWrapStyleWord(true); JScrollPane descriptionScroll = new JScrollPane(descriptionArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); size = descriptionScroll.getPreferredSize(); descriptionScroll.getViewport().setPreferredSize(size); descriptionScroll.getViewport().setMinimumSize(size); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(0, 0, 5, 0); panel.add(descriptionScroll, c); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 10; c.weighty = 1; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(0, 0, 0, 0); panel.add(Spacer.create(), c); return panel; } public boolean supportsDataSource(DataSource dataSource) { return dataSource != null && DataSourceDescriptorFactory.getDescriptor(dataSource).providesProperties(); } public void propertiesDefined(PropertiesPanel panel, DataSource dataSource) {} public void propertiesChanged(PropertiesPanel panel, DataSource dataSource) {} public void propertiesCancelled(PropertiesPanel panel, DataSource dataSource) {} } ././@LongLink0000644000000000000000000000015300000000000011602 Lustar rootrootvisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/DataSourceDescriptor.javavisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/DataSourceDescripto0000644000175000017500000003603713767155557032310 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource.descriptor; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasource.Storage; import org.graalvm.visualvm.core.datasupport.Positionable; import org.graalvm.visualvm.core.model.Model; import java.awt.Image; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.Comparator; /** * DataSourceDescriptor defines runtime appearance of the DataSource in Applications window. * * @author Jiri Sedlacek * @author Tomas Hurka */ public abstract class DataSourceDescriptor extends Model implements Positionable { /** * Named property for DataSource icon. */ public static final String PROPERTY_ICON = "prop_icon"; // NOI18N /** * Named property for DataSource name. */ public static final String PROPERTY_NAME = "prop_name"; // NOI18N /** * Named property for DataSource description. */ public static final String PROPERTY_DESCRIPTION = "prop_description"; // NOI18N /** * Named property for DataSource position within its owner. */ public static final String PROPERTY_PREFERRED_POSITION = "prop_preferred_position"; // NOI18N /** * Named property for comparator used to sort nested DataSources. */ public static final String PROPERTY_CHILDREN_COMPARATOR = "prop_children_comparator"; // NOI18N /** * Named property for DataSource expansion policy. */ public static final String PROPERTY_EXPANSION_POLICY = "prop_expansion_policy"; // NOI18N /** * Expansion policy - DataSource will never expand automatically. */ public static final int EXPAND_NEVER = 0; /** * Expansion policy - DataSource will be automatically expanded when first child is added, not more than once. */ public static final int EXPAND_ON_FIRST_CHILD = 1; /** * Expansion policy - DataSource will be automatically expanded whenever first child is added, for each first child. */ public static final int EXPAND_ON_EACH_FIRST_CHILD = 2; /** * Expansion policy - DataSource will be automatically expanded whenever new child is added. */ public static final int EXPAND_ON_EACH_NEW_CHILD = 3; /** * Expansion policy - DataSource will be automatically expanded whenever a child is added or removed. */ public static final int EXPAND_ON_EACH_CHILD_CHANGE = 4; private X dataSource; private Image icon; private String name; private String description; private int preferredPosition; private Comparator childrenComparator; private int autoExpansionPolicy; private final PropertyChangeSupport changeSupport; /** * Creates new instance of DataSourceDescriptor. * * @param dataSource DataSource described by the descriptor, cannot be null. */ public DataSourceDescriptor(X dataSource) { this(dataSource, dataSource != null ? dataSource.toString() : null, null, null, POSITION_AT_THE_END, EXPAND_ON_FIRST_CHILD); } /** * Creates new instance of DataSourceDescriptor. * * @param ds DataSource described by the descriptor, cannot be null. * @param n DataSource name. * @param desc DataSource description. * @param ic DataSource icon. * @param pos DataSource position. * @param aep DataSource expansion policy. * * @throws NullPointerException if the provided DataSource is null. */ public DataSourceDescriptor(X ds, String n, String desc, Image ic, int pos, int aep) { if (ds == null) throw new NullPointerException("DataSource cannot be null"); dataSource = ds; changeSupport = new PropertyChangeSupport(dataSource); name = formatName(n); // NOTE: called after dataSource is set, should work fine in subclasses with overriden formatName() description = desc; icon = ic; preferredPosition = pos; autoExpansionPolicy = aep; } /** * Returns icon of the DataSource. * * @return icon of the DataSource. */ public Image getIcon() { return icon; } /** * Returns true if the DataSource can be renamed using the Rename action, false otherwise. * * @return true if the DataSource can be renamed using the Rename action, false otherwise. */ public boolean supportsRename() { return false; } /** * Sets DataSource name. * * @param newName DataSource name. */ public void setName(String newName) { setNameImpl(newName, PROPERTY_NAME); } protected void setImplicitName(String newName, String propertyName) { setNameImpl(newName, propertyName); } private void setNameImpl(String newName, String propertyName) { if (!supportsRename()) throw new UnsupportedOperationException("Rename not supported for this descriptor"); // NOI18N if (newName == null) throw new IllegalArgumentException("Name cannot be null"); // NOI18N String oldName = name; name = formatName(newName); if (propertyName != null) getDataSource().getStorage().setCustomProperty(propertyName, newName); getChangeSupport().firePropertyChange(PROPERTY_NAME, oldName, getName()); } /** * Returns name of the DataSource. * * @return name of the DataSource. */ public String getName() { return name; } /** * Enables subclasses to process (format) the provided name of the DataSource. * * @param namePattern name of the DataSource to be processed (formatted) * @return processed (formatted) name of the DataSource. */ protected String formatName(String namePattern) { return namePattern; } /** * Returns description of the DataSource. * * @return description of the DataSource. */ public String getDescription() { return description; } /** * Returns preferred position of the DataSource. * * @return preferred position of the DataSource. */ public int getPreferredPosition() { return preferredPosition; } /** * Returns comparator used to sort nested DataSources. If defined, it overrides * the default sorting which uses DataSourceDescriptor.getPreferredPosition(). * Default implementation returns null. * * @return comparator used to sort nested DataSources or null */ public Comparator getChildrenComparator() { return childrenComparator; } /** * Returns expansion policy of the DataSource. * * @return expansion policy of the DataSource. */ public int getAutoExpansionPolicy() { return autoExpansionPolicy; } /** * Returns true if the General properties section should be available for * the DataSource, false otherwise. * * @return true if the General properties section should be available for * the DataSource, false otherwise */ public boolean providesProperties() { return false; } /** * Add a PropertyChangeListener to the listener list. * The listener is registered for all properties. * The same listener object may be added more than once, and will be called * as many times as it is added. * If listener is null, no exception is thrown and no action * is taken. * * @param listener The PropertyChangeListener to be added */ public final void addPropertyChangeListener(PropertyChangeListener listener) { getChangeSupport().addPropertyChangeListener(listener); } /** * Add a PropertyChangeListener for a specific property. The listener * will be invoked only when a call on firePropertyChange names that * specific property. * The same listener object may be added more than once. For each * property, the listener will be invoked the number of times it was added * for that property. * If propertyName or listener is null, no * exception is thrown and no action is taken. * * @param propertyName The name of the property to listen on. * @param listener The PropertyChangeListener to be added */ public final void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { getChangeSupport().addPropertyChangeListener(propertyName, listener); } /** * Remove a PropertyChangeListener from the listener list. * This removes a PropertyChangeListener that was registered * for all properties. * If listener was added more than once to the same event * source, it will be notified one less time after being removed. * If listener is null, or was never added, no exception is * thrown and no action is taken. * * @param listener The PropertyChangeListener to be removed */ public final void removePropertyChangeListener(PropertyChangeListener listener) { getChangeSupport().removePropertyChangeListener(listener); } /** * Remove a PropertyChangeListener for a specific property. * If listener was added more than once to the same event * source for the specified property, it will be notified one less time * after being removed. * If propertyName is null, no exception is thrown and no * action is taken. * If listener is null, or was never added for the specified * property, no exception is thrown and no action is taken. * * @param propertyName The name of the property that was listened on. * @param listener The PropertyChangeListener to be removed */ public final void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { getChangeSupport().removePropertyChangeListener(propertyName, listener); } protected final X getDataSource() { return dataSource; } protected void setDescription(String newDescription) { if (description == null && newDescription == null) return; String oldDescription = description; description = newDescription; getChangeSupport().firePropertyChange(PROPERTY_DESCRIPTION, oldDescription, getDescription()); } protected void setIcon(Image newIcon) { if (icon == null && newIcon == null) return; Image oldIcon = icon; icon = newIcon; getChangeSupport().firePropertyChange(PROPERTY_ICON, oldIcon, getIcon()); } protected void setPreferredPosition(int newPosition) { int oldPosition = preferredPosition; preferredPosition = newPosition; getChangeSupport().firePropertyChange(PROPERTY_PREFERRED_POSITION, oldPosition, getPreferredPosition()); } /** * Sets a custom comparator for sorting DataSources within a DataSource. * Use setChildrenComparator(null) to restore the default sorting. * * @param newComparator comparator for sorting DataSources within a DataSource */ protected void setChildrenComparator(Comparator newComparator) { Comparator oldComparator = childrenComparator; childrenComparator = newComparator; getChangeSupport().firePropertyChange(PROPERTY_CHILDREN_COMPARATOR, oldComparator, getChildrenComparator()); } protected void getAutoExpansionPolicy(int newPolicy) { int oldPolicy = autoExpansionPolicy; autoExpansionPolicy = newPolicy; getChangeSupport().firePropertyChange(PROPERTY_EXPANSION_POLICY, oldPolicy, getAutoExpansionPolicy()); } protected final PropertyChangeSupport getChangeSupport() { return changeSupport; } /** * Returns persisted DataSource name if available in DataSource Storage as * PROPERTY_NAME. Otherwise returns the provided name. * * @param dataSource DataSource for which to resolve the name * @param name name to be used if not available in DataSource Storage * @return persisted DataSource name if available or the provided name */ protected static String resolveName(DataSource dataSource, String name) { String persistedName = dataSource.getStorage().getCustomProperty(PROPERTY_NAME); if (persistedName != null) return persistedName; else return name; } /** * Returns persisted DataSource position if available in DataSource Storage * as PROPERTY_PREFERRED_POSITION. Otherwise uses the provided position. * Optionally saves the position to DataSource storage which also ensures that * relative positions POSITION_AT_THE_END and POSITION_LAST will be correctly * persisted. * * @param dataSource DataSource for which to resolve the position * @param position position to be used if not available in DataSource Storage * @param savePosition true when the position should be saved to DataSource's Storage * @return persisted DataSource position if available or the provided position */ protected static int resolvePosition(DataSource dataSource, int position, boolean savePosition) { Storage storage = dataSource.getStorage(); String positionS = storage.getCustomProperty(PROPERTY_PREFERRED_POSITION); if (positionS != null) try { position = Integer.parseInt(positionS); } catch (NumberFormatException e) { if (savePosition) storage.setCustomProperty(PROPERTY_PREFERRED_POSITION, Integer.toString(position)); } else { if (savePosition) storage.setCustomProperty(PROPERTY_PREFERRED_POSITION, Integer.toString(position)); } return position; } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/package-info.java0000644000175000017500000000252213767155557031635 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Definition of DataSourceDescriptor and related core APIs. */ package org.graalvm.visualvm.core.datasource.descriptor; ././@LongLink0000644000000000000000000000016200000000000011602 Lustar rootrootvisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/DataSourceDescriptorFactory.javavisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/DataSourceDescripto0000644000175000017500000000705513767155557032306 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource.descriptor; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.model.ModelFactory; import org.graalvm.visualvm.core.model.ModelProvider; import org.graalvm.visualvm.core.properties.PropertiesSupport; /** * ModelFactory for DataSourceDescriptors. * * @author Tomas Hurka */ public final class DataSourceDescriptorFactory extends ModelFactory implements ModelProvider { private static DataSourceDescriptorFactory dsDescFactory; private DataSourceDescriptorFactory() { } /** * Returns the singleton instance of DataSourceDescriptorFactory. * * @return singleton instance of DataSourceDescriptorFactory. */ public static synchronized DataSourceDescriptorFactory getDefault() { if (dsDescFactory == null) { dsDescFactory = new DataSourceDescriptorFactory(); dsDescFactory.registerProvider(dsDescFactory); // Register General properties tab support PropertiesSupport.sharedInstance().registerPropertiesProvider( new GeneralPropertiesProvider(), DataSource.class); } return dsDescFactory; } /** * Returns DataSourceDescriptor for given DataSource. * Use this method to get for example a DataSource name or icon. * * @param ds DataSource for which to get the descriptor. * @return DataSourceDescriptor for given DataSource. */ public static DataSourceDescriptor getDescriptor(DataSource ds) { return getDefault().getModel(ds); } /** * Creates DataSourceDescriptor for given DataSource. * This method is used by the ModelFactory framework, typically you need * to use the DataSourceDescriptor.getDescriptor(DataSource) method to get * properties of a DataSource. * * @param ds DataSource for which to create the descriptor. * @return new DataSourceDescriptor for given DataSource. */ public DataSourceDescriptor createModelFor(DataSource ds) { return new DefaultDataSourceDescriptor(ds); } private static class DefaultDataSourceDescriptor extends DataSourceDescriptor { DefaultDataSourceDescriptor(DataSource ds) { super(ds); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/descriptor/Bundle.properties0000644000175000017500000000241613767155557031777 0ustar apoapo# # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. CAP_GeneralProperties=General DESCR_GeneralProperties=General information LBL_GeneralDescr=&Description\: visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/DataSourceProvider.java0000644000175000017500000002371513767155557030707 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource; import org.graalvm.visualvm.core.datasupport.DataChangeEvent; import org.graalvm.visualvm.core.datasupport.DataChangeListener; import org.graalvm.visualvm.core.datasupport.Utils; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; /** * Default implementation of DataSourceProvider. * DataSourceProviders can benefit from extending this class which implements * managing created DataSource instances and firing the events to listeners. * * @author Jiri Sedlacek */ public class DataSourceProvider { private static final boolean SUPPRESS_EXCEPTIONS_UI = Boolean.getBoolean(DataSourceProvider.class.getName() + ".suppressExceptionsUI"); // NOI18N private static final Logger LOGGER = Logger.getLogger(DataSourceProvider.class.getName()); private final Set dataSources = Collections.synchronizedSet(new HashSet()); private final Map, Class> listeners = new HashMap(); /** * Creates new instance of DataSourceProvider. */ DataSourceProvider() { } /** * Adds a DataChangeListener to listen for added/removed DataSources. * * @param any DataSource type. * @param listener listener to be added. * @param scope scope of DataSource types for which to get notifications. */ public final void addDataChangeListener(final DataChangeListener listener, final Class scope) { DataSource.EVENT_QUEUE.post(new Runnable() { public void run() { if (listeners.containsKey(listener)) { String msg = "Listener " + listener + " already registered"; // NOI18N LOGGER.log(Level.SEVERE, msg, new UnsupportedOperationException(msg)); } else { listeners.put(listener, scope); fireCurrentState(listener); } } }); } /** * Removes a DataChange listener. * * @param any DataSource type. * @param listener listener to be removed. */ public final void removeDataChangeListener(final DataChangeListener listener) { DataSource.EVENT_QUEUE.post(new Runnable() { public void run() { if (!listeners.containsKey(listener)) { String msg = "Listener " + listener + " not registered"; // NOI18N LOGGER.log(Level.SEVERE, msg, new UnsupportedOperationException(msg)); } else { listeners.remove(listener); } } }); } /** * Returns DataSources managed by this provider. * @return DataSources managed by this provider. */ public final Set getDataSources() { return new HashSet(Arrays.asList(dataSources.toArray())); } /** * Returns DataSources of a certain type managed by this provider. * * @param any DataSource type. * @param scope DataSource types to return. * @return DataSources of a certain type managed by this provider. */ public final Set getDataSources(Class scope) { return Utils.getFilteredSet(getDataSources(), scope); } /** * Registers added DataSource into this provider. * * @param added added DataSource to register. */ protected final void registerDataSource(DataSource added) { registerDataSources(Collections.singleton(added)); } /** * Registers added DataSources into this provider. * * @param added added DataSources to register. */ protected final void registerDataSources(final Set added) { DataSource.EVENT_QUEUE.post(new Runnable() { public void run() { if (!added.isEmpty()) registerDataSourcesImpl(checkAdded(added)); } }); } /** * Unregisters removed DataSource from this provider. * * @param removed removed DataSource to unregister. */ protected final void unregisterDataSource(DataSource removed) { unregisterDataSources(Collections.singleton(removed)); } /** * Unregisters removed DataSources from this provider. * * @param removed removed DataSources to unregister. */ protected final void unregisterDataSources(final Set removed) { DataSource.EVENT_QUEUE.post(new Runnable() { public void run() { if (!removed.isEmpty()) unregisterDataSourcesImpl(checkRemoved(removed)); } }); } /** * Registers added DataSources into this provider and unregisters removed DataSources from this provider. * * @param added added DataSources to register. * @param removed removed DataSources to unregister. */ protected final void changeDataSources(final Set added, final Set removed) { DataSource.EVENT_QUEUE.post(new Runnable() { public void run() { if (!removed.isEmpty()) unregisterDataSourcesImpl(checkRemoved(removed)); if (!added.isEmpty()) registerDataSourcesImpl(checkAdded(added)); } }); } void registerDataSourcesImpl(Set added) { dataSources.addAll(added); fireDataAdded(added); } void unregisterDataSourcesImpl(Set removed) { dataSources.removeAll(removed); fireDataRemoved(removed); } private Set checkAdded(Set added) { Set uniqueAdded = new HashSet(added); Iterator it = uniqueAdded.iterator(); while(it.hasNext()) { DataSource ds = it.next(); if (dataSources.contains(ds)) { it.remove(); logUnsupportedOperation("DataSource already in repository: " + ds); // NOI18N } } return uniqueAdded; } private Set checkRemoved(Set removed) { Set uniqueRemoved = new HashSet(removed); Iterator it = uniqueRemoved.iterator(); while(it.hasNext()) { DataSource ds = it.next(); if (!dataSources.contains(ds)) { it.remove(); logUnsupportedOperation("DataSource not in repository: " + ds); // NOI18N } } return uniqueRemoved; } private static void logUnsupportedOperation(String msg) { if (SUPPRESS_EXCEPTIONS_UI) LOGGER.severe(msg); else LOGGER.log(Level.SEVERE, msg, new UnsupportedOperationException(msg)); } private void fireCurrentState(DataChangeListener listener) { fireDataChanged(listener, null, null); } private void fireDataAdded(Set added) { fireDataChanged(added, Collections.EMPTY_SET); } private void fireDataRemoved(Set removed) { fireDataChanged(Collections.EMPTY_SET, removed); } private void fireDataChanged(Set added, Set removed) { Set> listenersSet = listeners.keySet(); for (DataChangeListener listener : listenersSet) fireDataChanged(listener, added, removed); } private void fireDataChanged(DataChangeListener listener, Set added, Set removed) { Class filter = listeners.get(listener); Set filteredCurrent = Utils.getFilteredSet(dataSources, filter); if (added == null && removed == null) { DataChangeEvent event = new DataChangeEvent(filteredCurrent, filteredCurrent, null); listener.dataChanged(event); } else { Set filteredAdded = added != null ? Utils.getFilteredSet(added, filter) : Collections.EMPTY_SET; Set filteredRemoved = removed != null ? Utils.getFilteredSet(removed, filter) : Collections.EMPTY_SET; if (!filteredAdded.isEmpty() || !filteredRemoved.isEmpty()) { DataChangeEvent event = new DataChangeEvent(filteredCurrent, filteredAdded, filteredRemoved); listener.dataChanged(event); } } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/DataSourceContainer.java0000644000175000017500000000747113767155557031040 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource; import java.util.Set; /** * Default implementation of DataSourceContainer. * This class implements all neccessary methods to act as a repository of a DataSource (DataSource.getRepository()). * * @author Jiri Sedlacek */ public final class DataSourceContainer extends DataSourceProvider { private final DataSource owner; /** * Default implementation of DataSourceContainer. * DataSoures can benefit from using this class which implements * managing created DataSource instances and firing the events to listeners * as their repositories. * * @param owner */ DataSourceContainer(DataSource owner) { this.owner = owner; } /** * Adds a DataSource to the container. * * @param added DataSource to be added. */ public void addDataSource(DataSource added) { registerDataSource(added); } /** * Adds several DataSources to the container at once. * * @param added DataSources to be added. */ public void addDataSources(Set added) { super.registerDataSources(added); } /** * Removes a DataSource from the container. * * @param removed DataSource to be removed. */ public void removeDataSource(DataSource removed) { unregisterDataSource(removed); } /** * Removes several DataSources from the container at once. * * @param removed DataSources to be removed. */ public void removeDataSources(Set removed) { super.unregisterDataSources(removed); } /** * Adds and removes several DataSources to/from the container in a single operation. * * @param added DataSources to be added. * @param removed DataSources to be removed. */ public void updateDataSources(Set added, Set removed) { super.changeDataSources(added, removed); } protected void registerDataSourcesImpl(Set added) { for (DataSource dataSource : added) dataSource.addImpl(owner); super.registerDataSourcesImpl(added); } protected void unregisterDataSourcesImpl(Set removed) { for (DataSource dataSource : removed) { DataSourceContainer dataSourceRepository = dataSource.getRepository(); dataSourceRepository.unregisterDataSourcesImpl(dataSourceRepository.getDataSources()); dataSource.removeImpl(); } super.unregisterDataSourcesImpl(removed); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/package-info.java0000644000175000017500000000247513767155557027466 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Definition of DataSource and related core APIs. */ package org.graalvm.visualvm.core.datasource; visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/DataSourceRepository.java0000644000175000017500000000611413767155557031266 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource; import org.graalvm.visualvm.core.datasupport.DataChangeEvent; import org.graalvm.visualvm.core.datasupport.DataChangeListener; import java.util.Set; /** * Central repository of all known DataSources. * Whenever is a new DataSource added to DataSources tree, DataSourceRepository * detects it and emits notifications to listeners. * * @author Jiri Sedlacek */ public final class DataSourceRepository extends DataSourceProvider { private static DataSourceRepository sharedInstance; private final Listener dataChangeListener = new Listener(); /** * Returns singleton instance of DataSourceRepository. * * @return singleton instance of DataSourceRepository. */ public synchronized static DataSourceRepository sharedInstance() { if (sharedInstance == null) sharedInstance = new DataSourceRepository(); return sharedInstance; } void registerDataSourcesImpl(Set added) { super.registerDataSourcesImpl(added); for (DataSource dataSource : added) dataSource.getRepository().addDataChangeListener(dataChangeListener, DataSource.class); } void unregisterDataSourcesImpl(Set removed) { super.unregisterDataSourcesImpl(removed); for (DataSource dataSource : removed) dataSource.getRepository().removeDataChangeListener(dataChangeListener); } private DataSourceRepository() { registerDataSource(DataSource.ROOT); } private class Listener implements DataChangeListener { public void dataChanged(DataChangeEvent event) { Set added = event.getAdded(); Set removed = event.getRemoved(); if (!added.isEmpty() || !removed.isEmpty()) changeDataSources(added, removed); } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/StatefulDataSource.java0000644000175000017500000000521213767155557030674 0ustar apoapo/* * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource; import org.graalvm.visualvm.core.datasupport.Stateful; /** * * @author Tomas Hurka * @author Jiri Sedlacek */ public abstract class StatefulDataSource extends DataSource implements Stateful { private int state = STATE_UNKNOWN; private int modCount; private final Object stateLock = new Object(); protected StatefulDataSource() { this(STATE_AVAILABLE); } protected StatefulDataSource(int state) { this.state = state; } public final int getState() { synchronized (stateLock) { return state; } } public final int getModCount() { synchronized (stateLock) { return modCount; } } protected final void setState(final int newState) { synchronized (stateLock) { final int oldState = state; state = newState; if (oldState != newState && newState == STATE_AVAILABLE) { modCount++; } if (DataSource.EVENT_QUEUE.isRequestProcessorThread()) { getChangeSupport().firePropertyChange(PROPERTY_STATE, oldState, newState); } else { DataSource.EVENT_QUEUE.post(new Runnable() { public void run() { getChangeSupport().firePropertyChange(PROPERTY_STATE, oldState, newState); } }); } } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/datasource/Storage.java0000644000175000017500000003675713767155557026560 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.datasource; import org.graalvm.visualvm.core.datasupport.Utils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.text.MessageFormat; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; /** * Storage for a DataSource. * * @author Jiri Sedlacek */ public final class Storage { private static final String VISUALVM_TMP_DIR = System.getProperty("visualvm.tmpdir"); // NOI18N private static final String TEMPORARY_STORAGE_DIRNAME = "visualvm.dat"; // NOI18N private static final String TEMPORARY_STORAGE_DIRNAME_EX = "visualvm_{0}.dat"; // NOI18N private static final String PERSISTENT_STORAGE_DIRNAME = "repository"; // NOI18N private static final Logger LOGGER = Logger.getLogger(Storage.class.getName()); /** * Default extension for storage file. */ public static final String DEFAULT_PROPERTIES_EXT = ".properties"; // NOI18N private static final Object temporaryStorageDirectoryLock = new Object(); // @GuardedBy temporaryStorageDirectory private static File temporaryStorageDirectory; private static final Object temporaryStorageDirectoryStringLock = new Object(); // @GuardedBy temporaryStorageDirectoryString private static String temporaryStorageDirectoryString; private static final Object persistentStorageDirectoryLock = new Object(); // @GuardedBy persistentStorageDirectory private static File persistentStorageDirectory; private static final Object persistentStorageDirectoryStringLock = new Object(); // @GuardedBy persistentStorageDirectoryString private static String persistentStorageDirectoryString; private final File directory; private final File propertiesFile; private Properties properties; /** * Creates new instance of Storage for storing temporary data. The Storage * directory is initialized by getTemporaryStorageDirectory() value. */ public Storage() { this(new File(getTemporaryStorageDirectoryString())); // Do not create immediately } /** * Creates new instance of Storage. * * @param directory directory where storage data will be stored. */ public Storage(File directory) { this(directory, null); } /** * Creates new instance of Storage. * * @param directory directory where storage data will be stored. * @param propertiesFile filename of storage file. */ public Storage(File directory, String propertiesFile) { if (directory == null) throw new NullPointerException("Directory cannot be null"); // NOI18N if (directory.isFile()) throw new IllegalArgumentException("Not a valid directory: " + directory); // NOI18N this.directory = directory; this.propertiesFile = propertiesFile != null ? new File(directory, propertiesFile) : null; } /** * Returns true if storage directory exists, false otherwise. * * @return true if storage directory exists, false otherwise. */ public synchronized boolean directoryExists() { return directory.exists(); } /** * Returns storage directory. * * @return storage directory. */ public synchronized File getDirectory() { if (!Utils.prepareDirectory(directory)) throw new IllegalStateException("Cannot create storage directory " + directory); // NOI18N return directory; } /** * Returns defined custom property. * * @param key property name. * @return defined custom property. */ public String getCustomProperty(String key) { return getCustomProperties(new String[] { key })[0]; } /** * Returns defined custom properties. * * @param keys property names. * @return defined custom properties. */ public synchronized String[] getCustomProperties(String[] keys) { String[] values = new String[keys.length]; Properties prop = getCustomProperties(false); if (prop != null) for (int i = 0; i < keys.length; i++) values[i] = prop.getProperty(keys[i]); return values; } /** * Sets persistent custom property. * Since VisualVM 1.2 clears the property for null value. * * @param key property name. * @param value property value or (since VisualVM 1.2) null */ public void setCustomProperty(String key, String value) { setCustomProperties(new String[] { key }, new String[] { value }); } /** * Sets persistent custom properties. * Since VisualVM 1.2 a property is cleared for null value. * * @param keys property names. * @param values property values. */ public synchronized void setCustomProperties(String[] keys, String[] values) { Properties prop = getCustomProperties(true); for (int i = 0; i < keys.length; i++) if (values[i] != null) prop.put(keys[i], values[i]); else prop.remove(keys[i]); storeCustomProperties(); // NOTE: this could be done lazily if storeCustomProperties() was public } /** * Clears custom property. * * @param key property name */ public void clearCustomProperty(String key) { clearCustomProperties(new String[] { key }); } /** * Clears custom properties. * * @param keys property names */ public synchronized void clearCustomProperties(String[] keys) { Properties prop = getCustomProperties(false); if (prop != null) for (int i = 0; i < keys.length; i++) prop.remove(keys[i]); storeCustomProperties(); // NOTE: this could be done lazily if storeCustomProperties() was public } /** * Returns true if the Storage contains any custom properties, false otherwise. * * @return true if the Storage contains any custom properties, false otherwise */ public synchronized boolean hasCustomProperties() { Properties prop = getCustomProperties(false); return prop != null && !prop.isEmpty(); } /** * Saves persistent custom properties to a file. * * @param file file where the properties will be saved. */ public synchronized void saveCustomPropertiesTo(File file) { if (file == null) throw new NullPointerException("File cannot be null"); // NOI18N if (file.isDirectory()) throw new IllegalArgumentException("Not a valid file: " + file); // NOI18N Properties prop = getCustomProperties(false); if (prop != null && !prop.isEmpty()) storeProperties(prop, file); } /** * Deletes properties file. */ public synchronized void deleteCustomPropertiesStorage() { if (propertiesFile != null && propertiesFile.exists()) if (!propertiesFile.delete()) propertiesFile.deleteOnExit(); } /** * Returns default storage directory for temporary (runtime) DataSource data * * @return default storage directory for temporary (runtime) DataSource data */ public static String getTemporaryStorageDirectoryString() { synchronized(temporaryStorageDirectoryStringLock) { if (temporaryStorageDirectoryString == null) { if (VISUALVM_TMP_DIR != null) { temporaryStorageDirectoryString = new File(VISUALVM_TMP_DIR).getAbsolutePath() + File.separator + TEMPORARY_STORAGE_DIRNAME; } else { String tmpDir = System.getProperty("java.io.tmpdir"); // NOI18N String storageDir; String userDir = System.getProperty("user.home"); // NOI18N if (userDir != null && !userDir.isEmpty()) { String userName = new File(userDir).getName(); storageDir = MessageFormat.format(TEMPORARY_STORAGE_DIRNAME_EX, userName); } else { storageDir = TEMPORARY_STORAGE_DIRNAME; } temporaryStorageDirectoryString = new File(tmpDir).getAbsolutePath() + File.separator + storageDir; } } return temporaryStorageDirectoryString; } } /** * Returns default storage directory for temporary (runtime) DataSource data. * This directory is deleted when VisualVM session finishes, eventually on * new VisualVM session startup. * * @return default storage directory for temporary (runtime) DataSource data */ public static File getTemporaryStorageDirectory() { synchronized(temporaryStorageDirectoryLock) { if (temporaryStorageDirectory == null) { String temporaryStorageString = getTemporaryStorageDirectoryString(); temporaryStorageDirectory = new File(temporaryStorageString); if (temporaryStorageDirectory.exists() && temporaryStorageDirectory.isFile()) throw new IllegalStateException("Cannot create temporary storage directory " + temporaryStorageString + ", file in the way"); // NOI18N if (temporaryStorageDirectory.exists() && (!temporaryStorageDirectory.canRead() || !temporaryStorageDirectory.canWrite())) throw new IllegalStateException("Cannot access temporary storage directory " + temporaryStorageString + ", read&write permission required"); // NOI18N if (!Utils.prepareDirectory(temporaryStorageDirectory)) throw new IllegalStateException("Cannot create temporary storage directory " + temporaryStorageString); // NOI18N } return temporaryStorageDirectory; } } /** * Returns default storage directory for persistent DataSource data * * @return default storage directory for persistent DataSource data */ public static String getPersistentStorageDirectoryString() { synchronized(persistentStorageDirectoryStringLock) { if (persistentStorageDirectoryString == null) persistentStorageDirectoryString = new File(System.getProperty("netbeans.user")).getAbsolutePath() + File.separator + PERSISTENT_STORAGE_DIRNAME; // NOI18N return persistentStorageDirectoryString; } } /** * Returns default storage directory for persistent DataSource data * * @return default storage directory for persistent DataSource data */ public static File getPersistentStorageDirectory() { synchronized(persistentStorageDirectoryLock) { if (persistentStorageDirectory == null) { String persistentStorageString = getPersistentStorageDirectoryString(); persistentStorageDirectory = new File(persistentStorageString); if (persistentStorageDirectory.exists() && persistentStorageDirectory.isFile()) throw new IllegalStateException("Cannot create persistent storage directory " + persistentStorageString + ", file in the way"); // NOI18N if (persistentStorageDirectory.exists() && (!persistentStorageDirectory.canRead() || !persistentStorageDirectory.canWrite())) throw new IllegalStateException("Cannot access persistent storage directory " + persistentStorageString + ", read&write permission required"); // NOI18N if (!Utils.prepareDirectory(persistentStorageDirectory)) throw new IllegalStateException("Cannot create persistent storage directory " + persistentStorageString); // NOI18N } return persistentStorageDirectory; } } /** * Returns true if persistent storage directory exists, false otherwise. * @return true if persistent storage directory exists, false otherwise. */ public static boolean persistentStorageDirectoryExists() { return new File(getPersistentStorageDirectoryString()).isDirectory(); } private void storeCustomProperties() { if (properties != null && propertiesFile != null) storeProperties(properties, propertiesFile); } private Properties getCustomProperties(boolean createEmpty) { if (properties == null && propertiesFile != null) properties = loadProperties(propertiesFile); if (properties == null && createEmpty) properties = new Properties(); return properties; } private static Properties loadProperties(File file) { if (!file.exists() || !file.isFile()) return null; InputStream is = null; BufferedInputStream bis = null; try { is = new FileInputStream(file); bis = new BufferedInputStream(is); Properties properties = new Properties(); properties.loadFromXML(bis); return properties; } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error loading properties", e); // NOI18N return null; } finally { try { if (bis != null) bis.close(); if (is != null) is.close(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Problem closing input stream", e); // NOI18N } } } private static void storeProperties(Properties properties, File file) { Utils.prepareDirectory(file.getParentFile()); // Directories may not be created yet OutputStream os = null; BufferedOutputStream bos = null; try { os = new FileOutputStream(file); bos = new BufferedOutputStream(os); properties.storeToXML(os, null); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error storing properties", e); // NOI18N } finally { try { if (bos != null) bos.close(); if (os != null) os.close(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Problem closing output stream", e); // NOI18N } } } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/layer.xml0000644000175000017500000003175613767155557024007 0ustar apoapo visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/snapshot/0000755000175000017500000000000013767155557023774 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/snapshot/SnapshotCategory.java0000644000175000017500000001675513767155557030152 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.snapshot; import org.graalvm.visualvm.core.datasupport.Positionable; import java.io.File; import java.io.FilenameFilter; import javax.swing.filechooser.FileFilter; /** * Category describing a snapshot type. * Category should return POSITION_NONE for getPreferredPosition() if it's not to be shown in UI. * * @author Jiri Sedlacek * @author Tomas Hurka */ public abstract class SnapshotCategory implements Positionable { private static final String PREFIX_DIVIDER = "-"; // NOI18N /** * Category won't be displayed in UI. */ public static final int POSITION_NONE = Integer.MIN_VALUE; private final String name; private final Class type; private final String prefix; private final String suffix; private final int preferredPosition; /** * Creates new instance of SnapshotCategory. * * @param name name of the category, * @param type type of snapshots described by this category, * @param prefix prefix of files containing the snapshots (can be null), * @param suffix suffix of files containing the snapshots (can be null). * @param preferredPosition preferred position of this category within other categories when presented in UI. */ public SnapshotCategory(String name, Class type, String prefix, String suffix, int preferredPosition) { super(); this.name = name; this.type = type; this.prefix = prefix; this.suffix = suffix; this.preferredPosition = preferredPosition; } /** * Returns name of the category. * * @return name of the category. */ public final String getName() { return name; } /** * Returns type of snapshots described by this category. * * @return type of snapshots described by this category. */ public final Class getType() { return type; } /** * Returns preferred position of this category within other categories when presented in UI. * * @return preferred position of this category within other categories when presented in UI. */ public final int getPreferredPosition() { return preferredPosition; } /** * Returns true if the category can restore snapshot from a saved file, false otherwise. * * @return true if the category can restore snapshot from a saved file, false otherwise. */ public boolean supportsOpenSnapshot() { return false; } /** * Opens a saved snapshot. * Default implementation does nothing, custom implementations should open * an Open File dialog and open the choosen snapshot. * Throws an UnsupportedOperationException if supportsOpenSnapshot() returns false. * * @param file saved snapshot. */ public void openSnapshot(File file) { throw new UnsupportedOperationException("Open snapshot not supported"); // NOI18N } /** * Returns prefix of files containing the snapshots. * * @return prefix of files containing the snapshots. */ protected final String getPrefix() { return prefix; } /** * Returns suffix of files containing the snapshots. * * @return suffix of files containing the snapshots. */ protected final String getSuffix() { return suffix; } protected boolean isSnapshot(File file) { // String pref = getPrefix(); String suff = getSuffix(); // Fix for #92 - supported snapshot is detected just based on the SUFFIX by default // if (pref != null && !fileName.startsWith(pref + PREFIX_DIVIDER)) return false; if (suff != null && !file.getName().endsWith(suff)) return false; return true; } protected boolean isSnapshot(String fileName) { return isSnapshot(new File(fileName)); } protected String getBaseFileName(String fileName) { String pref = getPrefix(); String suff = getSuffix(); if (pref != null && fileName.startsWith(pref + PREFIX_DIVIDER)) fileName = fileName.substring(pref.length() + 1); if (suff != null && fileName.endsWith(suff)) fileName = fileName.substring(0, fileName.length() - suff.length()); return fileName; } protected String getTimeStamp(String fileName) { String timeStamp = null; try { long time = Long.parseLong(getBaseFileName(fileName)); return SnapshotsSupport.getInstance().getTimeStamp(time); } catch (NumberFormatException e) {} return timeStamp; } /** * Creates an unique name for a new snapshot. * * @return unique name for a new snapshot. */ public String createFileName() { String pref = getPrefix(); String suff = getSuffix(); String fileName = System.currentTimeMillis() + ""; if (pref != null) fileName = pref + PREFIX_DIVIDER + fileName; if (suff != null) fileName = fileName + suff; return fileName; } /** * Returns a FilenameFilter for the category. * * @return FilenameFilter for the category. */ public FilenameFilter getFilenameFilter() { return new FilenameFilter() { public boolean accept(File dir, String name) { return isSnapshot(new File(dir,name)); } }; } /** * Returns a FileFilter for the category. * * @return FileFilter for the category. */ public FileFilter getFileFilter() { return new FileFilter() { public boolean accept(File f) { return f.isDirectory() || isSnapshot(f); } public String getDescription() { String suff = getSuffix(); return getName() + (suff != null ? " (*" + suff + ")" : ""); // NOI18N } }; } // public FileView getFileView() { // return new FileView() { //// public Icon getIcon(File f) { //// return new ImageIcon(SnapshotCategory.this.getI); //// } // public String getName(File file) { // if (isSnapshot(file)) return getDisplayName(file); // else return null; // } // }; // } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/snapshot/Snapshot.java0000644000175000017500000001771713767155557026453 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.snapshot; import org.graalvm.visualvm.core.datasource.DataSource; import org.graalvm.visualvm.core.datasource.Storage; import org.graalvm.visualvm.core.datasupport.Utils; import org.graalvm.visualvm.core.ui.DataSourceWindowManager; import java.io.File; import java.util.Objects; /** * Abstract implementation of Snapshot. * * @author Jiri Sedlacek */ public abstract class Snapshot extends DataSource { /** * Named property for snapshot file. */ public static final String PROPERTY_FILE = "prop_file"; // NOI18N /** * Named property to control whether the snapshot view will be closable. * * Value true means always closable, value false means never closable, * any other value or property not defined means the default behavior. */ protected static final String PROPERTY_VIEW_CLOSABLE = "prop_view_closable"; // NOI18N private File file; private final SnapshotCategory category; private String snapshotID; /** * Creates new instance of AbstractSnapshot with the data stored in a file. * * @param file file where snapshot is saved, * @param category category of the snapshot. */ public Snapshot(File file, SnapshotCategory category) { this(file, category, null); } /** * Creates new instance of AbstractSnapshot with the data stored in a file and defined master. * * @param file file where snapshot is saved, * @param category category of the snapshot, * @param master DataSource in whose window the snapshot will be displayed. */ public Snapshot(File file, SnapshotCategory category, DataSource master) { super(master); this.file = file; this.category = category; } /** * Returns snapshot file or null if no file context is defined or snapshot doesn't support saving to file. * * @return snapshot file or null if no file context is defined or snapshot doesn't support saving to file. */ public final File getFile() { return file; } /** * Returns snapshot category. * * @return snapshot category. */ public final SnapshotCategory getCategory() { return category; } /** * Sets the file where data of this snapshot are stored. * * @param newFile file where data of this snapshot are stored. */ protected final void setFile(File newFile) { if (file == null && newFile == null) return; File oldFile = file; file = newFile; if (oldFile == null) snapshotID = null; getChangeSupport().firePropertyChange(PROPERTY_FILE, oldFile, newFile); } /** * Saves the snapshot to a directory. * * @param directory directory where to save the snapshot. */ public void save(File directory) { File f = getFile(); if (f != null && f.isFile()) { // File is not null and will be copied to the directory File saveFile = Utils.getUniqueFile(directory, f.getName()); Utils.copyFile(f, saveFile); // If there are any custom properties defined, store them to .properties getStorage().saveCustomPropertiesTo(new File(saveFile.getAbsolutePath() + Storage.DEFAULT_PROPERTIES_EXT)); } } /** * Returns true if the snapshot supports saving to an external (user defined) destination, false otherwise. * * @return true if the snapshot supports saving to an external (user defined) destination, false otherwise. */ public boolean supportsSaveAs() { return false; } /** * Saves the snapshot to an external (user defined) destination. * Default implementation does nothing, custom implementations should open * a Save File dialog and save the snapshot to selected destination. * Throws an UnsupportedOperationException if supportsSaveAs() returns false. */ public void saveAs() { throw new UnsupportedOperationException("Save as not supported"); // NOI18N } /** * Returns true if the snapshot can be deleted by the user from UI, false otherwise. * * @return true if the snapshot can be deleted by the user from UI, false otherwise. */ public boolean supportsDelete() { return true; } /** * Deletes the snapshot. */ public void delete() { DataSourceWindowManager.sharedInstance().closeDataSource(this); getOwner().getRepository().removeDataSource(this); } protected void remove() { final File f = getFile(); if (f != null) Utils.FILE_QUEUE.post(new Runnable() { public void run() { Utils.delete(f, true); } }); setFile(null); super.remove(); } protected Storage createStorage() { File f = getFile(); if (f != null) { String customPropertiesFileName = f.getName() + Storage.DEFAULT_PROPERTIES_EXT; if (f.isDirectory()) { return new Storage(f, customPropertiesFileName); // if (new File(f, customPropertiesFileName).exists()) return new Storage(f, customPropertiesFileName); // else return new Storage(f); } else if (f.isFile()) { File directory = f.getParentFile(); return new Storage(directory, customPropertiesFileName); // if (new File(directory, customPropertiesFileName).exists()) return new Storage(directory, customPropertiesFileName); // else return new Storage(directory); } } return super.createStorage(); } /** * Returns true if the Snapshot is present in other Snapshot's repository, false otherwise. * * @return true if the Snapshot is present in other Snapshot's repository */ protected final boolean isInSnapshot() { return getOwner() instanceof Snapshot; } /** * Returns ID of the Snapshot. The ID should be based on the snapshot file * if available and will only be computed for the first non-null file. * * @return ID of the Snapshot */ protected String computeSnapshotID() { File f = getFile(); return f == null ? super.hashCode() + "-no_file" : f.getPath(); // NOI18N } private String getSnapshotID() { if (snapshotID == null) snapshotID = computeSnapshotID(); return snapshotID; } public boolean equals(Object o) { if (!(o instanceof Snapshot)) return false; return Objects.equals(getSnapshotID(), ((Snapshot)o).getSnapshotID()); } public int hashCode() { return Objects.hashCode(getSnapshotID()); } } visualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/snapshot/options/0000755000175000017500000000000013767155557025467 5ustar apoapovisualvm-2.0.6/visualvm/core/src/org/graalvm/visualvm/core/snapshot/options/Openfile.java0000644000175000017500000001162513767155557030100 0ustar apoapo/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.visualvm.core.snapshot.options; import org.graalvm.visualvm.core.snapshot.RegisteredSnapshotCategories; import org.graalvm.visualvm.core.snapshot.SnapshotCategoriesListener; import org.graalvm.visualvm.core.snapshot.SnapshotCategory; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; import javax.swing.Timer; import javax.swing.filechooser.FileFilter; import org.netbeans.api.sendopts.CommandException; import org.netbeans.spi.sendopts.Env; import org.netbeans.spi.sendopts.Option; import org.netbeans.spi.sendopts.OptionProcessor; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.util.NbBundle; /** * Handling of --openfile commandline option * * @author Tomas Hurka */ public final class Openfile extends OptionProcessor { private Option openfile = Option.requiredArgument(Option.NO_SHORT_NAME,"openfile"); // NOI18N private static final int TIMEOUT = 5000; public Openfile() { openfile = Option.shortDescription(openfile, "org.graalvm.visualvm.core.snapshot.options.Bundle", "MSG_OPENFILE"); } protected Set