The decision in terms of which route this goes, whether it goes through the civilian court system or through the military courts martial system, takes into account several factors.
One of these factors is the subject, the accused; if they are not military, there's no courts martial system for them. A civilian offender on military property would be dealt with through the civilian court system. In other cases we've seen civilian infractions on defence establishments against other civilians. Again, that's something that would be dealt with through the civilian system.
Where we get into a court martial situation is when we have military accused, military victims, occurring on military establishments. That's certainly within the clear confines of the military's judicial system. Of course, the JAG would probably like to expand on this answer, if he so chooses.
There are a number of mechanisms that come into play here in determining which route the charges, if warranted, will be heard.