Pārlūkot izejas kodu

Made the izpl-shared part android-ready. Fixxxxxed the Editor-plugin not
loading under some circumstances / fixed a unneeded DIalog

LH 10 gadi atpakaļ
vecāks
revīzija
bff4c2f4e3

+ 51 - 0
IZPL-A/build.gradle

@@ -0,0 +1,51 @@
+defaultTasks 'distZip'
+
+apply plugin: 'java'
+apply plugin: 'application'
+
+
+sourceCompatibility = 1.8
+version = 'SNAPSHOT'
+mainClassName = 'de.nplusc.izc.iZpl.Builder'
+
+
+jar{
+	manifest{
+		attributes 'Implementation-Title': 'iZToolKit',
+					'Implementation-Version': 'SNAPSHOT',
+					'Main-Class': 'de.nplusc.izc.iZpl.Builder'
+					
+	}
+}
+
+repositories{
+	jcenter()
+}
+
+compileJava {
+options.compilerArgs << '-Xlint:none'
+
+options.compilerArgs << '-Xlint:-deprecation'
+
+options.compilerArgs << '-XDignore.symbol.file'
+}
+
+dependencies{
+	compile fileTree(dir: 'lib', include: '*.jar')
+	compile "commons-io:commons-io:2.+"
+	compile 'org.apache.commons:commons-exec:1.3'
+	compile "org.yaml:snakeyaml:1.14"
+	compile "commons-net:commons-net:3.3"
+	compile 'org.ini4j:ini4j:0.5.2'
+	compile 'org.im4java:im4java:1.4.0'
+    compile 'net.java.dev.jna:jna:3.5.2'
+	compile 'uk.co.caprica:vlcj:3.0.1' //HACK! bezüglich JNA
+    compile	'org.xerial:sqlite-jdbc:3.8.7'
+	compile 'mysql:mysql-connector-java:5.1.6'
+	compile(project(':ToolKit')) {
+        transitive = false
+    }
+
+
+	
+}

+ 1 - 0
Readme.txt

@@ -12,6 +12,7 @@ iZplaylist:
     OSes: Windows
     to compile run gradlew iZpl:dZ in the root folder.
     Output is in iZpl/build/distributions 
+    SOme components reside in izpl-shared so they can also be reused by izpl-server and other ports in the future
 iZPlaylist-Plugins:
     Folder: izplplugins
     Remark: Cntains only submodules

+ 0 - 1
ToolKit/src/main/java/de/nplusc/izc/tools/UiToolz/UIFileAccess.java

@@ -21,7 +21,6 @@ package de.nplusc.izc.tools.UiToolz;
 
 import de.nplusc.izc.tools.IOtools.ZipFileHandler;
 import de.nplusc.izc.tools.IOtools.FileTK;
-import de.nplusc.izc.tools.baseTools.Tools;
 import java.awt.*;
 import java.io.ByteArrayInputStream;
 import java.io.File;

+ 2 - 178
ToolKit/src/main/java/de/nplusc/izc/tools/baseTools/Tools.java

@@ -436,35 +436,6 @@ public class Tools
                     .addContainerGap(71, Short.MAX_VALUE)));
             // </editor-fold>
 
-            //Auskommentierter Fail!
-            // <editor-fold defaultstate="collapsed" desc="FailTry">
-/*javax.swing.JButton btnYes = new javax.swing.JButton();
-             btnYes.addActionListener
-             (
-             new java.awt.event.ActionListener()
-             {
-             public void actionPerformed(java.awt.event.ActionEvent evt)
-             {
-             btnCTNActionPerformed(evt);
-             }
-             }
-             );
-             javax.swing.JButton btnNo = new javax.swing.JButton();
-             btnNo.addActionListener
-             (
-             new java.awt.event.ActionListener()
-             {
-             public void actionPerformed(java.awt.event.ActionEvent evt)
-             {
-             btnSTPActionPerformed(evt);
-             }
-             }
-             );
-             btnYes.setText("Fortsetzen");
-             btnNo.setText("Abbrechen");*/
-            //d.add(new JButton());// </editor-fold>
-
-
             //p.add(btnYes);
             //p.add(btnNo);
             d.add(p);
