LH před 10 roky
rodič
revize
957193a015

+ 1 - 1
iZpl/build.gradle

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

+ 2 - 1
iZpl/src/main/java/de/nplusc/izc/iZpl/API/PlayListEditAPI.java

@@ -220,7 +220,8 @@ public class PlayListEditAPI
     public static void forceElement(int id)
     {
         
-        Main.getPLServer().getPlProcessorV2().forceNext(playListItemKeys.get(id));
+        Main.getPLServer().getPlProcessorV2().addElementToForcedList(
+        Main.getPLServer().getPlProcessorV2().getPool().get(playListItemKeys.get(id)));
     }
 
     private PlayListEditAPI()

+ 14 - 7
iZpl/src/main/java/de/nplusc/izc/iZpl/Main.java

@@ -209,7 +209,9 @@ public class Main extends javax.swing.JFrame
     {
         pluginInitCore(); //sorgt dafür dass plugins bereits registriert sind
         EventQueue.invokeLater(()->{
-        new MainMenu().setVisible(true);
+        MainMenu m = new MainMenu();
+        m.setIconImage(IZPLApi.getProgramIcon());
+        m.setVisible(true);
         });
     }
     
@@ -473,6 +475,13 @@ public class Main extends javax.swing.JFrame
 
         }
         //</editor-fold>
+        if(menumode)
+        {
+            spawnUI();
+            return;
+        }
+        
+        
         if (firstrunmode)
         {
             java.awt.EventQueue.invokeLater(() ->
@@ -482,18 +491,15 @@ public class Main extends javax.swing.JFrame
                 frs.setVisible(true);
             });
         }
-
+        
+        
+        
         l.info("Loading the configs now");
         loadConfigs();
         if (CONFIG.isStandaloneMode())
         {
             useGUI = true;
         }
-        if(menumode)
-        {
-            spawnUI();
-            return;
-        }
         detectSkins();
         l.info("Initializing the plugins now. This may take a while");
         initializePlugins();
@@ -1278,6 +1284,7 @@ public class Main extends javax.swing.JFrame
      * V0.4.1.0 work on adding FeaturePlugins
      * V0.4.1.1 Bugfixes
      * V0.5.0.0 MainMenu added
+     * V0.6.0.0 Editor basics, Bugfixxes & rewrite of the Reader code whic resides now in PLFileIO.java 
      */
 
 }

+ 1 - 176
iZpl/src/main/java/de/nplusc/izc/iZpl/PlProcessor.java

