Package com.cburch.logisim.file

Examples of com.cburch.logisim.file.Loader$LogisimFileFilter


        return false;
    }

    public static Project findProjectFor(File query) {
        for (Project proj : openProjects) {
            Loader loader = proj.getLogisimFile().getLoader();
            if (loader == null) {
                continue;
            }

            File f = loader.getMainFile();
            if (query.equals(f)) {
                return proj;
            }

        }
View Full Code Here


    public static Project doNew(SplashScreen monitor, boolean isStartupScreen) {
        if (monitor != null) {
            monitor.setProgress(SplashScreen.FILE_CREATE);
        }

        Loader loader = new Loader(monitor);
        InputStream templReader = AppPreferences.getTemplate().createStream();
        LogisimFile file = null;
        try {
            file = loader.openLogisimFile(templReader);
        } catch (IOException ex) {
            displayException(monitor, ex);
        } catch (LoadFailedException ex) {
            displayException(monitor, ex);
        } finally {
View Full Code Here

        SwingUtilities.invokeLater(new CreateFrame(loader, ret, isStartup));
        return ret;
    }

    public static LogisimFile createNewFile(Project baseProject) {
        Loader loader = new Loader(baseProject == null ? null : baseProject.getFrame());
        InputStream templReader = AppPreferences.getTemplate().createStream();
        LogisimFile file;
        try {
            file = loader.openLogisimFile(templReader);
        } catch (IOException ex) {
            displayException(baseProject.getFrame(), ex);
            file = createEmptyFile(loader);
        } catch (LoadFailedException ex) {
            if (!ex.isShown()) {
View Full Code Here

            Map<File,File> substitutions) throws LoadFailedException {
        if (monitor != null) {
            monitor.setProgress(SplashScreen.FILE_LOAD);
        }

        Loader loader = new Loader(monitor);
        LogisimFile file = loader.openLogisimFile(source, substitutions);
        AppPreferences.updateRecentFile(source);

        return completeProject(monitor, loader, file, false);
    }
View Full Code Here

    }

    public static void doOpen(Component parent, Project baseProject) {
        JFileChooser chooser;
        if (baseProject != null) {
            Loader oldLoader = baseProject.getLogisimFile().getLoader();
            chooser = oldLoader.createChooser();
            if (oldLoader.getMainFile() != null) {
                chooser.setSelectedFile(oldLoader.getMainFile());
            }
        } else {
            chooser = JFileChoosers.create();
        }
        chooser.setFileFilter(Loader.LOGISIM_FILTER);
View Full Code Here

    }

    public static Project doOpen(Component parent,
            Project baseProject, File f) {
        Project proj = Projects.findProjectFor(f);
        Loader loader = null;
        if (proj != null) {
            proj.getFrame().toFront();
            loader = proj.getLogisimFile().getLoader();
            if (proj.isFileDirty()) {
                String message = getFromLocale("openAlreadyMessage",
                        proj.getLogisimFile().getName());
                String[] options = {
                        getFromLocale("openAlreadyLoseChangesOption"),
                        getFromLocale("openAlreadyNewWindowOption"),
                        getFromLocale("openAlreadyCancelOption"),
                    };
                int result = JOptionPane.showOptionDialog(proj.getFrame(),
                        message, getFromLocale("openAlreadyTitle"), 0,
                        JOptionPane.QUESTION_MESSAGE, null,
                        options, options[2]);
                if (result == 0) {
                    // keep proj as is, so that load happens into the window
                    ;
                } else if (result == 1) {
                    // we'll create a new project
                    proj = null;
                } else {
                    return proj;
                }
            }
        }

        if (proj == null && baseProject != null && baseProject.isStartupScreen()) {
            proj = baseProject;
            proj.setStartupScreen(false);
            loader = baseProject.getLogisimFile().getLoader();
        } else {
            loader = new Loader(baseProject == null ? parent : baseProject.getFrame());
        }

        try {
            LogisimFile lib = loader.openLogisimFile(f);
            AppPreferences.updateRecentFile(f);
            if (lib == null) {
                return null;
            }
View Full Code Here

    }


    // returns true if save is completed
    public static boolean doSaveAs(Project proj) {
        Loader loader = proj.getLogisimFile().getLoader();
        JFileChooser chooser = loader.createChooser();
        chooser.setFileFilter(Loader.LOGISIM_FILTER);
        if (loader.getMainFile() != null) {
            chooser.setSelectedFile(loader.getMainFile());
        }
        int returnVal = chooser.showSaveDialog(proj.getFrame());
        if (returnVal != JFileChooser.APPROVE_OPTION) {
            return false;
        }
View Full Code Here

        }
        return doSave(proj, f);
    }

    public static boolean doSave(Project proj) {
        Loader loader = proj.getLogisimFile().getLoader();
        File f = loader.getMainFile();
        if (f == null) {
            return doSaveAs(proj);
        }

        else {
View Full Code Here

        }

    }

    private static boolean doSave(Project proj, File f) {
        Loader loader = proj.getLogisimFile().getLoader();
        Tool oldTool = proj.getTool();
        proj.setTool(null);
        boolean ret = loader.save(proj.getLogisimFile(), f);
        if (ret) {
            AppPreferences.updateRecentFile(f);
            proj.setFileAsClean();
        }
        proj.setTool(oldTool);
View Full Code Here

                if (action == JFileChooser.APPROVE_OPTION) {
                    File file = chooser.getSelectedFile();
                    FileInputStream reader = null;
                    InputStream reader2 = null;
                    try {
                        Loader loader = new Loader(getPreferencesFrame());
                        reader = new FileInputStream(file);
                        Template template = Template.create(reader);
                        reader2 = template.createStream();
                        // to see if OK
                        LogisimFile.load(reader2, loader);
View Full Code Here

TOP

Related Classes of com.cburch.logisim.file.Loader$LogisimFileFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.