Package com.cburch.logisim.file

Examples of com.cburch.logisim.file.Loader


    }
  }
 
  public static void run(Startup args) {
    File fileToOpen = args.getFilesToOpen().get(0);
    Loader loader = new Loader(null);
    LogisimFile file;
    try {
      file = loader.openLogisimFile(fileToOpen, args.getSubstitutions());
    } catch (LoadFailedException e) {
      System.err.println(Strings.get("ttyLoadError", fileToOpen.getName())); //OK
      System.exit(-1);
      return;
    }
View Full Code Here


    }
   
    // pre-load the two basic component libraries, just so that the time
    // 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...
      System.err.println("FATAL ERROR - no components"); //OK
      System.exit(-1);
    }
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();
            LogisimFile.load(reader2, loader); // to see if OK
            AppPreferences.setTemplateFile(file, template);
View Full Code Here

      System.err.println("unexpected format; aborted"); //OK
      return;
    }
   
    // Then display file chooser
    Loader loader = proj.getLogisimFile().getLoader();
    JFileChooser chooser = loader.createChooser();
    if (circuits.size() > 1) {
      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      chooser.setDialogTitle(Strings.get("exportImageDirectorySelect"));
    } else {
      chooser.setFileFilter(filter);
View Full Code Here

    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;
    }
    return null;
  }
View Full Code Here

    return doNew(monitor, false);
  }

  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

  }
 
  public static Project doOpen(SplashScreen monitor, File source,
      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 = StringUtil.format(Strings.get("openAlreadyMessage"),
            proj.getLogisimFile().getName());
        String[] options = {
            Strings.get("openAlreadyLoseChangesOption"),
            Strings.get("openAlreadyNewWindowOption"),
            Strings.get("openAlreadyCancelOption"),
          };
        int result = JOptionPane.showOptionDialog(proj.getFrame(),
            message, Strings.get("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) {
          proj = null; // we'll create a new project
        } 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;
      if (proj == null) {
        proj = new Project(lib);
      } else {
View Full Code Here

TOP

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

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.