Adam Howitt's Blog

Oct 29
2008

Back from the Dead with Eclipse

This Halloween inspired post explains how to bring a file back from the dead if you've ever looked at it in eclipse.

I have been playing with blueprintcss and pulled down source this morning.  It's genius to a developer with my *ahem* design skills, so I was thrilled to get it installed and running. But I was having trouble with one of their examples.  

The idea is that the page is divided into 24 columns so you can give a div a class of "span-24" and voila, you have a 24 column div.  You can create subdivs so that if your container is 12 columns you should be able to have subdivs marked span-8 and span-4 - gettit?  8+4=12.  But it didn't.  Somehow I was seeing funky layout wrapping.

Turns out I had the bleeding edge broken version but since I knew it was a github repo file, I could try out Git for the first time to pull down the fix (fixed minutes after I downloaded apparently).  I installed Msysgit and then went to my blueprint directory.  Tried a git pull from the command line within the repo directory but it said my local repo wasn't a repo.  Grabbed the git cheat sheet and decided to do a "git init" and "git add ."  Looking good.

git pull git://github.com/joshuaclayton/blueprint-css.git
Seems to have grabbed latest... Switch to eclipse and refresh project. Crap!  My extensive client blueprint example vanishes before my eyes.

Enter the Dragon

At this point I usually stare at the screen but since time is against me I recreate my lay_blueprint.cfm file and just as I right click for some reason I notice the "replace with" eclipse context menu item is there.  Hmm. I had clearly edited the file earlier today in Eclipse.  Could it be... Holy Stomping Mummys Batman - back from the dead.  My empty lay_blueprint.cfm fills with the lost code as my eyes fill with tears of joy.  Yay Eclipse!

Sep 22
2008

Eclipse Ganymede and Java 6 update 10 RC

Just a word of warning - my copy of Google Chrome suggested I install Java 6 update 10 RC last night to allow me to upload pics to facebook.  

Everything went okay but this morning Eclipse Ganymede was dead with no indication of why except a dialog box containing runtime parameters.  I uninstalled the new Java update and everything is fine again.

Apr 05
2005

The Red Badge of Courage

I finished Stephen Crane's "Red Badge of Courage" over the weekend and I'm sad to say it took me nearly 3 weeks to do so despite the fact it is only 100 pages. In my defense the book hardly licks along at a good pace until the last 30 pages when it really gets interesting and you feel invested.  Lots of guys told me it was a great book while many girls just remembered it from school as boring. 

Towards the end I found myself picturing the forests around Georgia and the times I've been paintballing in that environment.  In my experience it seems fairly random who gets clipped by a paintball unless you're the kind of ass who brings the BFG of paintball guns and hides in a hole by the flag. I don't mean to trivialize the danger of fighting with real guns by drawing the comparison but rather to say how much it scares me to think how hard it must be.

The fact that it took me 3 weeks to read this book is a classic signal that I'm starting to slip back on my priorities so I made the effort to review my checklist and how I'm organizing my free time. I don't know if it's because I'm a programmer but I feel like there is so much I want to read, to watch, to learn and to experiment with I regularly spread myself too thinly or focus on frivolous things at the cost of personal goals.

In an effort to keep myself on track I think sharing these goals might add some artificial pressure on myself to complete them:

  • Run 30 mins every other day
  • Ride to work at least once a week
  • Play soccer once a week
  • Participate in a 5k once a month with steadily improving times
  • Practice guitar once a week besides class
  • Finish one of the books in my classical literature A to Z every 3 weeks
  • Finish the examples from  the Eclipse 3 book
  • Modify the CFEclipse parser to handle custom tags correctly
  • Finish phase I of CFLunch.com to make co-ordinating the site with the meetings easier.

Of course, like many other things, there are obstacles to my progress on the horizon:

  • Cubs baseball has just started up again
  • An apartment to maintain which seems to be swallowing my personal belongings.  Latest loss was my favorite Cubs hat.  Reward of $5 dollars if you find it :-)
  • Dollar burgers on a Monday night at the Union
  • A week in San Francisco for the Gilbane conference
  • The wedding tour as my girlfriend and I hit DC, Atlanta, New York and Birmingham (England) for a series of weddings
So there you have it.  Am I strange?  Do all programmers lament on how to fit everything in or is it just me?

Mar 18
2005

Eclipse Navigator Tidy

Working through some of the chapters I skipped in the Berthold Daum book last night I discovered the wonder of working sets for the Navigator view.  If you are like me and work on maintenance items as well as new development projects, your navigator pane in Eclipse gets quite cluttered.  Enter the "working set".  I had been using these for searches for some time (Ctrl H to do an extended search) but had no idea they affected the rest of Eclipse.

  1. In the Navigator pane click the black down arrow in the toolbar and you see the option to "Select Working Set". 
  2. If you already have some working sets defined you can just pick one, otherwise you will want to click New.
  3. Select Resource on the next page of the wizard
  4. Enter a friendly name for your set name
  5. Select the projects (or subsection of projects) you wish to include by checking the box and then click finish

