Česky   |  Deutsch   |  English   |  Español   |  Français   |  Indonesia   |  日本語   |  한글   |  Polski   |  Português (BR)   |  Türkçe   |  中文   |  正體中文   |  Your Language  
PlanetNetbeans
Planet NetBeans is an aggregation of NetBeans related musings from all over the Blogosphere.
Feeds
[RSS 1.0 Feed] [RSS 2.0 Feed]
[FOAF Subscriptions] [OPML Subscriptions]
Do you blog about NetBeans ? Add your blog to PlanetNetBeans.
Feed Subscriptions
NetBeans Zone - The social network for developers (feed)
APIDesign - Blogs (feed)
blogtrader - Blog (feed)
David R. Heffelfinger (feed)
Carsten Zerbst's Weblog (feed)
Winston Prakash's Weblog (feed)
Anchialas' Java Blog (feed)
Blog of markiewb (feed)
Paulo Canedo » NetBeans English (feed)
Java, business and... NetBeans ! [[ Jonathan Lermitage ]] - NetBeans IDE (feed)
Michael's blog » NetBeans (feed)
Allan Lykke Christensen » NetBeans (feed)
Inspiration and Expression » Netbeans (feed)
open source. open mind. (feed)
J. O'Conner » NetBeans (feed)
ProNetBeans (feed)
Adam Bien (feed)
Ignacio Sánchez Ginés » NetBeans (feed)
Bernhard's Weblog (feed)
Michel Graciano's Weblog (feed)
Ramon.Ramos (feed)
Ozone and Programming » netbeans (feed)
NetBeans Ruminations » NetBeans (feed)
Tiplite » netbeans (feed)
Arun Gupta, Miles to go ... (feed)
Geertjan's Blog (feed)
.JARa's Bilingual Weblog (feed)
JavaFX Composer (feed)
The Java Jungle (feed)
Jesse Glick (feed)
Martin Grebac (feed)
The NetBeans Community Podcast (feed)
NetBeans Profiler (feed)
NetBeans for PHP (feed)
NetBeans Web Client (feed)
Rechtacek's (feed)
Virtual Steve (feed)
My First Blog - Satyajit Tripathi (feed)
The Aquarium (feed)
Tinuola Awopetu (feed)
Insert Witty Irony Here (feed)
mkleint (feed)
Roger Searjeant's blog (feed)
Optonline Webmail (feed)
Bistro! 2.0 (feed)
James Selvakumar's Blog » netbeans (feed)
nB gUru » NetBeans (feed)
Newsintegrator Blog » netbeans (feed)
Praxis LIVE » NetBeans (feed)
TechAshram » NetBeans (feed)
There's no place like 127.0.0.1 » Netbeans (feed)
Anuradha (feed)
Netbeans6/6.5 my best practices (feed)
Java Evangelist John Yeary's Blog (feed)
Need to find a title (feed)
Michel Graciano's Blog (feed)
Neil's Dev Stuff (feed)
Shanbag's Blog (ರಜ&#3236 &#3250&#3275&#3221) (feed)
Computer says null; (feed)
NetBeans Adventures, Java and more (feed)
NetBeans Community Docs Blog (feed)
Antonio's blog (feed)
The Netbeans Experience (feed)
An Open Source Fascicule (feed)
NbPython/ jpydbg / pymvs (feed)
Manikantan's Netbeans (feed)
Wade Chandler's Programming Blog (feed)
Devlin's Lab (feed)
In perfect (spherical) shape (feed)
Alex Kotchnev's Blog (feed)
Big Al's Blog (feed)
Code Snakes (feed)
Van Couvering Is Not a Verb (feed)
Diego Torres Milano's blog (feed)
Oliver Wahlen's Blog (feed)
Vroom Framework (feed)
Messages from mrhaki (feed)
Jeff's Blog (feed)
Shuttle between Galaxies (feed)
Welcome to my live... (feed)
ryandelaplante.com (feed)
Netbeans IDE Blog by Tushar Joshi, Nagpur (feed)
Devel Blog (feed)
diamond-powder (feed)
Where's my Blog?!

Powered by:    Planet

Last updated:
June 19, 2013 06:04 AM
All times are UTC

Sponsored by
sponsored by Oracle

