Package com.cburch.logisim.file

Examples of com.cburch.logisim.file.Loader


  }
 

  // 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;

    File f = chooser.getSelectedFile();
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 return doSave(proj, f);
  }
View Full Code Here

    if (f == null) return doSaveAs(proj);
    else return doSave(proj, f);
  }
 
  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

    return undoMods != 0;
  }

  public JFileChooser createChooser() {
    if (file == null) return JFileChoosers.create();
    Loader loader = file.getLoader();
    return loader == null ? JFileChoosers.create() : loader.createChooser();
  }
View Full Code Here

    public void actionPerformed(ActionEvent e) {
      Object src = e.getSource();
      if (src == unload) {
        ProjectLibraryActions.doUnloadLibrary(proj, lib);
      } else if (src == reload) {
        Loader loader = proj.getLogisimFile().getLoader();
        loader.reload((LoadedLibrary) lib);
      }
    }
View Full Code Here

      if (libs != null) proj.doAction(LogisimFileActions.loadLibraries(libs));
    }
  }
 
  public static void doLoadLogisimLibrary(Project proj) {
    Loader loader = proj.getLogisimFile().getLoader();
    JFileChooser chooser = loader.createChooser();
    chooser.setDialogTitle(Strings.get("loadLogisimDialogTitle"));
    chooser.setFileFilter(Loader.LOGISIM_FILTER);
    int check = chooser.showOpenDialog(proj.getFrame());
    if (check == JFileChooser.APPROVE_OPTION) {
      File f = chooser.getSelectedFile();
      Library lib = loader.loadLogisimLibrary(f);
      if (lib != null) {
        proj.doAction(LogisimFileActions.loadLibrary(lib));
      }
    }
  }
View Full Code Here

      }
    }
  }
 
  public static void doLoadJarLibrary(Project proj) {
    Loader loader = proj.getLogisimFile().getLoader();
    JFileChooser chooser = loader.createChooser();
    chooser.setDialogTitle(Strings.get("loadJarDialogTitle"));
    chooser.setFileFilter(Loader.JAR_FILTER);
    int check = chooser.showOpenDialog(proj.getFrame());
    if (check == JFileChooser.APPROVE_OPTION) {
      File f = chooser.getSelectedFile();
      String className = null;
     
      // try to retrieve the class name from the "Library-Class"
      // attribute in the manifest. This section of code was contributed
      // by Christophe Jacquet (Request Tracker #2024431).
      JarFile jarFile = null;
      try {
        jarFile = new JarFile(f);
        Manifest manifest = jarFile.getManifest();
        className = manifest.getMainAttributes().getValue("Library-Class");
      } catch (IOException e) {
        // if opening the JAR file failed, do nothing
      } finally {
        if (jarFile != null) {
          try { jarFile.close(); } catch (IOException e) { }
        }
      }
     
      // if the class name was not found, go back to the good old dialog
      if (className == null) {
        className = JOptionPane.showInputDialog(proj.getFrame(),
          Strings.get("jarClassNamePrompt"),
          Strings.get("jarClassNameTitle"),
          JOptionPane.QUESTION_MESSAGE);
        // if user canceled selection, abort
        if (className == null) return;
      }

      Library lib = loader.loadJarLibrary(f, className);
      if (lib != null) {
        proj.doAction(LogisimFileActions.loadLibrary(lib));
      }
    }
  }
View Full Code Here

        }
    }

    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) {
            //OK
            System.err.println(getFromLocale("ttyLoadError", fileToOpen.getName()));
            System.exit(-1);
            return;
View Full Code Here

    public JFileChooser createChooser() {
        if (file == null) {
            return JFileChoosers.create();
        }

        Loader loader = file.getLoader();
        return loader == null ? JFileChoosers.create() : loader.createChooser();
    }
View Full Code Here

        // 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 - no components were found");
            System.exit(-1);
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.