Package com.cburch.logisim.file

Examples of com.cburch.logisim.file.Loader


      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(getFromLocale("exportImageDirectorySelect"));
    } else {
      chooser.setFileFilter(filter);
View Full Code Here


        }
    }

    public static void doLoadLogisimLibrary(Project proj) {
        Loader loader = proj.getLogisimFile().getLoader();
        JFileChooser chooser = loader.createChooser();
        chooser.setDialogTitle(getFromLocale("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(getFromLocale("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(),
                    getFromLocale("jarClassNamePrompt"),
                    getFromLocale("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 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

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.