visit NetBeans website
Geertjan's Blog - June 18, 2013 07:02 AM
Integrating ZIP Features in a NetBeans Platform Application

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:

  1. Learn from 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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. 

Adam Bien - June 18, 2013 05:51 AM
JavaEE ...And The Bloat Is Gone (Session at InfoShare Conference)

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 other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 17, 2013 08:30 PM
Porting Wandora to the NetBeans Platform (Part 2)

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 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.

NetBeans Zone - The social network for developers - June 17, 2013 03:37 PM
NetBeans Weekly News (Issue #592 - June 17, 2013 )

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:  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,...

Geertjan's Blog - June 16, 2013 07:58 PM
Porting Wandora to the NetBeans Platform (Part 1)

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 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. 

Geertjan's Blog - June 15, 2013 07:00 AM
Sublime Text Look & Feel for NetBeans IDE

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 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.

Adam Bien - June 14, 2013 09:04 AM
MVP, IoC, DI and WYSIWG …with JavaFX--A Free Article

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 composition of visually created views.

See also:

  1. http://afterburner.adam-bien.com
  2. 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]>

Geertjan's Blog - June 14, 2013 07:00 AM
Ubuntu 13.04

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 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!

Adam Bien - June 13, 2013 08:05 AM
Glassfish v4 Is Out (with JavaEE 7)

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 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]>

Geertjan's Blog - June 13, 2013 07:00 AM
Ruby on Rails in NetBeans IDE 7.3.1

NetBeans IDE 7.3.1 is released, hurray, etc. Now let's look at using Ruby on Rails in NetBeans IDE 7.3.1.