@@ -5,17 +5,14 @@
 package de.nplusc.izc.iZpl;
 
 import java.util.ArrayList;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 import org.yaml.snakeyaml.Yaml;
 
 /**
- *
+ * Compatibility stub without logic due to some unserializing of data
  * @author LH
  */
 public class PlProcessor //implements HttpHandler 
 {
-    private static final Logger l = LogManager.getLogger();
     private ArrayList<String[]> pool1=new ArrayList<>(),pool2=new ArrayList<>();//wird verschoben so dass jedes Element drankommt und dann erst von vorne begonnen wird
     private int poolSize=0;
     private int unusedElems=0;
@@ -97,177 +94,5 @@ public class PlProcessor //implements HttpHandler
     
     //</editor-fold>
     
-    /*
-    public void InitializeOnPath(String PlPath)
-    {
-        path=PlPath;
-        reloadLists();
-    }
-    
-    
-    public void reloadLists()
-    {
-        reloadLists(false);
-    }
-    
-    public void reloadLists(boolean reload)
-    {
-        pool1=new ArrayList<>();
-        if(!reload)
-        {
-            l.trace("Das solte nur bei Init auftauchen");
-            pool2=new ArrayList<>();//wichtig bei reload
-        }   
-        List<String[]> list = PLReader.readList(path);
-        if(list==null)
-        {
-            return;
-        }
-        String[] g0 = list.get(0);//0-liste muss anderst verarztet werden
-        for (String etr : g0)
-        {
-            pool1.add(new String[]{etr});//randomizer arbeitetblockweise und einzeleinträge=neue Blöcke
-        }
-        list.remove(0);//NA DU SCHEISSER; WIE ISTS NACH SO LANGER ZEIT GEKILLT ZU WERDEN!
-        for (String[] blox : list)
-        {
-            pool1.add(blox);
-        }
-        if(reload)
-        {
-            
-            l.info("StartingReloadProcess");
-            try
-            {
-                if (IZPLApi.createDebugDumps())
-                {
-                    FileTK.writeFile(yp.dump(pool2), "izpl-viewme.yDUMP");
-                }
-                for (int i=0;i<pool2.size();i++)
-                {
-                    String[] el=pool2.get(i);
-                    
-                     //FunztNichtError 
-                     //int idx = pool1.indexOf(el);
-                     int idx=-1;
-                     for (int j = 0; j < pool1.size(); j++)
-                    {
-                        String[] l = pool1.get(j);
-                        if(el[0].equals(l[0]))
-                        {
-                            idx=j;
-                            break;
-                        }
-                        
-                    }
-                     
-                     l.trace(idx);
-                     yp.dump(el);
-                     if(idx==-1)
-                     {
-                         pool2.remove(i);//entfernte elemente killen
-                     }
-                     else
-                     {
-                         pool1.remove(idx);//subtrahieren der bereits gespielten elemente
-                     }
-                }
-            }
-            catch(Exception e)
-            {
-                e.printStackTrace();
-            }
-        }
-        l.trace("><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><");
-        l.trace("<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>");
-        l.trace("><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><");
-        l.trace("ArrayResult of the Internal List");
-        l.trace("\n"+yp.dump(pool1));
-        l.trace("><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><");
-        l.trace("List2; nur bei Reload wixtix");
-        l.trace("\n"+yp.dump(pool2));
-        l.trace("ENd of Block:MasterbLOCK");
-        l.trace("><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><");
-        l.trace("<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>");
-        l.trace("><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><");
-        if(!reload)
-        {
-            poolSize = pool1.size();
-            unusedElems=poolSize;
-        }
-        else
-        {
-            poolSize=pool1.size()+pool2.size();
-            unusedElems = pool1.size();
-        }
-    }
-    
-    
-    
-    
-    @Override
-    public void handle(HttpExchange t) throws IOException 
-    {
-        String time = new Date(System.currentTimeMillis()).toString();
-        l.info("IZPL-HAndler:Received Request at:"+time);
-         String response = "Nixda mit glotzen...\n Hier gibts keine Filezzzzzzz, also raus und zwar dalli";
-       /* if(!t.getRemoteAddress().getHostName().equalsIgnoreCase("localhost"))
-        {
-        t.sendResponseHeaders(403, response.length());
-        OutputStream os = t.getResponseBody();
-        os.write(response.getBytes());
-        os.close();
-        return;
-        }* /
-        response = "#EXTM3U";
-                //  \N am anfang jeder zeile....
-        String tr = getBlock();
-        response+=tr;
-        response+="\nhttp://localhost:9263/lst.m3u";//:9263/lst.m3u";//continueCode //Exit wird durch unblock woanderst realisiert
-        l.info("IZPL-HAndler:Responded with:"+response);
-        t.sendResponseHeaders(200, response.length());
-        Headers responseHeaders = t.getResponseHeaders();
-        responseHeaders.set("Content-Type", "audio/x-mpegurl");
-
-        OutputStream os = t.getResponseBody();
-        os.write(response.getBytes());
-        failRSP=response;
-        os.close();
-        time = new Date(System.currentTimeMillis()).toString();
-        l.info("IZPL-HAndler:Answered Request at:"+time);
-    }
-    public String getBlock()
-    {
-        String response = "";
-        double rm = Math.random();//Zufallsselektor
-        int selection = (int) (rm*unusedElems);//macht nix...
-        String[] loadedBlock = pool1.get(selection);
-        if(loadedBlock[0].length()>5)
-        {
-        pool2.add(loadedBlock); //legts in benutzt-Pool ab //wenn Pool1 leer dann tauschen diese ihren Platz
-        }
-        else
-        {
-            poolSize--;
-            unusedElems--;
-            pool1.remove(selection);//nimmts vorm nxten durchlauf raus
-            return getBlock();
-        }
-        pool1.remove(selection);//nimmts vorm nxten durchlauf raus
-        unusedElems--;
-        if(unusedElems==0)//Bei ende refill
-        {
-            pool1=pool2;
-            pool2=new ArrayList<>();
-            unusedElems=poolSize;
-        }
-        for (String line : loadedBlock)
-        {
-            response+="\n"+line;
-            
-        }
-        response=response.replaceAll("\\\n\\\n", "\\\n");
-        return response;
-    }*/
 }
 

