Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Thursday, November 20, 2014

JasperReports/iReports dynamically show and hide fields conditionally

Introduction

With JasperReports and its visual designer iReports you can have (blocks of) fields collapse based on certain conditions.
You can use a subreport, but that's not necessary. This post describes how to show/hide fields without subreports.

How

Basically you have to do two things:

  1. Put the elements (static text, textfields etc) you want to hide on a frame. Make sure the fields are not behind the frame.
  2. Set the correct properties on the frame, including the expression to show/hide it dynamically. By hiding the frame you hide all the fields on it. 
The most important thing is to make sure no other element besides those that need to be on it is overlapping with the frame! Below is a screenshot to make it clearer.
There are three static and three textfields on the frame. Plus two (separate!) vertical lines.


Note the green, red and black vertical lines in the screenshot: the red and black vertical lines are not on the frame at all. The frame has its own green vertical line. That way JasperReports can shrink it based on the condition. Otherwise it doesn't know what to do with the overlap, and doesn't (can't?) collapse it. Notice also the frame is selected (little square blue boxes on its lines) to make clear from where to where the frame runs.
So basically you have to make sure the frame is all by itself, all its elements only on the frame, and no other elements overlapping the frame.

PS: it might be possible to do it per field, but since I needed at least a label + field to be shown/hidden, I didn't even try that.

To put in the other necessary settings, you have two ways of doing that:

  1. Via the XML:

    Put in the condition of the frame. So if theObject is not null, the frame will be shown. Also make sure you add 'isRemoveLineWhenBlank="true"'. E.g:

  2. Or via the Eclipse properties tab: see below screenshot:


    Notice setting the flag and the expression, see the arrow pointing at $F, that's the start of the same above expression in the XML.


Thursday, August 15, 2013

Refactor/rename package in Eclipse with Subclipse and SVN

Refactoring a package by giving it a new name can give quite annoying problems when trying to commit it from within Eclipse using the Subclipse plugin.

You can get (tree) conflicts, maybe even causing you to rollback all your changes and then step by step committing them.
Below is a set of steps you can follow that should not cause any problems if executed in this order :) In short: you do your refactor, then first commit only the deletions, and only then commit the additions (which are the moved files in their new package location).

Detailed steps

Set up and tested with: Eclipse Juno version, Subclipse plugin, SVN 1.6:

  1. Rightclick on your project and select Team --> Synchronize with Repository
  2. Select the incoming view
  3. Now note in the incoming view, it shows conflicts on some/most directories (packages) that were renamed. Just do an update on those.
  4. Go to the outgoing view
  5. If you now select all items with a '-' (the deleted ones) and then try to commit, you get an error on the commit: Tree remains in conflict. Notice the red/green icons on several directories (actually the ones that had a conflict in step 3), see screenshot:

    So those need to be resolved first.
  6. Right click on one of those entries (multiple select not supported for the Show Tree Conflicts operation) and select Team --> Show Tree Conflicts. That shows something like:

  7. Rightclick and select Resolve...
  8. On that next screen:

    select only Mark conflict resolved.
  9. Click Finish
  10. Now the entry is not marked red/green any more, and only shown with a '-' in the Synchronize screen! 
  11. Do that for all red/green arrows (conflicts)
  12. When done, right-click on all items marked with a '-' and select Commit. And that succeeds!
  13. Finally, commit now the ones marked with '+' (so the added ones)
  14. Really final step: note that sometimes some empty packages with the old name stay around. Deleting them in Eclipse and then trying to commit gives again conflicts(!). Those I just delete directly from the Repository perspective and do an update on those.
Bonus tip: sometimes when another team member has commited a new module, the Synchronize perspective will show the (compiled) /target dir and its items as needing to be committed. Even though the directory is already in the .svnignore file, since right-clicking on it won't allow you to add it. Solution: do an update on that target directory. After this it should be fine and it should not show up anymore on the next Synchronizes.

