package com.fornsys.jvixen;
import com.fornsys.jvixen.sys.AppCommand;
import java.net.URL;
import java.util.Map.Entry;
import java.util.ResourceBundle;
import java.util.Set;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
public class JVixenApplicationController implements Initializable {
private boolean stopping;
private boolean _openExecution = true;
private boolean _disableControllers = false;
private String _rootDataDirectory;
private CpuUsage _cpuUsage;
private AppCommand _appCommands;
private JVixenApplicationData _applicationData;
public JVixenApplicationController()
{
for(Entry arg : System.getProperties().entrySet()) {
_ProcessArg(arg);
}
_applicationData = new JVixenApplicationData(_rootDataDirectory);
stopping = false;
InitializeComponent();
labelVersion.setText( _GetVersionString() );
setAppCommands( new AppCommand(this) );
Execution.ExecutionStateChanged += executionStateChangedHandler;
VixenSystem.Start(this, _openExecution, _disableControllers, _applicationData.DataFileDirectory);
InitStats();
}
private void VixenApp_FormClosing(Object sender, FormClosingEventArgs e)
{
stopping = true;
VixenSystem.Stop();
_applicationData.SaveData();
}
private void VixenApplication_Load(object sender, EventArgs e)
{
initializeEditorTypes();
openFileDialog.InitialDirectory = SequenceService.SequenceDirectory;
// Add menu items for the logs.
foreach(string logName in VixenSystem.Logs.LogNames) {
logsToolStripMenuItem.DropDownItems.Add(logName, null, (menuSender, menuArgs) => _ViewLog(((ToolStripMenuItem)menuSender).Text));
}
PopulateRecentSequencesList();
}
private String _GetVersionString() {
return getClass().getPackage().getImplementationVersion();
}
private void _ProcessArg(Entry<String,String> arg) {
switch(arg.getKey()) {
case "no_controllers":
_disableControllers = true;
break;
case "no_execution":
_openExecution = false;
break;
case "data_dir":
if(arg.getValue().isEmpty()) {
_rootDataDirectory = null;
} else {
_rootDataDirectory = arg.getValue();
}
break;
}
}
public AppCommand getAppCommands() {
return _appCommands;
}
public void setAppCommands(AppCommand command) {
_appCommands = command;
}
@FXML
private Label labelVersion;
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!");
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}