+ 13 - 13
iZpl/src/main/java/de/nplusc/izc/iZpl/PlProcessorV2.java

@@ -30,7 +30,9 @@ public class PlProcessorV2 implements HttpHandler
     private HashMap<String,PlayListItem> pool;
     private String path;
     private List<String> availEtrs;
-    private PlayListItem forced=null;
+    private List<PlayListItem> forceList;
+    
+    
     /* public PlProcessor(String PlPath)
     {
     }*/
@@ -92,12 +94,7 @@ public class PlProcessorV2 implements HttpHandler
     {
         path=PlPath;
         reloadLists();
-        forced=null;
-    }
-    
-    public void forceNext(String hmid)
-    {
-        forced=pool.get(hmid);
+        forceList=new ArrayList<>();
     }
     private static Yaml yp = new Yaml();
     public void reloadLists()
@@ -225,9 +222,9 @@ public class PlProcessorV2 implements HttpHandler
     public boolean resetted;
     public PlayListItem getBlockRaw()
     {
-        l.trace("Forced=\""+forced+"\"");
+       
         PlayListItem response = null;
-        if(forced==null)
+        if(forceList.isEmpty())
         {
             l.trace("Normal handling");
             double rm = Math.random();//Zufallsselektor
@@ -250,8 +247,9 @@ public class PlProcessorV2 implements HttpHandler
         }
         else
         {
-            response=forced;
-            forced=null;
+            l.trace("Forced=\""+forceList.get(0)+"\"");
+            response=forceList.get(0);
+            forceList.remove(0);
         }
         return response;
     }
@@ -265,8 +263,10 @@ public class PlProcessorV2 implements HttpHandler
         return response;
     }
     
