Search in sources :

Example 1 with LogisimMenuBar

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);
    }
}
Also used : Project(com.cburch.logisim.proj.Project) Loader(com.cburch.logisim.file.Loader) LogisimMenuBar(com.cburch.logisim.gui.menu.LogisimMenuBar) File(java.io.File) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) LoadFailedException(com.cburch.logisim.file.LoadFailedException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) Print(com.cburch.logisim.gui.main.Print) LoadFailedException(com.cburch.logisim.file.LoadFailedException)

Example 2 with LogisimMenuBar

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);
        }
    }
}
Also used : LogisimMenuBar(com.cburch.logisim.gui.menu.LogisimMenuBar)

Aggregations

LogisimMenuBar (com.cburch.logisim.gui.menu.LogisimMenuBar)2 LoadFailedException (com.cburch.logisim.file.LoadFailedException)1 Loader (com.cburch.logisim.file.Loader)1 Print (com.cburch.logisim.gui.main.Print)1 Project (com.cburch.logisim.proj.Project)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1