Package eas.miscellaneous.system

Examples of eas.miscellaneous.system.FileCopy


    @SuppressWarnings("unused")
    private void copyAllRelatedFiles(File source, File target) {
        // JAR-Dateien kopieren.
        final File sourcePfad = source;
       
        final FileCopy kopieren = new FileCopy();
        File[] zwisch = sourcePfad.listFiles();

        for (final File f : zwisch) {
            if (f.isFile()) {
                final File f2 = new File(
                        target.getAbsolutePath()
                                + File.separatorChar
                                + f.getName());
                kopieren.copy(f, f2);
            }
        }
    }
View Full Code Here


                params.getstarterSourceDirectory() + File.separatorChar);
        final File zielVerz = new File(
                params.getstarterSourceDirectory()
                        + File.separatorChar
                        + params.getJoschkaVerz());
        final FileCopy kopieren = new FileCopy();
        File[] zwisch;

        // Alte Dateien löschen.
        deleteVerz(zielVerz);
        zielVerz.mkdir();

        // Automaten kopieren.
        zwisch = quellVerz.listFiles(new AutomatenFilter());

        if (zwisch == null) {
            throw new RuntimeException("Verzeichnis existiert nicht: " + quellVerz);
        }

        for (final File f : zwisch) {
            final File f2 = new File(
                    zielVerz.getAbsolutePath()
                            + File.separatorChar
                            + f.getName());
            kopieren.copy(f, f2);
        }

        // // Falls sich keine Automaten im Verzeichnis befinden.
        // if (!enthaelt) {
        // this.paramListe.setBackground(Color.red);
        // this.deleteVerz(zielVerz);
        // return "Keine Roboter in " + quellVerz.getAbsolutePath() + ".";
        // }

        // Umgebungsdateien kopieren.
        if (params.existsPlugin(new EAPlugin().id())) {
            for (final String ausg : ausgaben) {
                // Achtung: In 0, ..., 4, letzt von ausg stehen JoSchKa-Zusätze.
                final String[] ausg1 = StaticMethods.processStringAsCommandLineParameters(ausg);
                String[] ausg2; // Ohne JoSchKa-Zusätze.
                ausg2 = new String[ausg1.length - 6];
                for (int i = 0; i < ausg2.length; i++) {
                    ausg2[i] = ausg1[i + 5];
                }

                final ParCollection paramsZwisch = new ParCollection(ausg2);
                paramsZwisch.complete();
                final File umgebungQuell = new File(
                        quellVerz.getAbsolutePath()
                                + File.separatorChar
                                + paramsZwisch.getParValueString(
                                        EAPlugin.UMGEBUNG_ATTR));
                final File umgebungZiel = new File(
                        zielVerz.getAbsolutePath()
                                + File.separatorChar
                                + paramsZwisch.getParValueString(
                                        EAPlugin.UMGEBUNG_ATTR));
                if (umgebungQuell.exists()) {
                    kopieren.copy(umgebungQuell, umgebungZiel);
                } else {
                    paramListe.setBackground(Color.red);
                    deleteVerz(zielVerz);
                    return "Umgebungsdatei nicht gefunden: "
                            + umgebungQuell.getAbsolutePath() + ".";
                }
            }
        }

        // JAR-Dateien kopieren.
        final File rootPfad = new File(".");
        zwisch = rootPfad.listFiles(new FileNamePostfixFilter("jar"));
        for (final File f : zwisch) {
            final File f2 = new File(
                    zielVerz.getAbsolutePath()
                            + File.separatorChar
                            + f.getName());
            kopieren.copy(f, f2);
        }

        // EAS-JAR-Datei erzeugen.
        try {
            createJAR();
View Full Code Here

       
        dia.setVisible(true);
       
        if (!dia.getResult().equals(GeneralDialog.CANCEL)) {
          // Make temp copy of plugin file.
          new FileCopy().copy(
              new File("./" + PluginFactory.PLUGIN_STORAGE_FILE_NAME),
              new File("./" + PluginFactory.PLUGIN_STORAGE_FILE_NAME + "--.tmp"));
         
          boolean includeHidden = dia.getResult().equals(searchHidden);
         
          dispose();
         
            final ParCollection parsNeu = new ParCollection(params);
            List<Class<Plugin<?>>> oldList = new ArrayList<Class<Plugin<?>>>(PluginFactory.STORED_PLUGINS);
           
            if (!StaticMethods.deleteDAT("./" + PluginFactory.PLUGIN_STORAGE_FILE_NAME)) {
                StaticMethods.speichereTextDatei(".", PluginFactory.PLUGIN_STORAGE_FILE_NAME, "MURKS", this.pars);
            }
           
            PluginFactory.STORED_PLUGINS = PluginFactory.loadPluginsFromFile(includeHidden);
           
            Starter.main(parsNeu.getAllParsArrayView());
            List<Class<Plugin<?>>> newList = new ArrayList<Class<Plugin<?>>>(PluginFactory.STORED_PLUGINS);
           
            newList.removeAll(oldList);
            oldList.removeAll(PluginFactory.STORED_PLUGINS);
           
            LinkedList<String> newListStr = new LinkedList<String>();
            LinkedList<String> oldListStr = new LinkedList<String>();
           
            for (Class<Plugin<?>> c : newList) {
                String name;
                try {
                    name = c.newInstance().id().toString();
                } catch (Exception e) {
                    name = "<ID not readable>";
                }
               
                newListStr.add(c.toString() + " (ID: " + name + ")");
            }
           
            for (Class<Plugin<?>> c : oldList) {
                String name;
                try {
                    name = c.newInstance().id().toString();
                } catch (Exception e) {
                    name = "<ID not readable>";
                }
               
                oldListStr.add(c.toString() + " (ID: " + name + ")");
            }
           
            String pluginsFound = " Plugins found (including master schedulers).\n \n"; // Alright.
           
            // Check if plugins have been found and restore old list if not.
            if (PluginFactory.STORED_PLUGINS == null || PluginFactory.STORED_PLUGINS.size() == 0) {
              pluginsFound = " Plugins reloaded. WARNING: The search for plugins was NOT successful (see log for details). \n \n"; // Not alright.
            new FileCopy().copy(
                new File("./" + PluginFactory.PLUGIN_STORAGE_FILE_NAME + ".tmp"),
                new File("./" + PluginFactory.PLUGIN_STORAGE_FILE_NAME));
              PluginFactory.STORED_PLUGINS = PluginFactory.loadPluginsFromFile(includeHidden);
            }
           
View Full Code Here

                } catch (Exception e2) {
                    throw new RuntimeException("Plugin instance not created.");
                }
              File dir = new File(dirPrefixPlugin + "/" + c.getPackage().getName().replace('.', '/'));
              File dirOwn = new File("./" + c.getPackage().getName().replace('.', '/'));
              FileCopy copy = new FileCopy();
              dir.mkdirs();
             
              try {
          copy.copyFolder(dirOwn, dir, true, false);
        } catch (IOException e1) {
          GlobalVariables.getPrematureParameters().logError("Could not copy directory '" + dirOwn + "':" + e1.getMessage() + "\n" + Arrays.deepToString(e1.getStackTrace()).replace(',', '\n'));
          GlobalVariables.getPrematureParameters().logInfo("Plugin export aborted due to errors.");
          return;
        }
            }
           
            try {
        ZipIt.createJARfromDirectory(dirPrefix, storeFile, null);
      } catch (IOException e1) {
        GlobalVariables.getPrematureParameters().logError("Could not create JAR file '" + storeFile + "'.");
      }
           
            StaticMethods.delDir(new File(dirPrefix));
           
            GlobalVariables.getPrematureParameters().logInfo("Plugin JAR file '" + storeFile + "' exported.");
           
            GeneralDialog dia2 = new GeneralDialog(
                myStarter,
                null,
                "Export successful (" + selected.length + " plugins)",
                GeneralDialog.OK_BUTT,
                "Plugin JAR file '" + storeFile + "' exported:\n\n- " + Arrays.deepToString(selected).replace("[", "").replace("]", "").replace(", ", "\n- "));
            dia2.setVisible(true);
           
            return;
        } else if (e.getSource().equals(buttCancel)) {
            frame.dispose();
            return;
        }
       
        myStarter.actionPerformed(e);
       
        if (e.getActionCommand().equals(Starter.EXIT_STRING)) {
            myStarter.dispose();
            System.exit(0);
        } else if (e.getActionCommand().equals(Starter.LOAD_STORED_SIMULATION)) {
            if (loadSimState()) {
                this.myStarter.dispose();
            }
        } else if (e.getActionCommand().equals(Starter.EXPORT_PLUGINS_STRING)) {
            frame = new JDialog(myStarter, Starter.EXPORT_PLUGINS_STRING + " NOTE: all necessary classes have to be located in the package of the main plugin class.");
            JPanel panel = new JPanel(new GridLayout(2, 1));
            Object[] items = convertListToArray(getSharablePlugins());
            list = new JList(items);
            JScrollPane jScrollPane1 = new JScrollPane(list);
            panel.add(jScrollPane1);
           
            JPanel mainPanel = new JPanel();
            JPanel panel1 = new JPanel(new GridLayout(1, 4));
            panel1.add(buttOK);
            panel1.add(buttCancel);
           
            buttOK.addActionListener(this);
            buttCancel.addActionListener(this);
           
            panel.add(mainPanel);
            mainPanel.add(panel1);
           
            frame.getContentPane().add(panel);
            frame.setSize(750, 400);
            frame.setVisible(true);
        } else if (e.getActionCommand().equals(Starter.IMPORT_PLUGINS_STRING)) {
           
            // User selects file to import.
            FileDialog dia = new FileDialog(this.myStarter, "Choose JAR file to store plugins", FileDialog.LOAD);
            dia.setFilenameFilter(new FileNamePostfixFilter(".jar"));
            dia.setVisible(true);

            if (dia.getDirectory() == null || dia.getFile() == null) {
                return;
            }

            // Delete temp dir if existing.
            StaticMethods.delDir(new File(dirPrefix));

            // Extract ZIP archive from JAR.
            try {
                ZipIt.extractZIPArchive(
                        new File(dia.getDirectory() + File.separator + dia.getFile()),
                        new File("."));
            } catch (Exception e1) {
                e1.printStackTrace();
            }
           
            // Create list of plugin ids.
            LinkedList<Class<Plugin<?>>> list = PluginFactory.findAllNonAbstractPluginClasses(false);
            LinkedList<String> listPlugStr = new LinkedList<String>();
            for (Class<Plugin<?>> c : list) {
                try {
                    listPlugStr.add(c.newInstance().id());
                } catch (Exception e1) {
                    GlobalVariables.getPrematureParameters().logError("Plugin instance not created: " + c.getName());
                }
            }
           
            // Check if some new plugin id already exists.
            File[] files = new File(this.dirPrefix).listFiles();
            String[] selected = new String[files.length];
            int num = 0;
           
            for (File f : files) {
                boolean ignore = false;
               
                if (listPlugStr.contains(f.getName())) {
                    GeneralDialog dia2 = new GeneralDialog(
                            this.myStarter,
                            "A Plugin with id '" + f.getName() + "' already exists in local class tree. Do you wish to continue?",
                            "Plugin id exists",
                            GeneralDialog.YES_NO,
                            null);
                    dia2.setVisible(true);
                    if (dia2.getResult().equals(GeneralDialog.NO)) {
                        ignore = true;
                    }
                }
               
                if (!ignore) {
                    // Import plugin.
                    selected[num] = f.getName();
                   
                    String destDir = ".";
                    File destDirFile = new File(destDir);
                    try {
                        new FileCopy().copyFolder(f, destDirFile, true, true);
                    } catch (IOException e1) {
                        GlobalVariables.getPrematureParameters().logError("Could not copy directory '" + f + "':" + e1.getMessage() + "\n" + Arrays.deepToString(e1.getStackTrace()).replace(',', '\n'));
                    }
                } else {
                    selected[num] = f.getName() + " (NOT IMPORTED).";
View Full Code Here

TOP

Related Classes of eas.miscellaneous.system.FileCopy

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.