I have reorganized my workspace now to the following working sets:

  • Maintenance - older projects refered to less often
  • New Development - current projects including our VSS repository for code templates
  • Personal - all the nerdy neat stuff I'm working on!
Not a huge productivity enhancer but it's a virtual version of the saying "tidy desk tidy mind" :-)

Mar 09
2005

Help Write CFEclipse!

Spike and I have been discussing CFEclipse lately in terms of people gettting involved and I thought I could help generate some forward momentum by recommending a book by Berthold Daum called "Eclipse 3 for Java Developers".  It explains how to get the most out of Eclipse to begin with before explaining how to create fragments and plugins for Eclipse like CFEclipse for instance.  If, despite the number of Eclipse plugins out there, you don't find what you need from a plugin it will teach you how to roll your own.  It still relies on an understanding of Java but do pick the book up!

CFEclipse for Configuration Management

In every company I've worked, configuration management has always caused huge problems.  Through the "magic" of file template snippets in CFEclipse I have put together a deployment document for our company which reduces the number of times someone has to ask, "which server is it on", "when did this change happen", "why did we make that change".

Even better, CFEclipse allows you to store your snippets in a networked location so we have ours in a common template folder.

First I'm going to give you the snippet we use and then explain how to set it up.  It should also be noted that similar magic can be worked in Dreamweaver but I'll leave that post to someone who actually likes that IDE :-)

---BEGIN SNIPPET ------------ 

Deployment Request Document $${CURRENTFILE}
For: $${Client Name}
Date: $${MONTHNUMBER}.$${DAYOFMONTH}.$${YEAR2DIGIT}"
Purpose: $${Purpose of the deployment}
Bug tracking case #: $${Sales force case number}
Author: $${CURRENTUSER}

Files to deploy to $${Live destination server}. 
$/WWW/appraisal/qry_complist_search.cfm
$/WWW/appraisal/reports/dsp_reports_turnardclient.cfm

Scripts to execute on $${Database server name}:
$/db/sp_search_comps_vii.sql

SQL Permissions to run after scripts execute:
GRANT EXECUTE ON dbo.sp_serach_comps_vii.sql TO vn_admin_role
----- END SNIPPET -----------

To create a file template snippet in CFEclipse:

  1. If it isn't already open go to Window > Show View > Snip Tree View
  2. Go to Window > Preferences > CFEclipse > File Paths and check the path.   This is where you can repoint CFEclipse to a network drive of templates if you want.
  3. Save your changes if you made any and close out of Preferences
  4. Find the snip tree view in your perspective and click the big plus symbol "+".
  5. Give your snippet a name, optionally some trigger text, a description of the snippet and then the start and end block.
  6. If there are variables in your file that change per day, file, user etc you can create your own variable using the format $${param name} e.g. $${Purpose of the file} or you can use some auto text ones.  For an excellent list, consult Spike's documentation.
  7. Check the box "Use this snippet as a file template"
  8. Set the extension and hit OK to save it.

To use your file template snippet, you have two choices.  Double click the snippet to insert it at the cursor or if you want to create the file in your configuration management directory:

  1. Right click on the directory you wish to store your new file
  2. Select New > Other
  3. Select CFEclipse > File From Template and hit next.
  4. If the path is inaccurate, hit Browse and set it.
  5. Set the filename
  6. Your template should be listed in the panel.  Select it and click finish
  7. Any variables you created will be listed so you can enter them.

So there you have it.  We use VSS and the Eclipse VSS plugin for our development so I can check these config files into VSS directly.

Mar 02
2005

Eclipse uncovers ColdFusion's Secret Powers

If you have ever seen a tech tip about ColdFusion leveraging the built in hidden methods of Java and wondered "how the heck do they know this stuff?", Eclipse can help you see the wizard behind the curtain.

Yesterday I was doofing around trying to discover a way to access the SQL statement passed by cfquery and cfstoredproc so I could log it on my production server without duplicating the code block. I figured, if CF knows what the parsed statement is, why can't I access it after the statement executes as, say, cfquery.parsedSqlStatement. I know it exists because if my code errors, I see it in the resulting error dump.

I started out looking for posts that utilize some of these hidden Java methods and came across Sam's post on "Handling file uploads without CFFILE". The important snippet was
cls = s.getClass();
stringCLass = cls.forName("java.lang.String");
Armed with this info I started to experiment by dumping out the stringClass variable to see the list of methods.

Next I threw a DB error deliberately and expanded the stack trace to get a list of CFClasses which were involved in the error. I constructed this little test:

<cfquery datasource="ll_site" name="qTest">
select * from object_tb
</cfquery>
<cfset cls = qTest.getClass()>
<cfdump var="#cls.getName()#">
<cfset stringClass = cls.forName("coldfusion.sql.QueryTable")>
<cfdump var="#stringCLass#">