Sunday, August 1, 2010

Best of this Week Summary 26 July - 1 August 2010

  • Pretty nasty, some application apparently depend on the the company name in the JDK! Including Eclipse, causing OutOfMemoryErrors since Oracle changed the name from 'Sun Microsystems, Inc' to 'Oracle'. Sounds like a magic constant somewhere... Though as it says here it had to be put in to work around another bug. Oracle rolled it back until JDK 7.

  • Evolutionary architecture and emergent design: Leveraging reusable code, Part 1 and Part 2.

  • A Spring MVC 3 Showcase, which should give you have a good idea of what the technology can do.It includes a sample project, along with a supporting slide presentation and screencast. After digging in, you should have a good understanding of what Spring MVC can do and get a feel for how easy it is to use.

  • Some random Android tips/lessons learned.

  • Java Iterator Quiz time!

Sunday, October 25, 2009

Best of this Week Summary 19 October - 25 October 2009

Sunday, March 29, 2009

Best of this Week Summary 23 March - 29 March 2009

  • Need to know whether a collection is modified concurrently, which causes the ConcurrentModificationException? Check this handy wrapper solution here.

  • The second article in the Transaction strategies series. "Using examples from the Spring Framework and the Enterprise JavaBeans (EJB) 3.0 specification, explained is how the transaction models work and how they can form the basis for developing transaction strategies ranging from basic transaction processing to high-speed transaction-processing systems".

  • For the Amazon EC2 now a free AWS Eclipse plugin is available. It facilitates remote development, deployment, and debugging Java applications on Amazon Web Services.

  • Three common mistakes to avoid when implementing XML and webservices: don't make your messages too large, don't create too fine-grained services, and don't forget to create an XML schema.

  • Javascript is getting more and more important the last couple of years, so here's a bunch of best practices and efficiency tips.

Sunday, April 27, 2008

Best of this Week Summary 05 May - 11 May 2008

Sunday, April 6, 2008

Best of this Week Summary 31 March - 6 April 2008

Sunday, March 9, 2008

Setup and Installation Ubuntu Development Environment with VMWare Part 2

This is the second post in my series on how to setup a development environment on Ubuntu 7.04 (Feisty Fawn) with VMWare 6.02. In this post I'll be detailing how I setup Eclipse 3.3 (Europa), thus with WTP and PDT. I'll also describe my experiences with Europa 3.2 (Callisto), because I tried that too, in case I couldn't get 3.2 working...

Install Sun Java JDK 5

Since I want to use Java 5 in Eclipse, I first installed the JDK via: 'sudo apt-get install sun-java5-jdk', which installs it in /usr/lib/jvm/java-1.5.0.sun. Make sure you use the Java 5 JDK by setting it via "sudo update-alternatives --config java'.

Install Eclipse 3.2 Callisto with WTP

Installation of Eclipse 3.3 is not supported via the repositories. But first I wanted to try to get 3.2 running anyway.
Step 1 - Installation steps Eclipse 3.2 and setup JDK
Substep 1a - Installed Eclipse 3.2 Callisto via 'sudo apt-get install eclipse' and that worked fine.
Substep 1b - I then installed WTP via Eclipse's own Software Updates mechanism. You might want to install it to "/usr/local/lib/eclipse" to make the plugins available for other users. After this, you can find Eclipse 3.2 in the menu Applications/Programming/Eclipse.
Substep 1c - Then set JDK 5 in Eclipse as the one to use (instead of the default GCJ; is not the greatest performance wise apparently).

Install Eclipse 3.2 Callisto with PDT

Apparently it is not really supported, see here and here. So I did try it for a bit but gave up when I found those two statements.

Install Eclipse 3.3 Europa with WTP and PDT

