use of com.cburch.logisim.gui.menu.LogisimMenuBar in project logisim-evolution by reds-heig.
the class Startup method run.
public void run() {
if (isTty) {
try {
TtyInterface.run(this);
return;
} catch (Exception t) {
t.printStackTrace();
System.exit(-1);
return;
}
}
// I loaded a large file.)
if (showSplash) {
try {
monitor = new SplashScreen();
monitor.setVisible(true);
} catch (Exception t) {
monitor = null;
showSplash = false;
}
}
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.COMPONENT_EVENT_MASK | AWTEvent.CONTAINER_EVENT_MASK);
// taken is shown separately in the progress bar.
if (showSplash) {
monitor.setProgress(SplashScreen.LIBRARIES);
}
Loader templLoader = new Loader(monitor);
int count = templLoader.getBuiltin().getLibrary("Base").getTools().size() + templLoader.getBuiltin().getLibrary("Gates").getTools().size();
if (count < 0) {
// this will never happen, but the optimizer doesn't know that...
// OK
logger.error("FATAL ERROR - no components");
System.exit(-1);
}
// load in template
loadTemplate(templLoader, templFile, templEmpty);
// interface initialization
if (showSplash) {
monitor.setProgress(SplashScreen.GUI_INIT);
}
WindowManagers.initialize();
if (MacCompatibility.isSwingUsingScreenMenuBar()) {
MacCompatibility.setFramelessJMenuBar(new LogisimMenuBar(null, null));
} else {
new LogisimMenuBar(null, null);
// most of the time occupied here will be in loading menus, which
// will occur eventually anyway; we might as well do it when the
// monitor says we are
}
// if user has double-clicked a file to open, we'll
// use that as the file to open now.
initialized = true;
// load file
if (filesToOpen.isEmpty()) {
Project proj = ProjectActions.doNew(monitor);
proj.setStartupScreen(true);
if (showSplash) {
monitor.close();
}
} else {
int numOpened = 0;
boolean first = true;
for (File fileToOpen : filesToOpen) {
try {
if (testVector != null) {
Project proj = ProjectActions.doOpenNoWindow(monitor, fileToOpen);
proj.doTestVector(testVector, circuitToTest);
} else {
ProjectActions.doOpen(monitor, fileToOpen, substitutions);
}
numOpened++;
} catch (LoadFailedException ex) {
logger.error("{} : {}", fileToOpen.getName(), ex.getMessage());
}
if (first) {
first = false;
if (showSplash) {
monitor.close();
}
monitor = null;
}
}
if (numOpened == 0)
System.exit(-1);
}
for (File fileToPrint : filesToPrint) {
doPrintFile(fileToPrint);
}
if (exitAfterStartup) {
System.exit(0);
}
}
use of com.cburch.logisim.gui.menu.LogisimMenuBar in project logisim-evolution by reds-heig.
the class LogFrame method setSimulator.
private void setSimulator(Simulator value, CircuitState state) {
if ((value == null) == (curModel == null)) {
if (value == null || value.getCircuitState() == curModel.getCircuitState())
return;
}
LogisimMenuBar menubar = (LogisimMenuBar) getJMenuBar();
menubar.setCircuitState(value, state);
if (curSimulator != null)
curSimulator.removeSimulatorListener(myListener);
if (curModel != null)
curModel.setSelected(this, false);
Model oldModel = curModel;
Model data = null;
if (value != null) {
data = modelMap.get(value.getCircuitState());
if (data == null) {
data = new Model(value.getCircuitState());
modelMap.put(data.getCircuitState(), data);
}
}
curSimulator = value;
curModel = data;
if (curSimulator != null)
curSimulator.addSimulatorListener(myListener);
if (curModel != null)
curModel.setSelected(this, true);
setTitle(computeTitle(curModel, project));
if (panels != null) {
for (int i = 0; i < panels.length; i++) {
panels[i].modelChanged(oldModel, curModel);
}
}
}
Aggregations