@@ -640,97 +611,6 @@ public class Tools
         }
         return cret;
     }
-    //public void runProcessBuilderCmd(String workdir,String executable)
-    //{
-    //    ProcessBuilder p = new ProcessBuilder(executable);
-    //    p.directory(new File(workdir));
-    //    p.start();
-    //}
-    
-    // <editor-fold defaultstate="collapsed" desc="Altlast">
-    /*
-     public static int cmdrunner(final ProcessBuilder p, final String[] runnable)
-     {
-     return cmdrunner(p,runnable,true);
-     }*/
-    /*
-     public static int cmdrunner(final ProcessBuilder p, final String[] runnable, final boolean bjCmd)
-     {
-     //try {
-     Thread t = new Thread(new Runnable() {
-
-     //@SuppressWarnings("SleepWhileInLoop")//Hx
-     @SuppressWarnings("CallToThreadDumpStack")
-     public void run() {
-
-     //try {
-     d = null;
-     d = new JDialog();
-                
-     try {
-     //e.
-     //exp=null;
-     //exp = new ExpectJ(5);
-     String run = arraytools.ArrayKleben(runnable," ");
-     //Spawn s = exp.spawn(run);
-     try {
-     e = p.start();
-     //s.expectErr(".");
-     } catch (Exception ex) {
-     ex.printStackTrace();
-     }
-     output = new StreamGobbler(e.getInputStream(), ">>");
-     error = new StreamGobbler(e.getErrorStream(), "!>");
-     output.start();
-     error.start();
-                    
-     if(bjCmd)
-     {
-     jCmd();
-     }
-     /* else
-     {
-     while(error.)
-     {
-                            
-     }
-     }*
-     * /
-     //int r = 1;
-     } catch (Exception ex) {
-     ex.printStackTrace();
-     }
-
-
-
-     //e.
-     /*}
-     catch (IOException ex) 
-     {
-     ex.printStackTrace();
-     r=100;
-     }*
-     * /
-
-     }
-     });
-        
-     t.start();
-     /*NOP* /
-     r = 1;
-     return r;
-     /*} catch (IOException ex) {
-     ex.printStackTrace();
-     }
-     return 0;* /
-        
-        
-     }
-    
-    
-    
-     */
-    //</editor-fold>
     private static void btnYesActionPerformed(java.awt.event.ActionEvent evt)
     {
         ContState = true;
@@ -739,36 +619,7 @@ public class Tools
         d = new JDialog();
     }
 
-    // <editor-fold defaultstate="collapsed" desc="Altlast">
-    /*
-     private static void cmdQuitActionPerformed(java.awt.event.ActionEvent evt)
-     {
-        
-     hideDialog();
-     d=null;
-     d = new JDialog();
-     e.destroy();
-     //error.
-     }*/
-    //@SuppressWarnings("CallToThreadDumpStack")
-     /*   private static void eingabeActionPerformed(java.awt.event.ActionEvent evt)
-     {
-     String cmd = cmdline.getText()+"\n";
-     //NOP;
-     OutputStreamWriter osw = new OutputStreamWriter(e.getOutputStream());
-     BufferedWriter bw = new BufferedWriter(osw);
-     try {
-     bw.write(cmd,0,cmd.length());
-     log("I>"+cmd);
-     //output.start();
-     //error.start();
-     } catch (IOException ex) {
-     ex.printStackTrace();
-     }
-     d.validate();
-     }*/
-    //</editor-fold>
-    private static void btnNoActionPerformed(java.awt.event.ActionEvent evt)
+  private static void btnNoActionPerformed(java.awt.event.ActionEvent evt)
     {
         ContState = false;
         hideDialog();
@@ -811,7 +662,7 @@ public class Tools
             }
         }
         else