Unfortunately my research stopped there because there just wasn't much to see. No properties or methods easily listed to help me on my quest. This was when I had a brainwave. Eclipse is a Java development tool, ColdFusion comes as a deployable ear file and has a list of classes: maybe Eclipse can see more than just a .ear file!

So I opened Eclipse, created a new Java project and set the location of my EAR file as the directory under "Create project at external location". Create a name for the project and hit Finish. Eclipse then prompted me to switch to the Java perspective (from CFEclipse which is my default) and to my amazement, I see a list of jar files and packages! I click to expand cfusion.jar and it expands to show me a list of coldfusion packages. I click to expand coldfusion.sql and I see a list of classes and properties. I expand SqlImpl.class and see methods and properties which I may be able to leverage.

So I'm still no closer to getting the exact SqlStatement because I'm still unsure as to how to access the property I need. If anyone following these steps is able to point this out I would greatly appreciate it.

Now THAT is something Homesite and Dreamweaver can't do ;-)

Feb 25
2005

Simplifying Form Validation with Eclipse Backreferences

I'm in awe of Eclipse and the productivity it affords me. Today's revelation comes as I look at a form with 43 fields defined by our graphics guy and a need to set the value="" attribute to the previously submitted value if it exists. With Eclipse and backreferences in the find/replace I was able to do it in one shot.

All my input fields were defined as
<input name="fldname" ... blah, blah, blah >

  • Take a copy of your code in case this blows up on you
  • Ctrl+F opens the find / replace window. Set the find string to
    name="(.*?)"
    This finds the name="" attribute and whatever is between the quotes is stored as a backreference number 1
  • Set the replace string to
    name="$1" value="#attributes.$1#"
    This says we are going to output two attributes in place of the one and for the value we are adding some CF code around the backreference $1 also.
  • Check the regular expressions box
  • Click find to be sure that your regex finds a good first match.
  • Click replace to replace just one occurence to check that it outputs in the way you want (it's easier to undo one mistake vs 43)
  • If all is good hit replace all

Dec 22
2004

Using Quantum Eclipse Plugin for SQL Server

I've installed and played around with Quantum and I have to say that while it works like a simple query analyzer it is missing quite a bit of functionality it could easily add.

The potential is there and some constructive feedback could help make this even better.

To install Quantum for Eclipse 3 to see for yourself, I've listed the steps to get you all the way to connect to a SQL Server.

  1. Download the latest build of Quantum from sourceforge (in my case quantum244_3.x.zip.
  2. Close Eclipse
  3. Extract the contents of the plugins directory into your Eclipse 3 plugins directory (in my case C:\Program Files\Eclipse\plugins
  4. Open Eclipse and select Window > Open Perspective > Other > Quantum DB and you see the default 3 panel setup.
  5. Download Microsoft SQL Server JDBC Drivers but remember that they can't be redistributed except within a single corporation by their terms and conditions.
  6. Run the setup.exe and choose custom setup if you want to place the drivers anywhere other than C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\
  7. Switch back to Eclipse and in the "Database Bookmarks" panel right click and select "New Bookmark"
  8. There is a default ODBC Driver installed but if you got this far you are trying to get to SQL Server so click "Add Driver"
  9. Click "Add External Jar" 3 times to add each of the three Drivers from the location you used above (C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\ by default on Windows). You should see
    • msbase.jar
    • mssqlserver.jar
    • msutil.jar
  10. Click Browse and pick the entry labelled "com.microsoft.jdbc.sqlserver.SQLServerDriver"
  11. Select Type "Microsoft SQL Server" and then click Finish
  12. Click Next and then enter your userid and password for the datbase you are connecting to
  13. For the JDBC URL you will use the following template:
    jdbc:microsoft:sqlserver://{server_name}:{port};databaseName={db_name} replacing server_name, port and db_name with your settings. By default SQL Server runs on port 1433 in case you are unsure.
  14. Click Next and enter the friendly name you want to use for your bookmark
  15. Click Next if you want to select a schema to display or Finish if you want to show them all
  16. If all is well you should see the new bookmark in the left hand panel. Right click the bookmark and select connect to retrieve the database information.
I'd like to see updateable resultsets for tables queries, table columns and properties. There appears to be only one script generation operation presently to Drop an item - what script as SELECT, INSERT, UPDATE or DELETE?

The quick list is a nice feature if your schema has lots of tables and the recent SQL statements saves using a large undo buffer.

Even better is the Quantum SQL Log which records each SQL statement it attempts.

This is one of several posts you'll see this week as I join the Eclipse bandwagon.

Aug 30
2004

Eclipse 3

I wrote a pleading message to Wiley Publishing for a preview copy of "Beginning Eclipse 3 for Java Developers" by Berthold Daum but if anyone out there has a favorite for the latest version of Eclipse please let me know. I'm also interested in locating some good resources for this release since the majority of tutorials I have found seem restricted to version 2.

Specifically I'm looking at implementing Drag and Drop functionality for Views and using Cut, Copy and Paste extension points.