@ -69,6 +69,7 @@ import prism.Prism;
import prism.PrismException ;
import prism.PrismFileLog ;
import prism.PrismLog ;
import prism.PrismNative ;
import userinterface.util.GUIComputationEvent ;
import userinterface.util.GUIEvent ;
import userinterface.util.GUIEventHandler ;
@ -116,10 +117,10 @@ public class GUIPrism extends JFrame
/ / Show the splash screen
splash = new GUIPrismSplash ( "images/splash.png" ) ;
splash . display ( ) ;
gui = new GUIPrism ( ) ;
gui = new GUIPrism ( args ) ;
gui . setVisible ( true ) ;
EventQueue . invokeLater ( new GUIPrism . SplashScreenCloser ( ) ) ;
gui . passCLArgs ( args ) ;
gui . passCLArgs ( ) ;
} catch ( GUIException e ) {
System . err . println ( "Error: Could not load the PRISM GUI: " + e . getMessage ( ) ) ;
System . exit ( 1 ) ;
@ -178,6 +179,11 @@ public class GUIPrism extends JFrame
/ / properties
private Prism prism ;
private PrismLog theLog ;
/ / command - line args to be passed on to components
private String args [ ] ;
/ / initial directory for file chooser ( optional )
private String chooserDir ;
/ / gui components
private ArrayList < GUIPlugin > plugs ;
@ -200,8 +206,18 @@ public class GUIPrism extends JFrame
* @throws GUIException Thrown if there is an error in initialising the user interface .
* /
public GUIPrism ( ) throws GUIException , PrismException
{
this ( new String [ 0 ] ) ;
}
/ * * Creates a new instance of GUIPrism . By calling setupResources ( ) , setupPrism ( )
* and then initComponents ( ) .
* @throws GUIException Thrown if there is an error in initialising the user interface .
* /
public GUIPrism ( String args [ ] ) throws GUIException , PrismException
{
super ( ) ;
this . args = processCLArgs ( args ) ;
setupResources ( ) ;
setupPrism ( ) ;
initComponents ( ) ;
@ -226,7 +242,8 @@ public class GUIPrism extends JFrame
}
/ / Create new file chooser which starts in current directory
File currentDir = new File ( "." ) ;
/ / ( or in the directory specified with command - line arg - dir )
File currentDir = new File ( chooserDir = = null ? "." : chooserDir ) ;
/ / If current directory is the bin directory , go up one level ( mainly for Windows version )
try {
currentDir = currentDir . getCanonicalFile ( ) ;
@ -402,22 +419,51 @@ public class GUIPrism extends JFrame
}
}
public void pa ssCLArgs( String args [ ] )
public String [ ] proce ssCLArgs( String args [ ] )
{
/ / just before we get started , pass any command - line args to all plugins
/ / we first remove the - javamaxmem / - javastack arguments , if present
/ / before ( later ) passing any command - line args to all plugins
/ / we first remove any - javamaxmem / - javastack arguments ( ignored )
/ / and any - dir argument ( processed here first )
List < String > argsCopy = new ArrayList < String > ( ) ;
for ( int i = 0 ; i < args . length ; i + + ) {
if ( args [ i ] . equals ( "-javamaxmem" ) | | args [ i ] . equals ( "-javastack" ) ) {
/ / ignore argument and subsequent value
i + + ;
if ( args [ i ] . charAt ( 0 ) = = '-' ) {
String sw = args [ i ] . substring ( 1 ) ;
/ / remove optional second "-" ( i . e . we allow switches of the form - - sw too )
if ( sw . charAt ( 0 ) = = '-' )
sw = sw . substring ( 1 ) ;
if ( sw . equals ( "javamaxmem" ) | | sw . equals ( "javastack" ) ) {
/ / ignore argument and subsequent value
i + + ;
} else if ( sw . equals ( "dir" ) ) {
if ( i < args . length - 1 ) {
String workingDir = args [ + + i ] ;
/ / set working dir natively for PRISM stuff
if ( PrismNative . setWorkingDirectory ( workingDir ) ! = 0 ) {
System . err . println ( "Error: Could not change working directory to " + workingDir ) ;
System . exit ( 1 ) ;
}
/ / also store locally to initialise file chooser
chooserDir = workingDir ;
/ / NB : we avoid setting system property "user.dir"
/ / since this may break loading of shared libraries etc .
} else {
System . err . println ( "Error: No value specified for -" + sw + " switch" ) ;
System . exit ( 1 ) ;
}
} else {
argsCopy . add ( args [ i ] ) ;
}
} else {
argsCopy . add ( args [ i ] ) ;
}
}
for ( int i = 0 ; i < plugs . size ( ) ; i + + ) {
GUIPlugin plug = ( GUIPlugin ) plugs . get ( i ) ;
plug . takeCLArgs ( argsCopy . toArray ( new String [ 0 ] ) ) ;
return argsCopy . toArray ( new String [ 0 ] ) ;
}
public void passCLArgs ( )
{
for ( GUIPlugin plug : plugs ) {
plug . takeCLArgs ( args ) ;
}
}