The shield gun is your 'melee' weapon.
Only useful at close range, it can devastate an enemy if used properly.
By holding down the normal fire button you can build up a charge which will both injure and knock back anyone it hits, but if you hit a wall with it it will hurt you so be careful.
The weapon will automatically fire when you get within range of something so just hold the button and run at enemies as fast as you can.
(Or better still, use a diagonal dodge jump past the side of the enemy, and the shield gun will probably fire off when you're in midair. If not, you've screwed the enemy's aim at you, so just repeat the process. - Exploding Tomato)
The secondary fire button creates a weak force field in front of you which somewhat reduces damage from incoming fire. Activating it drains more energy than keeping it running so flipping it on and off isn't much help. Energy is also drained when you take hits with the shield activated.
It will regain energy while not in use.
Use the secondary fire to protect yourself in assault while using an objective, or to shield an ally doing the same - remember that two people 'use' an objective just as quickly as one, so you're better off using the sg to shield your teammate from attack.
The shield gun can also be used to increase jump height or distance. Shield gun jumping is easy - just jump at the same time as pressing the fire button, and you'll go higher than a double jump in one go (and you can still double jump at the peak). This technique is mainly used to reach distant power-ups in deathmatch. Charge up to go higher, though there are few situations where you will need to.
Shield gun dodge jumping is a little harder to pull off, and generally less useful. You have to fire just at the second that you press the movement button for the second time, while doing a backwards dodge and pointing the sg at about 45 degrees towards the ground. There are few situation where this is useful; most notably, it can give you a good speed boost when carrying the flag in CTF - just remember to jump at the end of your dodge!
In addition, the shield gun is great for portal camping. In a team deathmatch on a map with teleporters, allocate someone the task of standing in front of the portals with a charged shield gun. Anything that comes through will be instantly shredded. Also consider running through a portal while being chased in deathmatch, then charging up the shiled gun and turning round. If you get followed... +1 frag. Another usage of shield gun portal camping is to trap enemies in sniper towers and the like - for instance on CTF-FaceClassic or ONS-Torlan. The enemy goes through, but you stay behind and camp their exit with a shield gun.
The secondary shot (force shield) also protects you from falling damage a little, this way you can survive a fall that would normally kill you; you might end with little health, but on assault maps where you need to reach an objective faster to defend is small trade-off.