-        {
+        {   //Evil loop :P (linenumber)
             for (int i = 0; i > toTrunc.length - number; i++)
             {
                 int j = i + number;
@@ -1490,33 +1341,6 @@ public class Tools
         
         return line.replaceAll("#"+varname+"#", toReplace.replace("\\", "\\\\")).replace("\\\\", "\\");
         
-        /*
-        String linemod = line;
-        int varstart = linemod.indexOf("#");
-        int varend = linemod.indexOf("#", varstart + 1);
-        String preVar = "";
-        if (varstart == -1||varend == -1)
-        {
-            return line;
-        }
-        if (varstart > 0)
-        {
-            preVar = linemod.substring(0, varstart);
-        }
-        String postVar = linemod.substring(varend + 1);
-        String var = linemod.substring(varstart + 1, varend);
-        if(var.equalsIgnoreCase(varname))
-        {
-        var = toReplace;
-        postVar=replaceHashmarkedVars(postVar, varname, toReplace);//falls sich noch wo anders eine versteckt
-        }
-        else
-        {
-            var="#"+var+"#";
-            postVar=replaceHashmarkedVars(postVar, varname, toReplace);//falls sich noch wo anders eine versteckt
-        }
-        line = preVar + var + postVar;
-        return line;*/
     }
     
     public static void DebugHelperPrint(String msg,boolean dbgonly,String debugEnablePreference)

+ 1 - 1
iZpl/build.gradle

@@ -8,7 +8,7 @@ apply plugin: 'java'
 apply plugin: 'application'
 apply from: "$rootDir/utils/IO.gradle"
 
-version = '0.7.0.0'
+version = '0.7.1.0'
 mainClassName = 'de.nplusc.izc.iZpl.Main'
 //'de.nplusc.izc.iZpl.Main'
 

+ 23 - 4
iZpl/src/main/java/de/nplusc/izc/iZpl/GUI/MainMenu.java

@@ -6,7 +6,9 @@
 
 package de.nplusc.izc.iZpl.GUI;
 
+import de.nplusc.izc.iZpl.API.FeaturePlugin;
 import de.nplusc.izc.iZpl.API.IZPLApi;
+import de.nplusc.izc.iZpl.API.Plugin;
 import de.nplusc.izc.iZpl.Main;
 import de.nplusc.izc.tools.IOtools.FileTK;
 import de.nplusc.izc.tools.baseTools.Tools;
@@ -282,13 +284,30 @@ public class MainMenu extends javax.swing.JFrame
         back.setVisible(true);
         pluginLaunchInit.setVisible(false);
     }//GEN-LAST:event_pluginLaunchInitActionPerformed
-
+    private String loadedFile ="";
+    private String fex = "nope";
     private void pluginLaunchActionActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_pluginLaunchActionActionPerformed
     {//GEN-HEADEREND:event_pluginLaunchActionActionPerformed
-        String loadedFile = Tools.FileChooseDlg(this,true, false, new String[]{"izpl","izcont"});
-        if(!loadedFile.equals(""))
+        boolean freq=true;
+        for(FeaturePlugin plg:IZPLApi.getPluginManager().getRegisteredFeatures())
         {
-            String fex = FileTK.getFileExt(loadedFile);
+            if(plg.getPluginName().equals( lstFeraturePlugins.getSelectedValue()+""))
+            {
+                freq=plg.requiresLoadedPlayList();
+            }
+        }
+        
+        
+        if(freq)
+        loadedFile= Tools.FileChooseDlg(this,true, false, new String[]{"izpl","izcont"});
+        
+        if(!freq||!loadedFile.equals(""))
+        {
+            
+            if(!loadedFile.equals(""))
+            {
+                fex=FileTK.getFileExt(loadedFile);
+            }
             Thread t = new Thread(()->{
                 Main.UIMain(fex.equalsIgnoreCase("izpl"), fex.equalsIgnoreCase("izcont"), loadedFile ,
                     false, false, false,

+ 3 - 0
iZpl/src/main/java/de/nplusc/izc/iZpl/Main.java

@@ -662,6 +662,9 @@ public class Main extends javax.swing.JFrame
     
     //</editor-fold>
     
+    //V--nothing to see here
+    
+    //^--evil line doesnt need any code :P
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private static javax.swing.JProgressBar pload;
     // End of variables declaration//GEN-END:variables

+ 2 - 0
iZplPlugins/Editor/src/main/java/de/nplusc/izc/izpl/plugins/editor/Editor.java

@@ -75,6 +75,7 @@ public class Editor implements FeaturePlugin
                         fw.append("#EXTM3U\n#IZPL");
                         fw.close();
                         loadPlayListIntoGraph(fp);
+                        openUserInterface();
                     }
                     catch(IOException e)
                     {
@@ -88,6 +89,7 @@ public class Editor implements FeaturePlugin
                 if(trg.exists())
                 {
                     loadPlayListIntoGraph(fp);
+                    openUserInterface();
                 }
             }
         }

+ 58 - 19
izpl-shared/src/main/java/de/nplusc/izc/iZpl/Utils/shared/PLFileIO.java

@@ -28,6 +28,8 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.RandomAccessFile;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -299,30 +301,67 @@ public class PLFileIO
     
     public static void writePLFile(PlayListFile f)
     {
-        Path p =  new File(f.getPath()).getParentFile().toPath();
-        try
-        {
-            String fp = f.getPath();
-            String pld = "#EXTM3U\n#IZPL\n";
-            for (SinglePlayListItem pli : f.getEntries())
+        // Arbeit mit derPath-Klasse & der File.getPath() methode, Reflection dient zur Kompatibilität mitSystemen ohne dieser Klasse (wie Androiden)
+        try{
+            boolean supportinRelativeness=false;
+            Object basepath = null;
+            Class pathclass=null;
+            try
             {
-                String pathOfFile = p.relativize(new File(pli.getPath()).toPath()).toString();
-                
-                
-                if(pli.isIncludeElement())
-                {
-                    pld+="#IZPL:INCLUDE|"+pli.getTargetPlaycount()+"|"+(pli.noexpandoninclude()?"NOEXPAND":"EXPAND")+"\n"+pathOfFile+"\n";
-                }
-                else
+                pathclass = Class.forName("java.nio.file.Path");
+                supportinRelativeness=true;
+            }
+            catch(ClassNotFoundException x)
+            {
+                //Nix da wenn der error auftritt nur ein feature deaktiviert wird
+            }
+            Method pfadheraberdalli = File.class.getMethod("toPath");
+            
+            if(supportinRelativeness)
+            {
+                File magix = new File(f.getPath()).getParentFile();
+                basepath =  pfadheraberdalli.invoke(magix);
+            }
+            try
+            {
+                String fp = f.getPath();
+                String pld = "#EXTM3U\n#IZPL\n";
+                for (SinglePlayListItem pli : f.getEntries())
                 {
-                    pld+=pli.getTitle()+"\n"+"#IZPL:"+pli.getTargetPlaycount()+"|"+pli.getGID()+"\n"+pathOfFile+"\n";
+                    String pathOfFile = pli.getPath();
+                            
+                    if(supportinRelativeness)
+                    {
+                        Method rel=pathclass.getMethod("relativize", (Class)pathclass);
+                        File current = new File(pathOfFile);
+                        Object pa = pfadheraberdalli.invoke(current);
+                        l.trace("pa-Class:"+pa.getClass());
+                        Object figgdi = rel.invoke(basepath, pa);
+                        l.trace("figgdi-Class:"+figgdi.getClass());
+                        pathOfFile=figgdi+"";
+                    }
+                           // = p.relativize(new File().toPath()).toString();
+
+
+                    if(pli.isIncludeElement())
+                    {
+                        pld+="#IZPL:INCLUDE|"+pli.getTargetPlaycount()+"|"+(pli.noexpandoninclude()?"NOEXPAND":"EXPAND")+"\n"+pathOfFile+"\n";
+                    }
+                    else
+                    {
+                        pld+=pli.getTitle()+"\n"+"#IZPL:"+pli.getTargetPlaycount()+"|"+pli.getGID()+"\n"+pathOfFile+"\n";
+                    }
                 }
+                RandomAccessFile file = new RandomAccessFile(fp, "rw");
+                file.setLength(0);
+                file.write(pld.getBytes());
+            }
+            catch (IOException ex)
+            {
+                ex.printStackTrace();
             }
-            RandomAccessFile file = new RandomAccessFile(fp, "rw");
-            file.setLength(0);
-            file.write(pld.getBytes());
         }
-        catch (IOException ex)
+        catch(NoSuchMethodException |IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
         {
             ex.printStackTrace();
         }