|
|
|
Posted
1 day
ago
The purpose of this article is to expand on Geertjan's blog entries about explorer trees and expansion icons. The first article found at https://blogs.oracle.com/geertjan/entry/no_expansion_key_when_no works well for static trees. When a node is
... [More]
constructed, it determines whether or not the underlying data object or bean has children. If there are no children, it becomes a leaf node. If... [Less]
|
|
Posted
2 days
ago
Let's say your requirement is that you need to open a ZIP file into an application, modify its content, and then ZIP it all up again. And you're using the NetBeans Platform. Here's the general approach to take: Learn from
... [More]
Similar Code. The very first thing to do is to ask yourself: "Does NetBeans IDE or any other NetBeans Platform application do something similar?" The answer in this case is Yes because NetBeans IDE has "File | Import Project | From ZIP". So you can look in the NetBeans source code and get some nice code relating to java.util.zip.ZipInputStream, while FileUtil.copy is also great to use.
Create a NetBeans Platform Application. When you create the application, go to the "ide" cluster in the Project Properties dialog of the application and include the "Image" module, as well as the "XML Text Editor" module, together with all the related modules (simply click the Resolve button) and then you'll have some cool editors immediately available when you open the content of the ZIP file in the application. Also include "User Utilities" so that you have "File | Open File" in your application.
Use CentralLookup. We're going to end up creating a Node hierarchy, i.e., we'll be using classes such as Node, ChildFactory, BeanTreeView, and ExplorerManager. These integrate very well with the Lookup concept. That is, when objects of interest (e.g., a folder that contains the newly unzipped ZIP file) are registered in the Lookup, you will create new Nodes in the Node hierarchy.
But which Lookup to use? Lookup.getDefault? No. That gives you access to META-INF/services, which is the standard Java 6 extension mechanism. Utilities.actionsGlobalContext? No. That gives you access to the currently selected object. We don't care about selection in this scenario. Whenever a ZIP file is unzipped into a new folder, we need to add that folder to some kind of observable list, i.e., Lookup, to which our Node hierarchy is listening. Therefore, copy CentralLookup into your application and use that. Here it is.
Recognize ZIP Files. Create a new MIME type (i.e., use the New File Type wizard) to recognize files with a ZIP extension as "application/x-zip", remove all the editor related code in the DataObject (because you don't want to open the ZIP file into an editor, instead, you want to open the files within the ZIP file into an editor), and implement Openable.
When the OpenAction is invoked, which happens automatically when you try to open a file via "File | Open File" (or from the Favorites window), your implementation of Openable will be called. In that Openable implementation, unzip the ZIP file into a new folder and then register that folder as a FileObject in the CentralLookup.
Create a Node Hierarchy. Create a TopComponent in "explorer" mode. Create a ChildFactory that implements LookupListener, listening to CentralLookup for new FileObjects. When a new FileObject is present, wrap it in a FilterNode and refresh the Node hierarchy.
Listen for Changes in the Folder. Use FileObject.addRecursiveListener() to listen for additions/deletions/changes in the folder. That gives you a way to mark the Node hierarchy as being "dirty", in some way, e.g., publish a Savable into the Lookup of the TopComponent or the Node and then the Save action will become enabled to save the Node hierarchy back into a ZIP file. And how to implement that? Well, look at the source code for "File | Export Project | To ZIP" in the NetBeans sources.
I've completed the first 5 steps above (and everything in step 6 is done, too, i.e., the Savable is added to the Node Lookup when appropriate and, when invoked, an "Export to ZIP" dialog is shown, which works as one might expect) and checked in the sources here:
https://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.3/misc/OpenZIP
Here's what the result looks like after opening a ZIP file, via "File | Open File", e.g., the images that you see will open into the NetBeans image editor automatically when they are double-clicked, because FilterNode is used to wrap the unzipped folder and its children:
Just for fun, I made the feature modular, i.e., the infrastructure for recognizing and parsing ZIP files is in one module, the explorer view is in another module, and a Utils module is included to provide the CentralLookup, which is the communication mechanism between the two modules:
Above you see everything I did to make this work, not very much when you consider the amount of features provided at the end, e.g., an application frame, window system, modular infrastructure, plugin system, menubar, toolbar, image editor, XML editor, ZIP file recognition, ZIP file parsing, rendering of ZIP file content in a Swing JTree (via ExplorerManager and BeanTreeView):
Finally, note that what you see above in the "ZIP Window" are not actually ZIP files. They're FilterNodes on top of folders created from ZIP files, with the display name of the FilterNode (and all its content, i.e., its children) derived from the original node, which is the folder created from unzipping the ZIP file. [Less]
|
|
Posted
2 days
ago
Session video: "JavaEE ...And The Bloat Is Gone at InfoShare" in Gdansk. This time no live coding, just slides :-) See you at Java EE Workshops at MUC Airport, contents of the video are also covered at the Architecture Day! See also
... [More]
other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.
Real World Java EE Workshops [Airport Munich]> [Less]
|
|
Posted
2 days
ago
A first step in porting an application, especially one you don't really know, is to run the application in the NetBeans debugger and then take a GUI snapshot of it. That lets you relate the GUI elements in the application to their source code, very
... [More]
easily, as shown below for Wandora:
It's kind of similar to the Chrome integration for HTML5 applications! There, you can click in the browser and then see where items are defined in the IDE. In the above screenshot, you're actually doing something very similar, but then for Java desktop applications, whether in Swing or JavaFX. [Less]
|
|
Posted
3 days
ago
Project News Just Released: NetBeans IDE 7.3.1 with Java EE 7 Support! NetBeans IDE 7.3.1 is an update to NetBeans IDE 7.3 and offers full support for Java EE 7 development and contains integ Preview Text:
... [More]
New releases: NetBeans IDE 7.3.1, Java EE 7 and GlassFish 4.0. Register for Virtual Java Developer Days. A plugin for POV-Ray syntax,... [Less]
|
|
Posted
3 days
ago
Wandora is a general purpose information extraction, management and publishing application based on Topic Maps and Java. Wandora has a graphical user interface, layered and merging information model, multiple visualization models, huge collection of
... [More]
information extraction, import and export options, embedded HTTP server with several output modules and open plug-in architecture.
Here it is:
The sources are in a handy NetBeans project:
Interestingly, attempts have been made to port Wandora to the NetBeans Platform, for very good reasons:
http://www.wandora.org/forum/viewtopic.php?f=11&t=50
But success has been elusive:
http://www.wandora.net/wandora/forum/viewtopic.php?f=11&t=95
The application is clearly large and understandably a massive undertaking to port it. But I'm going to try it nonetheless and report on my progress here. [Less]
|
|
Posted
5 days
ago
The highest ranked NetBeans theme on the truly brilliant NetBeans Themes site replicates Sublime Text and looks really great. Click to enlarge the screenshot below to see it in context in NetBeans IDE 7.3.1: I have no idea who is behind
... [More]
that NetBeans Themes site, but it's an amazing contribution to the NetBeans community. Just take a look at the themes on the site, choose one, download its ZIP file, go to Tools | Options in the IDE, click Import and then browse to the ZIP you downloaded. You can also upload your own themes to the site, i.e., configure NetBeans IDE the way you want it to be, export the settings by clicking Export in Tools | Options, click Upload Yours on the site and you're done. Wonderfully simple and a wonderful site!
In other news. My internet discovery of the day is Comedians In Cars Getting Coffee! Excellent. [Less]
|
|
Posted
6 days
ago
The JavaMagazine article: Integrating JavaFX Scene Builder Into Enterprise Applications discusses a pragmatic integration of JavaFX Scene Builder into the "Enterprise Application Workflow". DI is used to integrate backend services and
... [More]
composition of visually created views.
See also:
http://afterburner.adam-bien.com https://github.com/AdamBien/airhacks-control
See you at Java EE Workshops at MUC Airport. The material from the article is going to be also covered at the JavaEE UI day!
Real World Java EE Workshops [Airport Munich]> [Less]
|
|
Posted
6 days
ago
I've been actively and naturally using Ubuntu since Ubuntu 7.04 "Feisty Fawn", which means, of course, April 2007, as described here. Now let's flash forward six years or so to yesterday. Yesterday I was on 12.04 "Precise Pangolin", today on the
... [More]
latest version 13.04 "Raring Ringtail", which means I skipped 12.10 "Quantal Quetzal". In general, looking back in this blog over the years, I seem to have installed more "04" releases than "10" releases, which is interesting. I tend to skip one Ubuntu release per year, more or less. Not sure why, exactly. Part of it is that I'm too lazy to backup my data prior to an upgrade and can probably only handle the occasional frantic moments of despair (e.g., the sudden pause in the upgrade garbles that could either be an internal crash or the tiny technicians in my computer simply needing a coffee break) in the middle of upgrades on an annual basis.
The process which I followed to get from 12.04 to 13.04 is completely illustrative of how software updates happen and is interesting from a NetBeans IDE point of view, too. Often, on Twitter and on mailing lists, at least 60% of NetBeans-related questions I see immediately cause a small fuse to blow in my mind while I think, almost out loud: "Well, why don't you just go to the NetBeans Wiki and you'll find the answer there, very easily." But, of course, that's not how we gather info nowadays, we simply go to Google even though we know that each and every software product has its own dedicated site with highly detailed information. Then, when we don't find the answer we're looking for (or we think we're looking for) within 30 seconds, we start yelling "Help this product sucks" on Twitter.
And that's also why I can't explain exactly how I got from 12.04 to 13.04. I basically googled around and somewhere found a command line that I assumed would bring me directly to 13.04 but got me to 12.10. Then I went to the Update Manager, which (several hours later, zillions of new files later, while leaving everything else miraculously untouched) brought me to 13.04.
The other interesting thing is why I wanted to move to 13.04 in the first place. I would have been perfectly happy to have stayed at 12.04 if it wasn't for the fact that the VPN Cisco AnyConnect Client doesn't (or at least not without various low level tweaks, from a variety of random unreliable and contradictory online searches) work on 12.04. It worked before that, but from 12.04 onwards, I couldn't VPN into internal company sites that I need to do my work and had to use a Windows laptop purely for that reason only. That's why I upgraded. However, many many hours later, when I was finally on 13.04, I had exactly the same problems as before! Then I moved to "openconnect", which solved all my VPN problems immediately. But this aspect is interesting from a NetBeans point of view, where I often find myself thinking in response to some question or other: "Come on, you're asking this question, and then it turns out you're on NetBeans IDE 6.9 while the latest release is NetBeans IDE 7.3! Never thought of upgrading, in all these years..?" Etc. Then again, on the other hand, switching from one release of NetBeans IDE to another is a LOT simpler (takes a lot less time, is a lot less risky and a lot less irreversible) than switching from one version of Ubuntu to another.
Finally, a missing piece in my software toolbox on Ubuntu was Cisco IP Communicator, a soft phone, which only has Windows and Mac distributions. I never had it (nor tried to have it) on Ubuntu before but thought I'd give it a try since it would be the final missing piece on my Ubuntu from my Windows world. And, lo and behold, it works perfectly (well, aside from the Audio bit at the beginning, but that's a known problem) on Ubuntu too, if you install it via Wine. (Maybe the biggest plus from the process of updating to Ubuntu 13.04 is the side effect that I now know a lot more about Wine, i.e., the ".wine" folder is a fascinating replication of a Windows operating system.)
And now I'm on 13.04, the world isn't a very different place (not noticed anything new, so far, maybe performance improvements, but maybe mostly because I always assume each release of anything must have performance enhancements somehow). I used to have absolute nightmares setting up Wifi after an Ubuntu upgrade, but everything worked immediately out of the box. So far I don't have anything to mention in terms of differences, but certainly the smoothest upgrade (especially since I upgraded from 12.04 to 12.10 and then 13.04, all in the same set of hours) I have ever experienced. And good to know I'm on the latest release of Ubuntu again! [Less]
|
|
Posted
7 days
ago
Glassfish v4 (the "Killer Appserver") is available for download The glassfish.org website was redesigned as well. It looks clean and fresh. I'm using Glassfish v4 for a while in daily development--it looks promising. Glassfish v4
... [More]
also ships with NetBeans (JavaEE). With NetBeans and Glassfish you will get the most efficient JavaEE 7 environment to start (double click, wait 2 minutes) and to develop your applications (everything you need comes out-of-the-box--without any plugin hell).
See you at Java EE Workshops at MUC Airport--I will use Glassfish v4 for live hacking!
Real World Java EE Workshops [Airport Munich]> [Less]
|