Since I couldn't get it to work with 'get-apt' nor by downloading the .gz, extracting and setting symbolic links to give all users access to it, I followed these steps, which only make it available for the current user:
Step 2 - Installation of Eclipse 3.3 Europa
Substep 2a - Followed the steps in the User Installation section. I used the zip from here.
Substep 2b - Added WTP as I also did above for 3.2. Select what you want. don't forget: expand nodes otherwise 'Get Required' won't search in them!! I also let the plugins installed in the default (Eclipse installation) directory, because we only want the plugins for this special 3.2 version.
Substep 2c - Installed the PDT plugins as described here. It was complaining missing required ODA runtime 1.5.1. To fix that I manually had to select the appropriate checkbox, see screenshot below.


Issues resolved

One problem I was having is that after starting up Ubuntu it always gave the message "There was an error loading the theme Human. Can't open file /usr/share/gdm/themes/Human/Human.xml". I tried changing it in the menu System/Preferences/Themes, but again it showed up. I also tried 'sudo apt-get human-theme', but after reboot the message still appeared. Then I tried removing and adding the feisty themes as mentioned here: 'sudo apt-get remove feisty-gdm-themes' and 'sudo apt-get install feisty-gdm-themes'. Of course I first made a VMWare snapshot before trying this! Actually, the 'remove' said I didn't have the themes installed. And indeed, after a reboot, the message was gone!

Saturday, February 23, 2008

Best of this Week Summary 18 February - 23 February 2008

  • Nice overview showing how a Ruby on Rails Facebook application named "Friends for Sale" scaled to handle 200 requests/second and 300M page views per month. Includes the used hardware, software, # of visitors etc.

  • This is a short article describing Comet, one of the better known technologies to push events from the server to the browser client. Also explains the name Comet (I for example thought it was a software product, not a technology).

  • Reference to a thorough thesis (conclusions in the article) on performance of AJAX applications for 12 frameworks on mobile devices. Also 5 larger AJAX websites on mobile devices were compared.

  • Nice (but not very elaborate) comparison of 9 features and benchmark of four JEE 5 servers: JBoss 4.x (OSS), Glassfish 2.1 (OSS), WebSphere 2.0 CE (OSS) and WebLogic 10. Check the reference to the jRealBench (zip) benchmarking tool.

  • IBM has just opened their Jazz tool for beta. This post is a short description of installing and using it. Jazz "is a collaborative development environment product based on Eclipse, designed to support the application of RUP, which is itself an interative software development process framework built around iterative". But as you can see in the comments, it's not really restricted to RUP.

Sunday, January 27, 2008

Best of this Week Summary 21 January - 27 January 2008

  • Nice routing pattern for webservices that need to provide both synchronous and a-synchronous calls. You can even make the router such that depending on certain criteria (like load, response time), it will either turn the call into an a-synchronous call when needed. Disadavantage of this approach is of course that the caller has to be able to support both an a-synchronous and a synchronous version of each call. Related patterns you can find in these seven Self-Service: select application patterns.

  • An effort to give answer to the question whether Tomcat is an application server or not. GREAT introduction to JEE btw, so good read for beginners or as a refresher. The answer: Tomcat does not support the entire Java EE stack: no distributed transactions, EJBs, and JMS.

  • IBM made their Jazz tool available for the public. It can be used to "build a scalable, extensible team collaboration platform for integrating work across the phases of the development lifecycle." Note that it is not fully opensource yet. There's also a Mylyn connector available for Jazz.

  • Version 3.0.0 of HTML Purifier has been released. It will scan your HTML for malicious XSS code, check for compliance and will try to fix your code.

  • Summary of a statement made by Bruce Eckel in this article that Java should not change much anymore: it should stop growing and just become stable, and Sun should focus on optimizing/extending the JVM. Interesting considerations.

  • And finally for this week, for the developers among us, a bunch of shortcut keys in Eclipse you might not know about.

  • The Open Source hardening Project of the US Homeland Security department together with Coverity has led to the milestone where in 11 opensource projects all main bugs have been fixed. These 11 have been moved up to the new level Rung 2. Here you can see all the results of the scan.