-    
-    
+    public void addElementToForcedList(PlayListItem i)
+    {
+        forceList.add(i);
+    }
     
     public int getPoolSize()
     {

+ 38 - 1
iZplPlugins/Editor/src/main/java/de/nplusc/izc/izpl/plugins/editor/Editor.java

@@ -11,8 +11,11 @@ import de.nplusc.izc.iZpl.API.IZPLApi;
 import de.nplusc.izc.iZpl.API.InvalidPlayListFileException;
 import de.nplusc.izc.iZpl.API.PlayListFile;
 import de.nplusc.izc.iZpl.API.SinglePlayListItem;
+import de.nplusc.izc.tools.baseTools.Tools;
 import de.schlichtherle.truezip.file.TFile;
 import java.awt.EventQueue;
+import java.io.FileWriter;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -42,7 +45,40 @@ public class Editor implements FeaturePlugin
     {
         if(param==null||param.equals(""))
         {
-            //newfilehandling
+            boolean nf = Tools.dlg(true, "Neue playliste erstellen", "oder existierende laden", "Neu", "Laden");
+            String fp = Tools.FileChooseDlg(null, true,false,new String[]{"izpl"});
+            TFile trg = new TFile(fp);
+            if(nf)
+            {
+                if(trg.exists())
+                {
+                    l.error("File already exist, no chance for a Reset");
+                    JOptionPane.showMessageDialog(null, "File already exists", "Error", JOptionPane.ERROR_MESSAGE);
+                }
+                else
+                {
+                    try
+                    {
+                        trg.createNewFile();
+                        FileWriter fw = new FileWriter(trg);
+                        fw.append("#EXTM3U\n#IZPL");
+                        fw.close();
+                        loadPlayListIntoGraph(fp);
+                    }
+                    catch(IOException e)
+                    {
+                        l.error("Could not create File");
+                        JOptionPane.showMessageDialog(null, "Could not create File", "Error", JOptionPane.ERROR_MESSAGE);
+                    }
+                }
+            }
+            else
+            {
+                if(trg.exists())
+                {
+                    loadPlayListIntoGraph(fp);
+                }
+            }
         }
         else
         {
@@ -52,6 +88,7 @@ public class Editor implements FeaturePlugin
             }
             else
             {
+                
                 l.error("Keine gültige r00tPlayList");
             }
             openUserInterface();

+ 12 - 8
iZplPlugins/Editor/src/main/java/de/nplusc/izc/izpl/plugins/editor/EditorUICommon.form

@@ -28,21 +28,17 @@
               <Component id="btnSave" min="-2" pref="115" max="-2" attributes="0"/>
               <EmptySpace type="unrelated" max="-2" attributes="0"/>
               <Component id="btnLoad" min="-2" pref="113" max="-2" attributes="0"/>
-              <EmptySpace pref="703" max="32767" attributes="0"/>
-          </Group>
-          <Group type="102" alignment="0" attributes="0">
-              <EmptySpace max="-2" attributes="0"/>
-              <Component id="tpMain" max="32767" attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
+              <EmptySpace pref="712" max="32767" attributes="0"/>
           </Group>
+          <Component id="tpMain" alignment="0" max="32767" attributes="0"/>
       </Group>
     </DimensionLayout>
     <DimensionLayout dim="1">
       <Group type="103" groupAlignment="0" attributes="0">
           <Group type="102" alignment="1" attributes="0">
               <EmptySpace max="-2" attributes="0"/>
-              <Component id="tpMain" pref="612" max="32767" attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
+              <Component id="tpMain" pref="671" max="32767" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
               <Group type="103" groupAlignment="1" max="-2" attributes="0">
                   <Component id="btnLoad" pref="41" max="32767" attributes="0"/>
                   <Component id="btnSave" max="32767" attributes="0"/>
@@ -70,6 +66,14 @@
       </Events>
     </Component>
     <Container class="javax.swing.JTabbedPane" name="tpMain">
+      <Properties>
+        <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[971, 623]"/>
+        </Property>
+        <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[971, 623]"/>
+        </Property>
+      </Properties>
 
       <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
     </Container>

+ 7 - 7
iZplPlugins/Editor/src/main/java/de/nplusc/izc/izpl/plugins/editor/EditorUICommon.java

@@ -131,6 +131,9 @@ public class EditorUICommon extends javax.swing.JFrame
             }
         });
 
+        tpMain.setMinimumSize(new java.awt.Dimension(971, 623));
+        tpMain.setPreferredSize(new java.awt.Dimension(971, 623));
+
         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
         getContentPane().setLayout(layout);
         layout.setHorizontalGroup(
@@ -140,18 +143,15 @@ public class EditorUICommon extends javax.swing.JFrame
                 .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                 .addComponent(btnLoad, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addContainerGap(703, Short.MAX_VALUE))
-            .addGroup(layout.createSequentialGroup()
-                .addContainerGap()
-                .addComponent(tpMain)
-                .addContainerGap())
+                .addContainerGap(712, Short.MAX_VALUE))
+            .addComponent(tpMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
         );
         layout.setVerticalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                 .addContainerGap()
-                .addComponent(tpMain, javax.swing.GroupLayout.DEFAULT_SIZE, 612, Short.MAX_VALUE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(tpMain, javax.swing.GroupLayout.DEFAULT_SIZE, 671, Short.MAX_VALUE)
+                .addGap(18, 18, 18)
                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                     .addComponent(btnLoad, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE)
                     .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))