Go here, to the NetBeans plugin for JRuby maintained by Tom Enebo and the JRuby community (since there really isn't anyone better in the world to be responsible for a tooling plugin than the community itself) and click the Download button:

http://plugins.netbeans.org/plugin/38549/ruby-and-rails

Now you have a ZIP file. Unzip it. Go to Tools | Plugins in NetBeans IDE 7.3.1. Select all the NBMs from the unzipped file. Make very sure to change the "Files of Type" filter to "All", so that you can include the JRuby JAR, which you must have, otherwise the NBMs will not be able to be installed. I.e., you can include the JAR, as shown below, which is in the ZIP file, but, again, make sure to change the filter from the default, so that not only NBM files are selectable.

When you click Install above, you'll see this dialog, just accept what it tells you:

Once the installation is complete, go to File | New Project and there you'll see the Depot Application, which is a nice sample to get you started:

Now you have a full-blown and very fast/smooth editor for your code (click to enlarge the image below):

You can configure a bunch of things in the Project Properties dialog, i.e., per project:

Also, there are IDE-wide configuration settings you can configure in Tools | Options:

And, aside from the sample shown above, there are various starting points for your own applications:

So dive in today, the water is good!

NetBeans Zone - The social network for developers - June 12, 2013 05:40 PM
NetBeans IDE 7.3.1 Now Available with Java EE 7 Support

NetBeans IDE 7.3.1 is an update to NetBeans IDE 7.3 and includes the following highlights: Preview Text:  NetBeans IDE 7.3.1 is an update to NetBeans IDE 7.3 and features full support for Java EE 7 development. Legacy Sponsored:  unsponsored

Arun Gupta, Miles to go ... - June 12, 2013 04:26 PM
Java EE 7 SDK and GlassFish Server Open Source Edition 4.0 Now Available


Java EE 7 (JSR 342) is now final!

I've delivered numerous talks on Java EE 7 and related technologies all around the world for past several months. I'm loaded with excitement to share that the Java EE 7 platform specification and implementation is now in the records.

The platform has three major themes:



  • Deliver HTML5 Dynamic Scalable Applications
    • Reduce response time with low latency data exchange using WebSocket
    • Simplify data parsing for portable applications with standard JSON support
    • Deliver asynchronous, scalable, high performance RESTful Service
  • Increase Developer Productivity
    • Simplify application architecture with a cohesive integrated platform
    • Increase efficiency with reduced boiler-plate code and broader use of annotations
    • Enhance application portability with standard RESTful web service client support
  • Meet the most demanding enterprise requirements
    • Break down batch jobs into manageable chunks for uninterrupted OLTP performance
    • Easily define multithreaded concurrent tasks for improved scalability
    • Deliver transactional applications with choice and flexibility
This "pancake" diagram of the major components helps understand how the components work with each other to provide a complete, comprehensive, and integrated stack for building your enterprise and web applications. The newly added components are highlighted in the orange color:




In this highly transparent and participatory effort, there were 14 active JSRs:
  • 342: Java EE 7 Platform
  • 338: Java API for RESTful Web Services 2.0
  • 339: Java Persistence API 2.1
  • 340: Servlet 3.1
  • 341: Expression Language 3.0
  • 343: Java Message Service 2.0
  • 344: JavaServer Faces 2.2
  • 345: Enteprise JavaBeans 3.2
  • 346: Contexts and Dependency Injection 1.1
  • 349: Bean Validation 1.1
  • 352: Batch Applications for the Java Platform 1.0
  • 353: Java API for JSON Processing 1.0
  • 356: Java API for WebSocket 1.0
  • 236: Concurrency Utilities for Java EE 1.0

The newly added components are highlighted in bold.

And 9 Maintenance Release JSRs:

  • 250: Common Annotations 1.2
  • 322: Connector Architecture 1.7
  • 907: Java Transaction API 1.2
  • 196: Java Authentication Services for Provider Interface for Containers
  • 115: Java Authorization for Contract for Containers
  • 919: JavaMail 1.5
  • 318: Interceptors 1.2
  • 109: Web Services 1.4
  • 245: JavaServer Pages 2.3

Ready to get rolling ?

Binaries

Tools

Docs


A few articles have already been published on OTN:

And more are coming!

This blog has also published several TOTD on Java EE 7:


All the JSRs have been covered in the Java Spotlight podcast:

The latest issue of Java Magazine is also loaded with tons of Java EE 7 content:



Media coverage has started showing as well ...
And you can track lot more here.

You can hear the latest and greatest on Java EE 7 by watching replays from the launch webinar:



This webinar consists of:
  • Strategy Keynote
  • Technical Keynote
  • 16 Technical Breakouts with JSR Specification Leads
  • Customer, partner, and community testimonials
  • And much more
Do you feel enabled and empowered to start building Java EE 7 applications ?

Just download Java EE 7 SDK that contains GlassFish Server Open Source Edition 4.0, tutorial, samples, documentation and much more.

Enjoy!

Geertjan's Blog - June 12, 2013 02:33 PM
Adding a Palette to a MultiViewElement

The question of the day comes from Michele Vigilante from Italy who wants to combine a Palette with a MultiViewElement.

The two key references to solving this are the following:

Here's step by step how to put the pieces together, starting from the application described here:

https://blogs.oracle.com/geertjan/entry/how_to_create_a_satellite

  1. Create a Node Hierarchy. Typically you already have a hierarchy of nodes, but for the sake of argument, here's the one I'll be using, as simple as it gets:
    Node nodeHierarchy = new AbstractNode(Children.create(new ChildFactory<String>() {
        @Override
        protected boolean createKeys(List toPopulate) {
            for (int i = 0; i < 10; i++) {
                toPopulate.add("Category " + i);
            }
            return true;
        }
        @Override
        protected Node createNodeForKey(String key) {
            AbstractNode an = new AbstractNode(Children.create(new ChildFactory<String>() {
                @Override
                protected boolean createKeys(List<String> toPopulate) {
                    for (int i = 0; i < 10; i++) {
                        toPopulate.add("Item " + i);
                    }
                    return true;
                }
                @Override
                protected Node createNodeForKey(final String key) {
                    AbstractNode an = new AbstractNode(Children.LEAF, Lookups.singleton(key));
                    an.setDisplayName(key);
                    return an;
                }
            }, true));
            an.setDisplayName(key);
            return an;
        }
    }, true));
  2. Create a Palette from the Node Hierarchy. For the below, your module will need to depend on "Common Palette", which it won't be able to do unless it has been set as part of the application. Also, make sure to add the Palette to the Lookup of the MultiViewElement, so that the Palette will open/close with the MultiViewElement, together with the Lookup that has already been defined for it, by adding the following to the end of the MultiViewElement constructor:
    InstanceContent ic = new InstanceContent();
    Lookup dynamicLookup = new AbstractLookup(ic);
    lookup = new ProxyLookup(dynamicLookup, getLookup());
    ic.add(PaletteFactory.createPalette(nodeHierarchy, new PaletteActions() {
        @Override
        public Action[] getImportActions() {
            return null;
        }
        @Override
        public Action[] getCustomPaletteActions() {
            return null;
        }
        @Override
        public Action[] getCustomCategoryActions(Lookup category) {
            return null;
        }
        @Override
        public Action[] getCustomItemActions(Lookup item) {
            return null;
        }
        @Override
        public Action getPreferredAction(Lookup item) {
            return null;
        }
    }));
  3. Accept the Drop. Now, when the Visual tab opens, the user sees a Palette with items in it. Let's do something useful with the Palette, again in the MultiViewElement, somewhere in the constructor where the Scene is retrieved from the Lookup:
    scene.getActions().addAction(ActionFactory.createAcceptAction(new AcceptProvider() {
        @Override
        public ConnectorState isAcceptable(Widget widget, Point point, Transferable transferable) {
            return ConnectorState.ACCEPT;
        }
        @Override
        public void accept(Widget widget, Point point, Transferable transferable) {
            Node transferredNode = NodeTransfer.node(transferable, NodeTransfer.DND_COPY_OR_MOVE);
            String label = transferredNode.getLookup().lookup(String.class);
            if (label != null) {
                LabelWidget lw = new LabelWidget(scene, label);
                lw.setPreferredLocation(point);
                lkp.lookup(LayerWidget.class).addChild(lw);
                try {
                    String existingContent = obj.getPrimaryFile().asText();
                    String newContent = existingContent + "\n" + label;
                    OutputStream os = obj.getPrimaryFile().getOutputStream();
                    OutputStreamWriter writer = new OutputStreamWriter(os);
                    writer.write(newContent);
                    writer.flush();
                    writer.close();
                } catch (FileAlreadyLockedException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }));

    Now, when an item is dropped, if the Node has a String in its Lookup, a LabelWidget is added to the LayerWidget and the String is also added to the underlying file.

That's all you need to do to get started with a simple scenario that can be extended however you like.

All the source code discussed above is integrated into the sample:

https://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.3/misc/ABCFileTypeNavigator

Are you trying out the code discussed in this blog entry and something doesn't work for you? Go to the location above and look at the source code and/or check it out from its repo.

Geertjan's Blog - June 11, 2013 05:39 PM
JavaFX WebView & JavaFX HTMLEditor: A Tale of Two Cities

Tough times in the world of Fosfor, the EPUB Open Toolbox. Turns out that while the JavaFX WebView has perfect rendering but no editing capabilities, the JavaFX HTMLEditor has perfect editing capabilities but crap rendering.

Exhibit one is right here, with the JavaFX HTMLEditor on the left and the JavaFX WebView on the right, rendering the same XHTML file:

As can be seen, the images, CSS, and entities defined in the XHTML file above are perfectly rendered in WebView, but not at all in the HTMLEditor. It seems to me that the HTMLEditor is meant for rendering text only, nothing else.

I then hacked my own HTMLEditor on top of the JavaFX HTMLEditor, which searches through all the text prior to rendering and uses the file protocol to locally locate images and CSS:

https://java.net/projects/epubopentoolbox/sources/epub/content/jepub-browser-external/src/main/java/com/eirik/jepub/browser/external/HTMLEditorControl.java

The result is as follows, i.e., I've fixed the images and CSS problem, but not the entities, yet:

In short, I'm going to try and create a set of service providers for a "fixHTMLEditorRendering" service which will pre-process images, CSS, and HTML entities prior to them being rendered in the JavaFX HTMLEditor. Then, when saving the file back to EPUB, I'm going to have to reverse the process.

Not ideal, but I think it's workable.

Issue: https://javafx-jira.kenai.com/browse/RT-30487

open source. open mind. - June 11, 2013 01:37 PM
Das Chuck Norris Experiment – Java ohne Jailbreak auf iPad und Android

Chuck Norris kann Java auf dem iPad starten – ohne jailbreak!” Mal sehen was nötig ist um das ohne Roundhouse-Kick selbst nachzuvollziehen. Hier wird bck2brwsr vorgestellt, ein neues Open Source Projekt, das es ermöglicht Java direkt im Browser laufen zu lassen – ohne Java Plugin. Anders als bei GWT und ähnlichen Projekten wird der Quellcode nicht nach JavaScript kompiliert, sondern als ByteCode in einer JavaScript basierten JVM ausgeführt. Als Demo bauen wir eine Spiele-App, die auf Android und iOS genauso läuft wie auf dem Desktop. Und all das ist keine Zukunftsmusik, sondern bereits verfügbar und kann sofort eingesetzt werden…

NetBeans Zone - The social network for developers - June 11, 2013 12:14 AM
NetBeans Weekly News (Issue #591 - June 10, 2013 )

Project News Register for Free Webinar on Java EE 7 Developer productivity and application portability play a huge role in the success or failure of your business. Already the world’s #1 development platform, Java is now better than ever with the release of Java EE 7. On Wednesday June 12, Join Oracle and participants from throughout the Java community to learn how Java EE 7 can help...

Geertjan's Blog - June 10, 2013 05:18 PM
Tips for Teachers in NetBeans IDE

So you're using NetBeans IDE to teach programming to your class. What kind of features would be specifically relevant to you, during teaching?

  • Increase/decrease font size. Hold down the Alt key and scroll the mouse up/down and you'll see the font size magically increase/decrease. Same thing in the Output window, to really show your class the errors of their ways.

  • Quickly switch between open editor documents. Ctrl-Tab, just like all/most other applications, just like when you switch between applications on your computer.

  • Maximize/minimize NetBeans IDE. Alt-Shift-Enter, this toggles between maximized/minimized mode of the entire window frame of the IDE.

  • Distraction-free mode. Wouldn't it be cool if you could remove all the windows around the editor, showing nothing other than the editor document? That's coming up in NetBeans IDE 7.4, distraction-free mode, Ctrl-Shift-Enter, mentioned in NetBeans IDE 7.4 New & Noteworthy, already available in daily builds (also via "View | Show Only Editor").
Now, you'll be able to increase the font size, remove everything from the screen except the editor document, maximize the editor document to cover the entire screen, and switch between multiple open documents. Excellent. Now all that's left for you to do is... teach.

NetBeans Zone - The social network for developers - June 10, 2013 07:03 AM
Hack OpenJDK with NetBeans IDE

Since recently, the OpenJDK repository contains a NetBeans project for all C/C++ parts of the OpenJDK, including Hotspot. That means that now NetBeans IDE can easily be used to review, hack, and develop OpenJDK. Simple howto is as follows:Legacy Sponsored:  unsponsored

NetBeans Zone - The social network for developers - June 10, 2013 05:53 AM
The Many Ways of Monitoring and Managing GlassFish

Robust facilities for management and monitoring is one of the most significant ways GlassFish shines as compared to most open source Java EE application servers. Indeed as a former independent consultant, I have personally seen multiple cases where customers chose GlassFish over other options for this very reason. Folks in operations are usually particularly pleasantly surprised to...

NetBeans Zone - The social network for developers - June 10, 2013 04:49 AM
Perl on NetBeans IDE Beta 2

"Perl on NetBeans " is intended for Perl programmers who want the intuitiveness of a great editor with the ease of being able to execute the program without having to do it through a command Interpreter. Also, it has the capability to inspect the austerity of your Perl programs, and format the same in accordance to the best practices and conventions. Preview Text:  ...

Adam Bien - June 09, 2013 08:54 AM
JDD JavaEE Session: Future Is Now, But Is Not Evenly Distributed Yet

A session about JavaEE, JDD Conference 2012

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.

Let's do it together at Java EE Workshops at MUC Airport:-).


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 09, 2013 07:00 AM
Pharmacy Terminal Application on the NetBeans Platform

Speaking of terminal emulators, which I did yesterday, here's another terminal application on top of the NetBeans Platform, one that's been in production for several years, by and for Thrifty White Pharmacy. It is named JTerm. 

After Windows 7 came out, the company needed a Telnet/Terminal emulator that would replace the existing emulators that only worked up to Windows XP. Their main pharmacy application is written in COBOL and requires a Console/Terminal emulator to access it.

Instead of the NetBeans Terminal library, which was used in the blog entry yesterday, the open source JTA - Telnet/SSH library is used in a wrapper library in JTerm. Here's a screenshot of JTerm:

JTerm allows the user to open a new session via an XML file to connect to any of the company's pharmacy servers across their WAN. It has print functionality, with a wizard to allow users to create new XML session files.

Geertjan's Blog - June 08, 2013 11:09 AM
Interacting with the Native Terminal

I've been looking into how to interact with the terminal in a NetBeans Platform application. The simplest approach is described here, from sometime ago, which gives you a native terminal embedded in your NetBeans Platform application, but does not let you interact with it, i.e., listen to key strokes. That may be fine for your purposes, in which case forget the rest of this blog entry.

However, to get more control over the embedded native terminal, quite a bit more work needs to be done. The related NetBeans APIs are not public or stable yet, but if you're OK with implementation dependencies (i.e., that means you know upfront that incompatible changes could be included in these APIs in the future, since it is still under development), you can go some way to achieving this.

My aim was to create a NetBeans Platform application that shows a terminal window and nothing else. Secondly, my aim was to cause a new menu item to be created whenever the Enter key is pressed, with the text of the menu item being the characters typed by the user in the terminal. In other words, a terminal history feature.

To achieve the above (and note that all the colors you see above come directly from the NetBeans Platform support described in the following, i.e., I didn't do anything to create the colors, which describe the various states of the folders and files), I needed to use (as stated above) implementation dependencies on three currently internal modules (because they are under development): Native Execution (org.netbeans.modules.dlight.nativeexecution), Terminal (org netbeans.modules.terminal), and Terminal Emulator (org netbeans.lib.terminalemulator). Note that aside from using these unstable APIs, I also do not know whether even in the current state of these APIs I am using them in the intended way or not.

However, all that having been said, here's the TopComponent that you see above, which is in the "editor" mode, with the tab removed (as described elsewhere and referenced often, i.e., the "Farewell to Weird Tabs" blog entry):

import java.awt.BorderLayout;
import org.netbeans.modules.terminal.api.TerminalContainer;
import org.openide.windows.TopComponent;
import org.openide.windows.IOContainer;

public class TerminalTopComponent extends TopComponent {

    private final TerminalContainer tc;

    public TerminalTopComponent() {
        setLayout(new BorderLayout());
        tc = TerminalContainer.create(TerminalTopComponent.this, "Local");
        add(tc, BorderLayout.CENTER);
    }

    public IOContainer getIOContainer() {
        return tc.ioContainer();
    }

    @Override
    protected void componentActivated() {
        super.componentActivated();
        tc.componentActivated();
    }

    @Override
    protected void componentDeactivated() {
        super.componentDeactivated();
        tc.componentDeactivated();
    }

}

I then have an Installer class that creates the TopComponent above, gets the IOContainer, uses the Native Execution module to get an Environment (otherwise, no typing is possible in the terminal), and opens the terminal:

TerminalTopComponent emulator = new TerminalTopComponent();

WindowManager.getDefault().findMode("editor").dockInto(emulator);

emulator.open();
emulator.requestActive();

IOContainer ioContainer = emulator.getIOContainer();

ExecutionEnvironment env = ExecutionEnvironmentFactory.getLocal();
if (env != null) {
    String homeDir = System.getProperty("user.home").toString();
    openTerminalImpl(ioContainer, "tabtitle", env, homeDir, true);
}

The "openTerminalImpl" call above is a very lengthy piece of code, based on an even lengthier piece of code, which I found in the dlight modules somewhere. Included in there is an implementation of org.netbeans.lib.terminalemulator.TermInputListener, which lets me detect characters being typed in the terminal.

Whenever the Enter key is pressed, a FileObject is written into a folder in the filesystem, to which the Terminal History menu is listening. When a new FileObject is found, a new menu item is created in the menu.

It's all a bit rocky and probably mostly incorrect, but here it is, and note that it's operating system dependent, as well, and only used (not tested) so far on Ubuntu with NetBeans Platform 7.3:

https://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.3/misc/TerminalEmulator

Adam Bien - June 07, 2013 07:15 AM
JavaEE 7 Heals Crippled Jars And java.lang.ClassFormatError

JavaEE 6 APIs in Maven central were only usable for compiling. Any attempt to load the classes from

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>
would result in:

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/LockModeType
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

The official Java EE 7 APIs do not have that problem any more:


   <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

If you are starting with JavaEE 7, just use the Essential Java EE 7 POM

When I spotted the "crippled" dependency in JavaEE 6 projects, I always asked "Do you write Unit Tests?". "Yes" answers were not honest. Now Java EE 7 killed my litmus tests :-)

The whole example with workaround was checked into http://kenai.com/projects/javaee-patterns The name of the project is: MavenUnitTestWithCrippledAPI. Just increase the dependency version to 7.0 and the unit tests should pass without any workarounds needed.

See you at Java EE Workshops at MUC Airport!


Real World Java EE Workshops [Airport Munich]>

Geertjan's Blog - June 07, 2013 07:00 AM
Czech Learner Corpus Software on the NetBeans Platform

A learner corpus, also called interlanguage or L2 corpus, is a computerised textual database of language as produced by second language (L2) learners. Such a database is a powerful resource in research of second language acquisition. It can be used to optimise the L2 learning process, to assist authors of textbooks and dictionaries, and to tailor them to learners with a particular native language.

Czesl, a learner corpus tool for Czech, has been written in Java on top of the NetBeans Platform. The screenshot below shows the annotation of a sample sentence as displayed by the tool.

More details (PDF): https://www.aclweb.org/anthology/W/W10/W10-1802.pdf

NetBeans Zone - The social network for developers - June 07, 2013 12:08 AM
NetBeans Weekly News (Issue #590 - June 3, 2013 )

Project News Contribute to the Java SE Platform as It's Being Developed! Download the latest preview updates of JDK 8, the next generation of the Java Development Kit. Kick the tires, give it a test drive and share your feedback. PHP Static Code Analysis in NetBeans IDE Coming up in the next NetBeans IDE release, the ability to check the quality of your PHP code.Legacy ...

NetBeans Ruminations » NetBeans - June 06, 2013 10:57 PM
The Ultimate NetBeans Platform Resource

Much has been written about the NetBeans Platform. But the ultimate resource still remains the source code of the Platform itself! I have used plenty of open source libraries over the years. And I have ventured into the source code numerous times. Quite often the experience is one that leaves one dazed and confused. But I have found that the NetBeans source code is well structured and easy to follow. So even on your very first adventure, you can gain much wisdom! :)

Reading source code is like reading a Physics text book. You can try to keep all of that information in your head, or you can experience it in practice. So in most cases, the easy way to find an answer is to debug into the source instead of just perusing it.

How to set up the source code to be able to debug into it, depends on what type of project you are working with. For Ant-based module projects, download the source code of the same version as the platform that you are building on, and configure the platform to use it in the NetBeans Platform Manager (Tools > NetBeans Platforms). This gives you access to all of the source code in all of the modules.

For Maven-based projects, you have to attach the source code for each of the dependencies. In project view, right-click on one of the NetBeans module dependencies and choose Download Sources.

Now put a breakpoint somewhere in your own module to start from. So for example, if you wanted to explorer the behaviour of the TopComponent class, put a breakpoint into the constructor of a TopComponent subclass (created using the Window wizard). And step into for example the setName() method.

Using this methodology, you can explore how the platform loads and uses things like nodes and actions and windows. That will provide you with much deeper insight into how these things work!

Robert Bracko (robert [dot] bracko [at] vip [dot] hr) explored the behaviour of an old third party IDE module from the 6.9.1 days. He sent me the following points, describing his fascinating first adventure!

  1. Downloaded NB 6.9.1 (Build Type: Release) from https://netbeans.org/downloads/6.9.1/zip.html:
    1. netbeans-6.9.1-201007282301-ml-javase.zip (description: NetBeans 6.9.1 Java SE OS Independent Zip/English)
      Extracted (not installed!) into directory netbeans-6.9.1-201007282301-ml-javase
    2. netbeans-6.9.1-201007282301-src.zip
      Extracted into directory netbeans-6.9.1-201007282301-src
  2. Inside Development IDE (NB 7.3), added platform nb691 as new NB platform, based on directory netbeans-6.9.1-201007282301-ml-javase\netbeans.
    Sources linked for that platform, based on directory netbeans-6.9.1-201007282301-src
    So far so good :-)
  3. Project opened inside Development IDE: KoalaLayoutSupport. Project properties changed: NetBeans platform set to nb691
    Attempt to build the project fails:
    The following error occurred while executing this line:
    X:\netbeans\netbeans-6.9.1-201007282301-ml-javase\netbeans\harness\testcoverage.xml:22: C:\Program Files\NetBeans 7.3\harness\testcoverage\cobertura does not exist.What is strange here is that error message refers to C:\Program Files\NetBeans 7.3 directory. Why does it look into NB 7.3 installation directory?
    Next step was to investigate exactly what’s going on during build process. So I’ve selected project’s node Important Files > Build Script and from the pop-up menu chose Debug Targer > netbeans. I found out that file nbproject/build-impl.xml refers to file nbproject/private/platform-private.properties which further defines property user.properties.file with value C:\\Documents and Settings\\Administrator\\Application Data\\NetBeans\\7.3\\build.properties. Nothing wrong with that, right? Because at the same time debugger’s variables-window shows that property nbplatform.active contains value nb691, so the whole process of building should be (at least I think so) controlled by NB 6.9.1. platform.
    But then one suspicious thing: build-impl.xml tries to define the property harness.dir with value nbplatform.${nbplatform.active}.harness.dir. After having executed that line, debugger’s variables-window shows the value C:\Program Files\NetBeans 7.3/harness for that variable! And that’s obviously wrong.
    So the next step was to change harness dir for platform nb691. I have done that through NB Platform Manager: inside tab Harness, choosing “Harness supplied with Platform” instead of “Harness supplied with IDE”. And then the build passed OK! :-)
  4. Next thing, module debugging. Breakpoint set inside of module’s class works OK, also a breakpoint set inside of a class of NB 6.9.1 source. But… For the latter one, debugger’s variable window shows the error message “variable information not available, source compiled without -g option”. I know what it means but how to resolve it?….. For me it’s rather important to see how NB Form Editor source code interact with my module…

Thanks for sharing, Robert! Some questions still remain unanswered in the steps above. Stay tuned for more about his next adventure!

Geertjan's Blog - June 06, 2013 09:06 AM
NetBeans Platform in Croatia and Beyond!

I had a great time at JavaCro over the last few days, held near Zagreb, Croatia. I was there last year too, when the conference was held for the first time. I renewed some contacts I made then, ate really a lot of meat (seems to be the main item of food in that part of the world), and met a lot of people for the first time.

I did two presentations, one on HTML5 tools in NetBeans IDE and HTML5 integration with Java EE. The other was an introduction and panel discussion about some of the cool applications being created on the NetBeans Platform in and around Croatia.

Here's the whole panel, from Amphinicy, Gaea+, Croatian Telecom, and Belgrade University:

Sadi from Amphinicy talked about network satellite software created by him and his team, on the NetBeans Platform. Here's one of several applications that they have on the NetBeans Platform:

Marjan from Gaea+ in Slovenia talked about geolocation software created by him and his team, on the NetBeans Platform:

Boris from Croatian Telecom talked about an OpenMQ administration software created by him and his team, on the NetBeans Platform. He's used the real-time charts from VisualVM and is considering providing the application in the form of a plugin from VisualVM:

Zoran talked about the neural network software created by him and the NetBeans User Group Serbia at the University of Belgrade, on the NetBeans Platform:

There's clearly lots of cool and surprising stuff going on with the NetBeans Platform around the world. Several people at the conference indicated they'd like to create applications on the NetBeans Platform too, because of its modularity, loose coupling, and out-of-the-box components, so I'm looking forward to doing another session like the above at the next JavaCro, with different applications!

Neil's Dev Stuff - June 05, 2013 11:55 AM

Well it is my last day at IBM and I will miss the talented people I worked with there they are amazing.... Moving on..... Recently had time to use NodeJS with some MQTT sprinkled in. I also came across a blog that describes how to setup Notepad++ to use NodeJs.

Adam Bien - June 05, 2013 08:51 AM
Summer Of JavaEE Workshops And Gigs

  1. Free Hacking night:11.06.2013, Utrecht JavaEE 7 Meets HTML 5 and AngularJS
  2. Workshops: 24.06-26.06.13, Munich Java EE Summit
  3. Conference: JayDay, 02.07.2013, Munich Nothing Compares To …Java EE 7
  4. Jug Session: 02.07.2013, Nürnberg JavaEE 7 And Why There Is No More Room For Overengineering (Livehacking)
  5. JavaEE Tribe Gathering :-) 22.7-26.7.2013 Modular Java EE 7 Workshops--Airhacks From "absolute beginning" over JavaEE 7 architectures to User Interfaces and HTML 5

See you at Java EE Workshops at MUC Airport!


Real World Java EE Workshops [Airport Munich]>