Explorar o código

added iZpl-RTSS-Link to display current track on the Afterburner overlay

LH %!s(int64=7) %!d(string=hai) anos
pai
achega
98fa0e15a8
Modificáronse 20 ficheiros con 2893 adicións e 2616 borrados
  1. 434 433
      ToolKit/src/main/java/de/nplusc/izc/tools/UiToolz/ComponentMover.java
  2. 28 0
      ToolKit/src/main/java/de/nplusc/izc/tools/baseTools/OutputStreamBridge.java
  3. 1579 1564
      ToolKit/src/main/java/de/nplusc/izc/tools/baseTools/Tools.java
  4. 2 1
      iZpl/build.gradle
  5. 27 0
      iZpl/src/main/java/de/nplusc/izc/iZpl/API/IZPLApi.java
  6. 31 0
      iZpl/src/main/java/de/nplusc/izc/iZpl/API/PlaybackStatusPlugin.java
  7. 463 434
      iZpl/src/main/java/de/nplusc/izc/iZpl/API/PluginManager.java
  8. 1 2
      iZpl/src/main/java/de/nplusc/izc/iZpl/Utils/VlcInterface.java
  9. 179 179
      iZplPlugins/WMP/src/main/java/de/nplusc/izc/izpl/plugins/wmp/WMPNAtive.java
  10. 1 0
      iZplPlugins/rtsslink/.gitignore
  11. 19 0
      iZplPlugins/rtsslink/build.gradle
  12. 106 0
      iZplPlugins/rtsslink/src/main/java/de/nplusc/izc/izpl/plugins/rtss/RTSSLink.java
  13. BIN=BIN
      iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x64/RTSSLink.exe
  14. 6 0
      iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x64/RTSSLink.exe.config
  15. BIN=BIN
      iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x64/RTSSSharedMemoryNET.dll
  16. BIN=BIN
      iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x86/RTSSLink.exe
  17. 6 0
      iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x86/RTSSLink.exe.config
  18. BIN=BIN
      iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x86/RTSSSharedMemoryNET.dll
  19. 8 0
      iZplPlugins/rtsslink/src/main/resources/plugin.yml
  20. 3 3
      settings.gradle

+ 434 - 433
ToolKit/src/main/java/de/nplusc/izc/tools/UiToolz/ComponentMover.java

@@ -1,433 +1,434 @@
-/*
- * Copyright (C) 2015 iZc
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package de.nplusc.izc.tools.UiToolz;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
-
-/**
- * This class allows you to move a Component by using a mouse. The Component
- * moved can be a high level Window (ie. Window, Frame, Dialog) in which case
- * the Window is moved within the desktop. Or the Component can belong to a
- * Container in which case the Component is moved within the Container.
- *
- * When moving a Window, the listener can be added to a child Component of
- * the Window. In this case attempting to move the child will result in the
- * Window moving. For example, you might create a custom "Title Bar" for an
- * undecorated Window and moving of the Window is accomplished by moving the
- * title bar only. Multiple components can be registered as "window movers".
- *
- * Components can be registered when the class is created. Additional
- * components can be added at any time using the registerComponent() method.
- *
- *
- * Gotten here: http://tips4java.wordpress.com/2009/06/14/moving-windows/
- */
-public class ComponentMover extends MouseAdapter
-{
-
-    private Insets dragInsets = new Insets(0, 0, 0, 0);
-    private Dimension snapSize = new Dimension(1, 1);
-    private Insets edgeInsets = new Insets(0, 0, 0, 0);
-    private boolean changeCursor = true;
-    private boolean autoLayout = false;
-    
-    private Class destinationClass;
-    private Component destinationComponent;
-    private Component destination;
-    private Component source;
-    //iZink_addition
-    private HashMap<Component,Point> baseLocationsAdditional=new HashMap<>();
-    private ArrayList<Component> additionalDestinations=new ArrayList<>();
-    private Point pressed;
-    private Point location;
-    
-    private Cursor originalCursor;
-    private boolean autoscrolls;
-    private boolean potentialDrag;
-
-    /**
-     * Constructor for moving individual components. The components must be
-     * regisetered using the registerComponent() method.
-     */
-    public ComponentMover()
-    {
-    }
-
-    /**
-     * Constructor to specify a Class of Component that will be moved when
-     * drag events are generated on a registered child component. The events
-     * will be passed to the first ancestor of this specified class.
-     *
-     * @param destinationClass the Class of the ancestor component
-     * @param components the Components to be registered for forwarding
-     * drag events to the ancestor Component.
-     */
-    public ComponentMover(Class destinationClass, Component... components)
-    {
-        this.destinationClass = destinationClass;
-        registerComponent(components);
-    }
-
-    /**
-     * Constructor to specify a parent component that will be moved when drag
-     * events are generated on a registered child component.
-     *
-     * @param destinationComponent the component drage events should be forwareded to
-     * @param components the Components to be registered for forwarding drag
-     * events to the parent component to be moved
-     */
-    public ComponentMover(Component destinationComponent, Component... components)
-    {
-        this.destinationComponent = destinationComponent;
-        registerComponent(components);
-    }
-
-    /**
-     * Get the auto layout property
-     *
-     * @return the auto layout property
-     */
-    public boolean isAutoLayout()
-    {
-        return autoLayout;
-    }
-
-    /**
-     * Set the auto layout property
-     *
-     * @param autoLayout when true layout will be invoked on the parent container
-     */
-    public void setAutoLayout(boolean autoLayout)
-    {
-        this.autoLayout = autoLayout;
-    }
-
-    /**
-     * Get the change cursor property
-     *
-     * @return the change cursor property
-     */
-    public boolean isChangeCursor()
-    {
-        return changeCursor;
-    }
-
-    /**
-     * Set the change cursor property
-     *
-     * @param changeCursor when true the cursor will be changed to the
-     * Cursor.MOVE_CURSOR while the mouse is pressed
-     */
-    public void setChangeCursor(boolean changeCursor)
-    {
-        this.changeCursor = changeCursor;
-    }
-
-    /**
-     * Get the drag insets
-     *
-     * @return the drag insets
-     */
-    public Insets getDragInsets()
-    {
-        return dragInsets;
-    }
-
-    /**
-     * Set the drag insets. The insets specify an area where mouseDragged
-     * events should be ignored and therefore the component will not be moved.
-     * This will prevent these events from being confused with a
-     * MouseMotionListener that supports component resizing.
-     *
-     * @param dragInsets
-     */
-    public void setDragInsets(Insets dragInsets)
-    {
-        this.dragInsets = dragInsets;
-    }
-
-    /**
-     * Get the bounds insets
-     *
-     * @return the bounds insets
-     */
-    public Insets getEdgeInsets()
-    {
-        return edgeInsets;
-    }
-
-    /**
-     * Set the edge insets. The insets specify how close to each edge of the parent
-     * component that the child component can be moved. Positive values means the
-     * component must be contained within the parent. Negative values means the
-     * component can be moved outside the parent.
-     *
-     * @param edgeInsets
-     */
-    public void setEdgeInsets(Insets edgeInsets)
-    {
-        this.edgeInsets = edgeInsets;
-    }
-
-    /**
-     * Remove listeners from the specified component
-     *
-     * @param components the component the listeners are removed from
-     */
-    public void deregisterComponent(Component... components)
-    {
-        for (Component component : components)
-        {
-            component.removeMouseListener(this);
-        }
-    }
-
-    /**
-     * Add the required listeners to the specified component
-     *
-     * @param components the component the listeners are added to
-     */
-    public void registerComponent(Component... components)
-    {
-        for (Component component : components)
-        {
-            component.addMouseListener(this);
-        }
-    }
-
-    /**
-     * Get the snap size
-     *
-     * @return the snap size
-     */
-    public Dimension getSnapSize()
-    {
-        return snapSize;
-    }
-
-    /**
-     * Set the snap size. Forces the component to be snapped to
-     * the closest grid position. Snapping will occur when the mouse is
-     * dragged half way.
-     */
-    public void setSnapSize(Dimension snapSize)
-    {
-        if (snapSize.width < 1
-                || snapSize.height < 1)
-        {
-            throw new IllegalArgumentException("Snap sizes must be greater than 0");
-        }
-        
-        this.snapSize = snapSize;
-    }
-
-    /**
-     * Setup the variables used to control the moving of the component:
-     *
-     * source - the source component of the mouse event
-     * destination - the component that will ultimately be moved
-     * pressed - the Point where the mouse was pressed in the destination
-     * component coordinates.
-     */
-    @Override
-    public void mousePressed(MouseEvent e)
-    {
-        source = e.getComponent();
-        int width = source.getSize().width - dragInsets.left - dragInsets.right;
-        int height = source.getSize().height - dragInsets.top - dragInsets.bottom;
-        Rectangle r = new Rectangle(dragInsets.left, dragInsets.top, width, height);
-        
-        if (r.contains(e.getPoint()))
-        {
-            setupForDragging(e);
-        }
-    }
-    
-    private void setupForDragging(MouseEvent e)
-    {
-        source.addMouseMotionListener(this);
-        potentialDrag = true;
-
-		//  Determine the component that will ultimately be moved
-        if (destinationComponent != null)
-        {
-            destination = destinationComponent;
-        }
-        else if (destinationClass == null)
-        {
-            destination = source;
-        }
-        else  //  forward events to destination component
-        {
-            destination = SwingUtilities.getAncestorOfClass(destinationClass, source);
-        }
-        
-        pressed = e.getLocationOnScreen();
-        location = destination.getLocation();
-        
-        for (Component component : additionalDestinations)
-        {
-            baseLocationsAdditional.put(component, component.getLocation());
-        }
-        if (changeCursor)
-        {
-            originalCursor = source.getCursor();
-            source.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
-        }
-
-		//  Making sure autoscrolls is false will allow for smoother dragging of
-        //  individual components
-        if (destination instanceof JComponent)
-        {
-            JComponent jc = (JComponent) destination;
-            autoscrolls = jc.getAutoscrolls();
-            jc.setAutoscrolls(false);
-        }
-    }
-
-    /**
-     * Move the component to its new location. The dragged Point must be in
-     * the destination coordinates.
-     */
-    @Override
-    public void mouseDragged(MouseEvent e)
-    {
-        Point dragged = e.getLocationOnScreen();
-        int dragX = getDragDistance(dragged.x, pressed.x, snapSize.width);
-        int dragY = getDragDistance(dragged.y, pressed.y, snapSize.height);
-        
-        int locationX = location.x + dragX;
-        int locationY = location.y + dragY;
-
-		//  Mouse dragged events are not generated for every pixel the mouse
-        //  is moved. Adjust the location to make sure we are still on a
-        //  snap value.
-        while (locationX < edgeInsets.left)
-        {
-            locationX += snapSize.width;
-        }
-        
-        while (locationY < edgeInsets.top)
-        {
-            locationY += snapSize.height;
-        }
-        
-        Dimension d = getBoundingSize(destination);
-        
-        while (locationX + destination.getSize().width + edgeInsets.right > d.width)
-        {
-            locationX -= snapSize.width;
-        }
-        
-        while (locationY + destination.getSize().height + edgeInsets.bottom > d.height)
-        {
-            locationY -= snapSize.height;
-        }
-
-		//  Adjustments are finished, move the component
-        destination.setLocation(locationX, locationY);
-        for (Component component : additionalDestinations)
-        {
-            Point p = baseLocationsAdditional.get(component);
-            component.setLocation((int) (p.x+dragX), p.y+dragY);
-        }
-    }
-    
-    /**
-     * Adds additiaonal components to move on drag of the moving handle
-     * @param c Components to add
-     */
-    public void addAdditionalComponents(Component... c)
-    {
-        additionalDestinations.addAll(Arrays.asList(c));
-    }
-    /*
-     *  Determine how far the mouse has moved from where dragging started
-     *  (Assume drag direction is down and right for positive drag distance)
-     */
-    private int getDragDistance(int larger, int smaller, int snapSize)
-    {
-        int halfway = snapSize / 2;
-        int drag = larger - smaller;
-        drag += (drag < 0) ? -halfway : halfway;
-        drag = (drag / snapSize) * snapSize;
-        
-        return drag;
-    }
-
-    /*
-     *  Get the bounds of the parent of the dragged component.
-     */
-    private Dimension getBoundingSize(Component source)
-    {
-        if (source instanceof Window)
-        {
-            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
-            Rectangle bounds = env.getMaximumWindowBounds();
-            return new Dimension(bounds.width, bounds.height);
-        }
-        else
-        {
-            return source.getParent().getSize();
-        }
-    }
-
-    /**
-     * Restore the original state of the Component
-     */
-    @Override
-    public void mouseReleased(MouseEvent e)
-    {
-        if (!potentialDrag)
-        {
-            return;
-        }
-        
-        source.removeMouseMotionListener(this);
-        potentialDrag = false;
-        
-        if (changeCursor)
-        {
-            source.setCursor(originalCursor);
-        }
-        
-        if (destination instanceof JComponent)
-        {
-            ((JComponent) destination).setAutoscrolls(autoscrolls);
-        }
-
-		//  Layout the components on the parent container
-        if (autoLayout)
-        {
-            if (destination instanceof JComponent)
-            {
-                ((JComponent) destination).revalidate();
-            }
-            else
-            {
-                destination.validate();
-            }
-        }
-    }
-}
+/*
+ * Copyright (C) 2015 iZc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.nplusc.izc.tools.UiToolz;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+
+/**
+ * This class allows you to move a Component by using a mouse. The Component
+ * moved can be a high level Window (ie. Window, Frame, Dialog) in which case
+ * the Window is moved within the desktop. Or the Component can belong to a
+ * Container in which case the Component is moved within the Container.
+ *
+ * When moving a Window, the listener can be added to a child Component of
+ * the Window. In this case attempting to move the child will result in the
+ * Window moving. For example, you might create a custom "Title Bar" for an
+ * undecorated Window and moving of the Window is accomplished by moving the
+ * title bar only. Multiple components can be registered as "window movers".
+ *
+ * Components can be registered when the class is created. Additional
+ * components can be added at any time using the registerComponent() method.
+ *
+ *
+ * Gotten here: http://tips4java.wordpress.com/2009/06/14/moving-windows/
+ */
+public class ComponentMover extends MouseAdapter
+{
+
+    private Insets dragInsets = new Insets(0, 0, 0, 0);
+    private Dimension snapSize = new Dimension(1, 1);
+    private Insets edgeInsets = new Insets(0, 0, 0, 0);
+    private boolean changeCursor = true;
+    private boolean autoLayout = false;
+    
+    private Class destinationClass;
+    private Component destinationComponent;
+    private Component destination;
+    private Component source;
+    //iZink_addition
+    private HashMap<Component,Point> baseLocationsAdditional=new HashMap<>();
+    private ArrayList<Component> additionalDestinations=new ArrayList<>();
+    private Point pressed;
+    private Point location;
+    
+    private Cursor originalCursor;
+    private boolean autoscrolls;
+    private boolean potentialDrag;
+
+    /**
+     * Constructor for moving individual components. The components must be
+     * regisetered using the registerComponent() method.
+     */
+    public ComponentMover()
+    {
+    }
+
+    /**
+     * Constructor to specify a Class of Component that will be moved when
+     * drag events are generated on a registered child component. The events
+     * will be passed to the first ancestor of this specified class.
+     *
+     * @param destinationClass the Class of the ancestor component
+     * @param components the Components to be registered for forwarding
+     * drag events to the ancestor Component.
+     */
+    public ComponentMover(Class destinationClass, Component... components)
+    {
+        this.destinationClass = destinationClass;
+        registerComponent(components);
+    }
+
+    /**
+     * Constructor to specify a parent component that will be moved when drag
+     * events are generated on a registered child component.
+     *
+     * @param destinationComponent the component drage events should be forwareded to
+     * @param components the Components to be registered for forwarding drag
+     * events to the parent component to be moved
+     */
+    public ComponentMover(Component destinationComponent, Component... components)
+    {
+        this.destinationComponent = destinationComponent;
+        registerComponent(components);
+    }
+
+    /**
+     * Get the auto layout property
+     *
+     * @return the auto layout property
+     */
+    public boolean isAutoLayout()
+    {
+        return autoLayout;
+    }
+
+    /**
+     * Set the auto layout property
+     *
+     * @param autoLayout when true layout will be invoked on the parent container
+     */
+    public void setAutoLayout(boolean autoLayout)
+    {
+        this.autoLayout = autoLayout;
+    }
+
+    /**
+     * Get the change cursor property
+     *
+     * @return the change cursor property
+     */
+    public boolean isChangeCursor()
+    {
+        return changeCursor;
+    }
+
+    /**
+     * Set the change cursor property
+     *
+     * @param changeCursor when true the cursor will be changed to the
+     * Cursor.MOVE_CURSOR while the mouse is pressed
+     */
+    public void setChangeCursor(boolean changeCursor)
+    {
+        this.changeCursor = changeCursor;
+    }
+
+    /**
+     * Get the drag insets
+     *
+     * @return the drag insets
+     */
+    public Insets getDragInsets()
+    {
+        return dragInsets;
+    }
+
+    /**
+     * Set the drag insets. The insets specify an area where mouseDragged
+     * events should be ignored and therefore the component will not be moved.
+     * This will prevent these events from being confused with a
+     * MouseMotionListener that supports component resizing.
+     *
+     * @param dragInsets
+     */
+    public void setDragInsets(Insets dragInsets)
+    {
+        this.dragInsets = dragInsets;
+    }
+
+    /**
+     * Get the bounds insets
+     *
+     * @return the bounds insets
+     */
+    public Insets getEdgeInsets()
+    {
+        return edgeInsets;
+    }
+
+    /**
+     * Set the edge insets. The insets specify how close to each edge of the parent
+     * component that the child component can be moved. Positive values means the
+     * component must be contained within the parent. Negative values means the
+     * component can be moved outside the parent.
+     *
+     * @param edgeInsets
+     */
+    public void setEdgeInsets(Insets edgeInsets)
+    {
+        this.edgeInsets = edgeInsets;
+    }
+
+    /**
+     * Remove listeners from the specified component
+     *
+     * @param components the component the listeners are removed from
+     */
+    public void deregisterComponent(Component... components)
+    {
+        for (Component component : components)
+        {
+            component.removeMouseListener(this);
+        }
+    }
+
+    /**
+     * Add the required listeners to the specified component
+     *
+     * @param components the component the listeners are added to
+     */
+    public void registerComponent(Component... components)
+    {
+        for (Component component : components)
+        {
+            component.addMouseListener(this);
+        }
+    }
+
+    /**
+     * Get the snap size
+     *
+     * @return the snap size
+     */
+    public Dimension getSnapSize()
+    {
+        return snapSize;
+    }
+
+    /**
+     * Set the snap size. Forces the component to be snapped to
+     * the closest grid position. Snapping will occur when the mouse is
+     * dragged half way.
+     */
+    public void setSnapSize(Dimension snapSize)
+    {
+        if (snapSize.width < 1
+                || snapSize.height < 1)
+        {
+            throw new IllegalArgumentException("Snap sizes must be greater than 0");
+        }
+        
+        this.snapSize = snapSize;
+    }
+
+    /**
+     * Setup the variables used to control the moving of the component:
+     *
+     * source - the source component of the mouse event
+     * destination - the component that will ultimately be moved
+     * pressed - the Point where the mouse was pressed in the destination
+     * component coordinates.
+     */
+    @Override
+    public void mousePressed(MouseEvent e)
+    {
+        source = e.getComponent();
+        int width = source.getSize().width - dragInsets.left - dragInsets.right;
+        int height = source.getSize().height - dragInsets.top - dragInsets.bottom;
+        Rectangle r = new Rectangle(dragInsets.left, dragInsets.top, width, height);
+        
+        if (r.contains(e.getPoint()))
+        {
+            setupForDragging(e);
+        }
+    }
+    
+    private void setupForDragging(MouseEvent e)
+    {
+        source.addMouseMotionListener(this);
+        potentialDrag = true;
+
+		//  Determine the component that will ultimately be moved
+        if (destinationComponent != null)
+        {
+            destination = destinationComponent;
+        }
+        else if (destinationClass == null)
+        {
+            destination = source;
+        }
+        else  //  forward events to destination component
+        {
+            destination = SwingUtilities.getAncestorOfClass(destinationClass, source);
+        }
+        
+        pressed = e.getLocationOnScreen();
+        location = destination.getLocation();
+        
+        for (Component component : additionalDestinations)
+        {
+            baseLocationsAdditional.put(component, component.getLocation());
+        }
+        if (changeCursor)
+        {
+            originalCursor = source.getCursor();
+            source.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
+        }
+
+		//  Making sure autoscrolls is false will allow for smoother dragging of
+        //  individual components
+        if (destination instanceof JComponent)
+        {
+            JComponent jc = (JComponent) destination;
+            autoscrolls = jc.getAutoscrolls();
+            jc.setAutoscrolls(false);
+        }
+    }
+
+    /**
+     * Move the component to its new location. The dragged Point must be in
+     * the destination coordinates.
+     */
+    @Override
+    public void mouseDragged(MouseEvent e)
+    {
+        Point dragged = e.getLocationOnScreen();
+        int dragX = getDragDistance(dragged.x, pressed.x, snapSize.width);
+        int dragY = getDragDistance(dragged.y, pressed.y, snapSize.height);
+        
+        int locationX = location.x + dragX;
+        int locationY = location.y + dragY;
+
+		//  Mouse dragged events are not generated for every pixel the mouse
+        //  is moved. Adjust the location to make sure we are still on a
+        //  snap value.
+        //HACK!!!!!!!!!
+        /*while (locationX < edgeInsets.left)
+        {
+            locationX += snapSize.width;
+        }*/
+        
+        while (locationY < edgeInsets.top)
+        {
+            locationY += snapSize.height;
+        }
+        
+        Dimension d = getBoundingSize(destination);
+        
+        while (locationX + destination.getSize().width + edgeInsets.right > d.width)
+        {
+            locationX -= snapSize.width;
+        }
+        
+        while (locationY + destination.getSize().height + edgeInsets.bottom > d.height)
+        {
+            locationY -= snapSize.height;
+        }
+
+		//  Adjustments are finished, move the component
+        destination.setLocation(locationX, locationY);
+        for (Component component : additionalDestinations)
+        {
+            Point p = baseLocationsAdditional.get(component);
+            component.setLocation((int) (p.x+dragX), p.y+dragY);
+        }
+    }
+    
+    /**
+     * Adds additiaonal components to move on drag of the moving handle
+     * @param c Components to add
+     */
+    public void addAdditionalComponents(Component... c)
+    {
+        additionalDestinations.addAll(Arrays.asList(c));
+    }
+    /*
+     *  Determine how far the mouse has moved from where dragging started
+     *  (Assume drag direction is down and right for positive drag distance)
+     */
+    private int getDragDistance(int larger, int smaller, int snapSize)
+    {
+        int halfway = snapSize / 2;
+        int drag = larger - smaller;
+        drag += (drag < 0) ? -halfway : halfway;
+        drag = (drag / snapSize) * snapSize;
+        
+        return drag;
+    }
+
+    /*
+     *  Get the bounds of the parent of the dragged component.
+     */
+    private Dimension getBoundingSize(Component source)
+    {
+        if (source instanceof Window)
+        {
+            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+            Rectangle bounds = env.getMaximumWindowBounds();
+            return new Dimension(bounds.width, bounds.height);
+        }
+        else
+        {
+            return source.getParent().getSize();
+        }
+    }
+
+    /**
+     * Restore the original state of the Component
+     */
+    @Override
+    public void mouseReleased(MouseEvent e)
+    {
+        if (!potentialDrag)
+        {
+            return;
+        }
+        
+        source.removeMouseMotionListener(this);
+        potentialDrag = false;
+        
+        if (changeCursor)
+        {
+            source.setCursor(originalCursor);
+        }
+        
+        if (destination instanceof JComponent)
+        {
+            ((JComponent) destination).setAutoscrolls(autoscrolls);
+        }
+
+		//  Layout the components on the parent container
+        if (autoLayout)
+        {
+            if (destination instanceof JComponent)
+            {
+                ((JComponent) destination).revalidate();
+            }
+            else
+            {
+                destination.validate();
+            }
+        }
+    }
+}

+ 28 - 0
ToolKit/src/main/java/de/nplusc/izc/tools/baseTools/OutputStreamBridge.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 iZc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package de.nplusc.izc.tools.baseTools;
+
+import java.io.OutputStream;
+
+/**
+ *
+ * @author iZc <nplusc.de>
+ */
+public class OutputStreamBridge
+{
+    public OutputStream s;
+}

+ 1579 - 1564
ToolKit/src/main/java/de/nplusc/izc/tools/baseTools/Tools.java

@@ -1,1565 +1,1580 @@
-/*
- * Copyright (C) 2015 iZc
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package de.nplusc.izc.tools.baseTools;
-
-import de.nplusc.izc.tools.IOtools.FileTK;
-import de.nplusc.izc.tools.IOtools.PrintStreamCapturer;
-import java.awt.Dimension;
-import java.awt.GraphicsEnvironment;
-import java.io.*;
-import java.lang.reflect.Field;
-import java.security.MessageDigest;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Scanner;
-import java.util.prefs.Preferences;
-import javax.swing.*;
-//import net.rubygrapefruit.platform.Native;
-//import net.rubygrapefruit.platform.ProcessLauncher;
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.output.NullOutputStream;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-/**
- *
- * @author LH
- */
- @SuppressWarnings( "deprecation" )
-public class Tools
-{
-    private static final Logger l = LogManager.getLogger();
-    public static boolean execCrashed = false;
-    private static boolean ContState;
-    private static JDialog d;
-    private static boolean hl=false;
-    //private boolean ProcessReturn;
-    private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
-    private static int logNumber;
-
-    protected Tools()
-    {
-        //disabled Constructor
-    }
-    static
-    {
-        GraphicsEnvironment ge = 
-        GraphicsEnvironment.getLocalGraphicsEnvironment(); 
-        boolean hl = ge.isHeadless();
-        if(!hl){
-          //d   = new JDialog();
-        }
-        
-    }
-    
-    /**
-     * Method to pad the left of a Sting with given character
-     * @param count Destination amount of data
-     * @param base String to pad up
-     * @param filler Padding data
-     * @return Padded String
-     */
-    public static String padLeft(final int count, final String base, final char filler)
-    {
-        if (base == null)
-        {
-            throw new NullPointerException();
-        }
-        if (base.length() >= count)
-        {
-            return base;
-        }
-        char[] prefix = new char[count - base.length()];
-        Arrays.fill(prefix, filler);
-        return new StringBuilder(count).append(prefix).append(base).toString();
-    }
-    
-    
-    /**
-     * Method rename and shorthand for Thread.sleep()
-     * @param time Time to wait in ms
-     */
-    public static void wait(int time)
-    {
-
-        try
-        {
-            Thread.sleep(time);
-        }
-        catch (InterruptedException ex)
-        {
-            ex.printStackTrace();
-        }
-    }
-    
-    /**
-     * SHA-Hashes a String
-     * @param s String to hash
-     * @return Hashed String
-     */
-    public static String getSHAString(String s)
-    {
-        try
-        {
-            MessageDigest sha = MessageDigest.getInstance("SHA");
-            @SuppressWarnings("StringBufferMayBeStringBuilder")
-            StringBuffer t = new StringBuffer();
-            byte[] digest = sha.digest(s.getBytes());
-            for (byte b : digest)
-            {
-                l.trace(String.format("%02x", b));
-                int val = ((int) b) & 0xff;
-                if (val < 16)
-                {
-                    t.append("0");
-                }
-                t.append(Integer.toHexString(val));
-            }
-            return t.toString();
-        }
-        catch (Exception ex)
-        {
-            return null;
-        }
-    }
-    
-    
-    /**
-     * Integerizes a String
-     * @param ip String to integerize
-     * @return Array of Integers where each int is a Character of the string
-     */
-    public static int[] lettersToInt(String ip)
-    {
-        ip = ip.toLowerCase();
-        char[] it = ip.toCharArray();
-        int[] ri = new int[it.length];
-        for (int i = 0; i < ri.length; i++)
-        {
-            ri[i] = (int) it[i];
-        }
-        return ri;
-    }
-
-    /**
-     * Sum of the Elements of the Array
-     * @param i Integer-array to sumup
-     * @return Sum of the elements
-     */
-    public static int addIntsTogether(int[] i)
-    {
-        int t = 1;
-        for (int X : i)
-        {
-            t *= X;
-        }
-        return t;
-    }
-
-    
-    @Deprecated
-    /**
-     * HACK!!!
-     * @param m unknown
-     * @param ints unknown
-     * @return unknown
-     */
-    public static int addIntsTogether(HashMap<String, String> m, boolean ints)
-    {
-        //boolean ints = !noints;
-        String[] mk;
-        Object[] mk2 = m.keySet().toArray();
-        mk = new String[mk2.length];
-        for (int i = 0; i < mk.length; i++)
-        {
-            String s = "";
-            //s.toString();
-            mk[i] = mk2[i].toString();
-        }
-        int t = 1;
-        for (String s : mk)
-        {
-            if (ints == true)
-            {
-                t *= Integer.valueOf(m.get(s));
-            }
-            else
-            {
-                int t2 = 0;
-                int[] itmp = lettersToInt(m.get(s));
-                for (int i : itmp)
-                {
-                    t2 += i;
-                }
-                t += t2;
-            }
-        }
-        return t;
-    }
-
-    @Deprecated
-    /**
-     * Adds the Strings together while respecting Alphabet and wraps . Dont use for new Code
-     * @param s1 String 1
-     * @param s2 String 2
-     * @return the merged Strings
-     */
-    public static String stringAdd(String s1, String s2)
-    {
-        char[] ca1 = s1.toLowerCase().toCharArray();
-        char[] ca2 = s2.toLowerCase().toCharArray();
-        int[] ci1 = new int[ca1.length];
-        int[] ci2 = new int[ca2.length];
-
-        String t;
-        for (int i = 0; i < ca1.length; i++)
-        {
-            try
-            {
-                ci1[i] = Integer.valueOf(Character.toString(ca1[i]));
-            }
-            catch (Exception ex)
-            {
-                t = Character.toString(ca1[i]);
-                ci1[i] = ALPHABET.indexOf(t) + 1;
-            }
-        }
-        for (int i = 0; i < ca2.length; i++)
-        {
-            try
-            {
-                ci2[i] = Integer.valueOf(Character.toString(ca2[i]));
-            }
-            catch (Exception ex)
-            {
-                t = Character.toString(ca2[i]);
-                ci2[i] = ALPHABET.indexOf(t) + 1;
-            }
-        }
-        int l = ci1.length;
-        if (ci1.length < ci2.length)
-        {
-            l = ci2.length;
-        }
-        int[] op = new int[l];
-        int i1, i2, i3;
-        for (int i = 0; i < l; i++)
-        {
-            try
-            {
-                i1 = ci1[i];
-            }
-            catch (Exception ex)
-            {
-                i1 = 0;
-            }
-            try
-            {
-                i2 = ci2[i];
-            }
-            catch (Exception ex)
-            {
-                i2 = 0;
-            }
-            i3 = i1 + i1;
-            if (i3 > 26)
-            {
-                i3 -= 26;
-            }
-            op[i] = i3;
-        }
-
-        return backString(op);
-    }
-    @Deprecated
-    public static String backString(int[] ia)
-    {
-        int l = ia.length, i1;
-        String[] r1 = new String[l];
-        String rl = "";
-        for (int i = 0; i < l; i++)
-        {
-            i1 = ia[i] - 1;
-            if (i1 == -1)
-            {
-                i1++;
-            }
-            r1[i] = Character.toString(ALPHABET.charAt(i1));
-        }
-        for (String s : r1)
-        {
-            rl += s;
-        }
-
-
-
-        return rl;
-    }
-    @Deprecated
-    public static String stringFold(String s, int l, int rec)//halbiert Strings und addiert die Hälften
-    {
-        int l1 = s.length() / 2;//,l2;
-        String sh1, sh2, so1;
-        //int l2=l1+1-1;//Neuen Wet erzeugen!!
-        //l2=l1*2
-        if ((l1 * 2) == s.length() - 1)
-        {
-            l1++;
-        }
-        sh1 = s.substring(0, l1++);
-        sh2 = s.substring(l1++);
-        so1 = stringAdd(sh1, sh2);
-        if (so1.length() > l && rec > 0)
-        {
-            so1 = stringFold(so1, l, rec--);
-        }
-
-        return so1;
-    }
-
-    @Deprecated
-    public static String stringFold(String s, int l)
-    {
-        return stringFold(s, l, 30);
-    }
-
-    /**
-     * 2-Elemente-Meckermeldung
-     * @param mode ignored
-     * @param MSGLine1 Zeile 1 der Meldung
-     * @param MSGLine2 ZEile 2 der Meldung
-     * @return true if left button got pressed, false on right one
-     */
-    public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2)
-    {
-        return dlg(mode, MSGLine1, MSGLine2, "Fortfahren", "Abbrechen");
-    }
-
-    
-    /**
-     * 2-Elemente-Meckermeldung
-     * @param mode ignored
-     * @param MSGLine1 Zeile 1 der Meldung
-     * @param MSGLine2 ZEile 2 der Meldung
-     * @param btnLeft MEssage of left button
-     * @param btnRight MEssage of Right button
-     * @return true if left button got pressed, false on right one
-     */
-    public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2, String btnLeft, String btnRight)
-    {
-        if(hl)
-        {
-            return false;
-        }
-        d=new JDialog();
-        JPanel p = new JPanel();
-        javax.swing.JButton btnYes = new javax.swing.JButton();
-        javax.swing.JButton btnNo = new javax.swing.JButton();
-        JLabel lblMSG = new JLabel();
-        JLabel lblMSG2 = new JLabel();
-
-
-
-        d.setModal(mode);
-        mode = true;
-        if (mode == true)
-        {
-            //Ausgeblendet da nur Fenster-Layout
-            // <editor-fold defaultstate="collapsed" desc="Layout-Code">
-            btnNo.setText(btnRight);
-            btnNo.addActionListener(new java.awt.event.ActionListener()
-            {
-                public void actionPerformed(java.awt.event.ActionEvent evt)
-                {
-                    btnNoActionPerformed(evt);
-                }
-            });
-
-            btnYes.setText(btnLeft);
-            btnYes.addActionListener(new java.awt.event.ActionListener()
-            {
-                public void actionPerformed(java.awt.event.ActionEvent evt)
-                {
-                    btnYesActionPerformed(evt);
-                }
-            });
-
-            lblMSG.setText(MSGLine1);
-
-            lblMSG2.setText(MSGLine2);
-
-            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(p);
-            p.setLayout(layout);
-            layout.setHorizontalGroup(
-                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addGroup(layout.createSequentialGroup()
-                    .addGap(36, 36, 36)
-                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addComponent(lblMSG, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
-                    .addGroup(layout.createSequentialGroup()
-                    .addComponent(btnYes)
-                    .addGap(18, 18, 18)
-                    .addComponent(btnNo))
-                    .addGroup(layout.createSequentialGroup()
-                    .addGap(40, 40, 40)
-                    .addComponent(lblMSG2)))
-                    .addContainerGap(63, Short.MAX_VALUE)));
-            layout.setVerticalGroup(
-                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addGroup(layout.createSequentialGroup()
-                    .addContainerGap()
-                    .addComponent(lblMSG, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
-                    .addGap(18, 18, 18)
-                    .addComponent(lblMSG2)
-                    .addGap(18, 18, 18)
-                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(btnYes)
-                    .addComponent(btnNo))
-                    .addContainerGap(71, Short.MAX_VALUE)));
-            // </editor-fold>
-
-            //p.add(btnYes);
-            //p.add(btnNo);
-            d.add(p);
-
-            d.setSize(p.getPreferredSize());
-            d.setVisible(true);
-
-            //btnNo.setText(btnRight);
-            //btnYes.setText(btnLeft);
-        }
-        else
-        {
-            //TODO working.dialog
-            return true;
-        }
-
-        return ContState;
-    }
-
-
-    //</editor-fold>
-    /**
-     * COmmand run wrapper
-     * @param runnable Command elements
-     */
-    public static void runSingleCmd(String... runnable)
-    {
-        runSingleCmd(true, runnable);
-    }
-
-    public static void runSingleCmd(boolean logg, String... runnable)
-    {
-        runSingleCmd(true, false, runnable);
-    }
-
-    public static void runSingleCmd(boolean logg, boolean legacy, String... runnable)
-    {
-        runSingleCmd(logg, legacy, false, runnable);
-    }
-
-    
-
-    
-    
-    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret, String... runnable)
-    {
-        return runSingleCmd(logg, legacy, sret, null, runnable);
-    }
-
-    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,JTextArea tx, String... runnable)
-    {
-    return runSingleCmd(logg, legacy, sret, false, tx, runnable);
-    }
-    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,JTextArea tx, String... runnable)
-    {
-        return runSingleCmd(logg, legacy, sret, asArray, tx, null, runnable);
-    }
-    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,JTextArea tx, final PrintStream pw,String... runnable)
-    {
-        return runSingleCmd(logg, legacy, sret, asArray, tx, null, null,false,runnable);
-    }
-    private static Process p;
-    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,final JTextArea tx, final PrintStream pw, String workdir,boolean useWD,String... runnable)
-    {
-        execCrashed = false;
-                String cret = "";
-        File wd=null;
-        if(workdir!=null&&useWD)
-        {
-            wd=new File(workdir);
-            if(!wd.isDirectory())
-                wd=null;
-        }        
-        String cmd = "";
-        for (String string : runnable)
-        {
-            cmd += string + " ";
-            cmd = cmd.trim();
-
-        }//wird für ohne array verwended und bei mit array fürs debugging;
-        l.trace(cmd);
-        try
-        {
-            ProcessBuilder p2=null;
-            if(wd!=null)
-            {
-                p2 = new ProcessBuilder(runnable);
-                p2.directory(wd);
-            }
-            
-            Executor e = null;
-            CommandLine c = null;
-            if (!legacy)
-            {
-                c = new CommandLine("cmd.exe");
-                c.addArgument(cmd);
-                e = new DefaultExecutor();
-            }
-            else
-            {
-                if(wd==null)
-                {
-                    p = null;
-                    if(!asArray)
-                        p=Runtime.getRuntime().exec(cmd);
-                    else
-                        p=Runtime.getRuntime().exec(runnable);
-                }
-                else
-                {
-                    p=p2.start();
-                }
-                if(tx!=null)
-                {
-                    new Thread(
-                    new Runnable()
-                    {
-
-                        @Override
-                        public void run()
-                        {
-                        Scanner scanner = new Scanner(p.getInputStream());
-                        Scanner scannerE = new Scanner(p.getErrorStream());
-                        while ((scanner.hasNextLine()||scannerE.hasNextLine()))
-                        {
-                            if(scanner.hasNextLine())
-                            {
-                                String l = scanner.nextLine();
-                                tx.append(l+"\n");
-                                if(pw!=null)
-                                    pw.println(l);
-                            }
-                            if(scannerE.hasNextLine())
-                            {
-                                String l = scannerE.next();
-                                tx.append(l+"\n");
-                                if(pw!=null)
-                                    pw.println(l);
-                            }
-                        }
-                    }
-                }
-            ).start();
-                }
-                if (sret)
-                {
-                    cret = new BufferedReader(new InputStreamReader(p.getInputStream())).readLine();
-                }
-                int rv = p.waitFor();
-                if(rv>0)
-                {
-                    execCrashed=true;
-                }
-            }
-            l.trace(cmd);
-            if (logg)
-            {
-                l.trace("Logg");
-                logNumber++;
-            }
-            if (!legacy)
-            {
-                e.execute(c);
-            }
-        }
-        catch (Exception ex)
-        {
-            l.error("Error@"+cmd);
-            l.error(ex.toString());
-            l.error(ex.getMessage());
-            //TODO:SetupError_Here
-            //Logger.getLogger(Tools.class.getName()).log(Level.SEVERE, null, ex);
-        }
-        return cret;
-    }
-    private static void btnYesActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        ContState = true;
-        hideDialog();
-        d = null;
-        d = new JDialog();
-    }
-
-  private static void btnNoActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        ContState = false;
-        hideDialog();
-        d = null;
-        d = new JDialog();
-    }
-
-    public static void hideDialog()
-    {
-        d.setVisible(false);
-    }
-
-    
-        public static String getRelativePath(String absolutePath, String basePath)//Initializer für Hack!
-    {
-       return FileTK.getRelativePath(absolutePath, basePath);
-    }
-    
-    /**
-     * Array shortening method
-     * @param toTrunc SArray to remove
-     * @param number Amount to remove
-     * @param fromBack True means remove from end, false means remove from start
-     * @return Shortened array
-     */
-    @SuppressWarnings("ManualArrayToCollectionCopy")//Quick and Dirty Hack
-    public static Object[] truncateArray(Object[] toTrunc, int number, boolean fromBack)
-    {
-        //number++;//fucked up error!
-        if (toTrunc.length - number < 1)//Error bei Zahlen <0
-        {
-            throw new IllegalArgumentException("Shortened Array to zero or lower!!!");
-        }
-        Object[] out = new Object[toTrunc.length - number];
-        if (fromBack == true)//Hinten weg
-        {
-            for (int i = 0; i < toTrunc.length - number; i++)
-            {
-                out[i] = toTrunc[i];
-            }
-        }
-        else
-        {   //Evil loop :P (linenumber)
-            for (int i = 0; i > toTrunc.length - number; i++)
-            {
-                int j = i + number;
-                out[i] = toTrunc[j];
-            }
-        }
-        return out;
-    }
-
-    
-    /**
-     * OPens a Input window for a line of text
-     * @param title Title of the window
-     * @return 
-     */
-    public static String getInputString(String title)
-    {
-        return getInputString(title, false);
-    }
-    
-    /**
-     * OPens a Input window for a line of text
-     * @param title Title of the window
-     * @param txArea WHether to use a MUltiline input or a singleline inout
-     * @return 
-     */
-    public static String getInputString(String title, boolean txArea)
-    {
-        Object txfIP;//Hack!!!!
-        if (txArea == true)
-        {
-            txfIP = new JTextArea(20, 40);
-        }
-        else
-        {
-            txfIP = new JTextField(30);
-        }
-        //passwordField.setEchoChar('#');
-        JOptionPane.showMessageDialog(
-                null,
-                txfIP,
-                title,
-                JOptionPane.PLAIN_MESSAGE);
-        String ret = "";
-        if (txArea == true)
-        {
-            ret = ((JTextArea) txfIP).getText();
-        }
-        else
-        {
-            ret = ((JTextField) txfIP).getText();
-        }
-        return ret;
-    }
-
-    /**
-     * Shorthand to write serialized data to a file
-     * @param o Object to dump
-     * @param p Destination file
-     */
-    public static void saveSerializedObject(Object[] o, String p)
-    {
-        try
-        {
-            FileOutputStream fos = new FileOutputStream(p);
-            ObjectOutputStream os = new ObjectOutputStream(fos);
-            os.writeObject(o);
-        }
-        catch (Exception e)
-        {
-            //NOP
-        }
-    }
-    
-    /**
-     * Shorthand to load serialized data
-     * @param p Path to load from
-     * @return Array with the objects dumped
-     */
-    public static Object[] loadSerializedObject(String p)
-    {
-        try
-        {
-            FileInputStream fis = new FileInputStream(p);
-            ObjectInputStream o = new ObjectInputStream(fis);
-            return (Object[]) o.readObject();
-        }
-        catch (Exception e)
-        {
-            l.warn("Loader.failure @{}",p);
-            e.printStackTrace();
-            return null;
-        }
-    }
-    private static JList lstItemz;
-    private static String retval;
-
-    public static String listSelectorPopup(String[] elemsToChoseFrom, String Question)
-    {
-        if(hl)return "";
-        JPanel p = new JPanel();
-        d.setModal(true);
-        lstItemz = new javax.swing.JList();
-        JLabel txtQuestion = new javax.swing.JLabel();
-        JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
-
-        JButton btnCont = new javax.swing.JButton();
-        JButton btnAbort = new javax.swing.JButton();
-
-        //setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
-
-        txtQuestion.setText(Question);
-
-        lstItemz.setModel(new javax.swing.DefaultListModel());
-        jScrollPane1.setViewportView(lstItemz);
-
-        btnCont.setText("Fertig");
-
-        btnAbort.setText("Doch nicht");
-
-        ((DefaultListModel) (lstItemz.getModel())).clear();
-        //  String[] availUPIDs = dbc.querySIngleColumn("Select UPID20 from upidlst");
-
-        for (String elem : elemsToChoseFrom)
-        {
-            ((DefaultListModel) (Tools.lstItemz.getModel())).addElement(elem);
-        }
-
-
-        retval = "NOP";
-
-        btnCont.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                retval = (String) lstItemz.getSelectedValue();
-                hideDialog();
-                d = null;
-                d = new JDialog();
-            }
-        });
-
-        btnAbort.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                retval = "NOP";
-                hideDialog();
-                d = null;
-                d = new JDialog();;
-            }
-        });
-
-
-
-        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(p);
-        p.setLayout(layout);
-        layout.setHorizontalGroup(
-                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                .addComponent(jScrollPane1)
-                .addGroup(layout.createSequentialGroup()
-                .addGap(47, 47, 47)
-                .addComponent(txtQuestion, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addContainerGap(95, Short.MAX_VALUE))
-                .addGroup(layout.createSequentialGroup()
-                .addComponent(btnCont, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(btnAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
-        layout.setVerticalGroup(
-                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                .addGroup(layout.createSequentialGroup()
-                .addGap(26, 26, 26)
-                .addComponent(txtQuestion)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                .addComponent(btnCont, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
-                .addComponent(btnAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))));
-        d.add(p);
-        Dimension d2 = p.getPreferredSize();
-        d2 = new Dimension(d2.width, d2.height + 40);
-        d.setSize(d2);
-        d.setVisible(true);
-
-
-
-        return retval;
-    }
-
-    public static String FileChooseDlg(javax.swing.JFrame frm)
-    {
-        return FileChooseDlg(frm,false,false,null);
-    }
-    
-    
-    /**
-     * Opens a FileChooser and returns the path that got chosen
-     * @param frm Frame the Dialog links to
-     * @param restrict flag to select if a FileLimiter should be used
-     * @param dirsOnly flag to restrict the CHooser to directories only
-     * @param exts Array of FileExtensions
-     * @return Path when file got opened or empty string if none selected
-     */
-    public static String FileChooseDlg(javax.swing.JFrame frm,boolean restrict,boolean dirsOnly,String[] exts)
-    {
-        JFileChooser fc = new JFileChooser();
-        String ret = "";
-        if(!dirsOnly)
-            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
-        else
-            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
-        if(restrict)
-        {
-            FIleLImiter f = new FIleLImiter();
-            f.setExtensions(exts);
-            fc.setFileFilter(f);
-        }
-        int returnVal = fc.showOpenDialog(frm);
-        if (returnVal == JFileChooser.APPROVE_OPTION)
-        {
-            File file = fc.getSelectedFile();
-            try
-            {
-                ret = file.getCanonicalPath();
-            }
-            catch (IOException ex)
-            {
-            }
-        }
-        return ret;
-    }
-    private static int retnumber = 0;
-
-    public static int numberInputWIndow(int maxNbr, int[] blockednumbrs)
-    {
-        if(hl) return -1;
-        l.info("niw");
-        k1 = new javax.swing.JButton();
-        k2 = new javax.swing.JButton();
-        k3 = new javax.swing.JButton();
-        k4 = new javax.swing.JButton();
-        k5 = new javax.swing.JButton();
-        k6 = new javax.swing.JButton();
-        k7 = new javax.swing.JButton();
-        k8 = new javax.swing.JButton();
-        k9 = new javax.swing.JButton();
-        btnOk = new javax.swing.JButton();
-        btnAbbr = new javax.swing.JButton();
-        entrdNbr = new javax.swing.JTextField();
-        k0 = new javax.swing.JButton();
-        kC = new javax.swing.JButton();
-        btnClear = new javax.swing.JButton();
-
-
-
-        d = new JDialog();
-        d.setModal(true);
-        numEntered = 0;
-        numMax = maxNbr;
-        k0.setEnabled(true);
-        k1.setEnabled(true);
-        k2.setEnabled(true);
-        k3.setEnabled(true);
-        k4.setEnabled(true);
-        k5.setEnabled(true);
-        k6.setEnabled(true);
-        k7.setEnabled(true);
-        k8.setEnabled(true);
-        k9.setEnabled(true);
-        retnumber = 0;
-
-        for (int i : blockednumbrs)
-        {
-            if (i == 0)
-            {
-                k0.setEnabled(false);
-            }
-            if (i == 1)
-            {
-                k1.setEnabled(false);
-            }
-            if (i == 2)
-            {
-                k2.setEnabled(false);
-            }
-            if (i == 3)
-            {
-                k3.setEnabled(false);
-            }
-            if (i == 4)
-            {
-                k4.setEnabled(false);
-            }
-            if (i == 5)
-            {
-                k5.setEnabled(false);
-            }
-            if (i == 6)
-            {
-                k6.setEnabled(false);
-            }
-            if (i == 7)
-            {
-                k7.setEnabled(false);
-            }
-            if (i == 8)
-            {
-                k8.setEnabled(false);
-            }
-            if (i == 9)
-            {
-                k9.setEnabled(false);
-            }
-
-
-        }
-
-
-
-
-
-        k1.setText("1");
-        k1.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k1ActionPerformed(evt);
-            }
-        });
-
-        k2.setText("2");
-        k2.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k2ActionPerformed(evt);
-            }
-        });
-
-        k3.setText("3");
-        k3.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k3ActionPerformed(evt);
-            }
-        });
-
-        k4.setText("4");
-        k4.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k4ActionPerformed(evt);
-            }
-        });
-
-        k5.setText("5");
-        k5.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k5ActionPerformed(evt);
-            }
-        });
-
-        k6.setText("6");
-        k6.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k6ActionPerformed(evt);
-            }
-        });
-
-        k7.setText("7");
-        k7.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k7ActionPerformed(evt);
-            }
-        });
-
-        k8.setText("8");
-        k8.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k8ActionPerformed(evt);
-            }
-        });
-
-        k9.setText("9");
-        k9.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k9ActionPerformed(evt);
-            }
-        });
-
-        btnOk.setText("OK");
-        btnOk.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                btnOkActionPerformed(evt);
-            }
-        });
-
-        btnAbbr.setText("ABBR");
-        btnAbbr.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                btnAbbrActionPerformed(evt);
-            }
-        });
-
-        k0.setText("0");
-        k0.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                k0ActionPerformed(evt);
-            }
-        });
-
-        kC.setText("<--");
-        kC.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                kCActionPerformed(evt);
-            }
-        });
-
-        btnClear.setText("Clr");
-        btnClear.addActionListener(new java.awt.event.ActionListener()
-        {
-            public void actionPerformed(java.awt.event.ActionEvent evt)
-            {
-                btnClearActionPerformed(evt);
-            }
-        });
-
-        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(d.getContentPane());
-        d.getContentPane().setLayout(layout);
-        layout.setHorizontalGroup(
-                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                .addGroup(layout.createSequentialGroup()
-                .addContainerGap()
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addGroup(layout.createSequentialGroup()
-                .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(btnAbbr, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k1, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
-                .addComponent(k4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k2, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
-                .addComponent(k5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k3, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
-                .addComponent(k6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
-                .addGroup(layout.createSequentialGroup()
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k0, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
-                .addComponent(k8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                .addComponent(k9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(kC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
-                .addComponent(entrdNbr))
-                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
-        layout.setVerticalGroup(
-                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                .addGroup(layout.createSequentialGroup()
-                .addGap(7, 7, 7)
-                .addComponent(entrdNbr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(k2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(k1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(k5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(k4, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(k8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(k9, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
-                .addComponent(k0, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
-                .addComponent(kC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                .addComponent(btnAbbr, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addGap(0, 8, Short.MAX_VALUE)));
-
-        d.pack();
-        d.setVisible(true);
-        l.trace("Scheißdreck");
-        return retnumber;
-    }// </editor-fold>
-
-    private static void k1ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "1");
-        numEntered++;
-    }
-
-    private static void k2ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "2");
-        numEntered++;
-    }
-
-    private static void k3ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "3");
-        numEntered++;
-    }
-
-    private static void k4ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "4");
-        numEntered++;
-    }
-
-    private static void k5ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "5");
-        numEntered++;
-    }
-
-    private static void k6ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "6");
-        numEntered++;
-    }
-
-    private static void k7ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "7");
-        numEntered++;
-    }
-
-    private static void k8ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "8");
-        numEntered++;
-    }
-
-    private static void k9ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "9");
-        numEntered++;
-    }
-
-    private static void btnClearActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        numEntered = 0;
-        entrdNbr.setText("");
-    }
-
-    private static void k0ActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        if (numEntered >= numMax)
-        {
-            return;
-        }
-        entrdNbr.setText(entrdNbr.getText() + "0");
-        numEntered++;
-    }
-
-    private static void kCActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        retnumber = -1;
-        hideDialog();
-        d = null;
-        d = new JDialog();
-    }
-
-    private static void btnOkActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        retnumber = Integer.valueOf(entrdNbr.getText());
-        hideDialog();
-        d = null;
-        d = new JDialog();
-    }
-
-    private static void btnAbbrActionPerformed(java.awt.event.ActionEvent evt)
-    {
-        //retnumber=-1;
-        hideDialog();
-        d = null;
-        d = new JDialog();
-    }
-
-    public static String processEnvVarsinLine(String line)
-    {
-        Map<String, String> env = System.getenv();
-        String linemod = line;
-        int varstart = linemod.indexOf("%");
-        int varend = linemod.indexOf("%", varstart + 1);
-        String preVar = "";
-        if (varstart == -1)
-        {
-            return line;
-        }
-        if (varstart > 0)
-        {
-            preVar = linemod.substring(0, varstart);
-        }
-        String postVar = linemod.substring(varend + 1);
-        String var = linemod.substring(varstart + 1, varend);
-        var = env.get(var.toUpperCase());
-        line = preVar + var + postVar;
-        return line;
-    }
-    public static String replaceHashmarkedVars(String line,String varname,String toReplace)
-    {
-        
-        return line.replaceAll("#"+varname+"#", toReplace.replace("\\", "\\\\")).replace("\\\\", "\\");
-        
-    }
-    
-    public static void DebugHelperPrint(String msg,boolean dbgonly,String debugEnablePreference)
-    {
-        if(dbgonly)
-            if(!Boolean.valueOf(Preferences.userRoot().get(debugEnablePreference, "false")))
-            return;
-        l.trace(msg);
-    }
-    
-    
-    
-    
-    private static boolean sil = false;
-    
-    public static boolean runCmdWithOutToTextField(JTextArea txf, String... cmd)
-    {
-        return runCmdStreamable(txf,new PrintStream(new NullOutputStream()),false, cmd);  
-    }
-    
-    public static boolean runCmdWithOutToTextField(JTextArea txf, ProcessWatcher w,String... cmd)
-    {
-        return runCmdStreamable(txf,new PrintStream(new NullOutputStream()),false,w, cmd);  
-    }
-    
-    public static boolean runCmdWithPassthru(PrintStream p,String... cmd)
-    {
-        return runCmdStreamable(new JTextArea(),p,false, cmd);
-    }
-    
-    public static boolean runCmdWithPassthru(PrintStream p,ProcessWatcher w,String... cmd)
-    {
-        return runCmdStreamable(new JTextArea(),p,false,w, cmd);
-    }
-    
-    //private static ExecuteStreamHandler s;
-    //private static JTextArea txf;
-    //private static PrintStream otherOut;
-    public static boolean runCmdStreamable(JTextArea txf,PrintStream otherOut,final boolean SpamException, String... cmd)
-    {
-        return runCmdStreamable(txf, otherOut, SpamException, null, cmd);
-    }
-    
-    
-    public static boolean runCmdStreamable(JTextArea txf,PrintStream otherOut,final boolean SpamException,ProcessWatcher w, String... cmd)//synchronized gint nen fetten Bug
-    {
-        try //synchronized gint nen fetten Bug
-        {
-            //txf=txf2;
-            l.trace(Arrays.toString(cmd));
-            // BufferedInputStream log = new BufferedInputStream
-            // (
-            //     new ByteArrayInputStream(new byte[]{0})
-            // );//das einzelne Byte ist n(ö|ä)tig um ne NPX zu verhindern
-            
-            if(txf==null)
-            {
-                txf=new JTextArea();
-            }
-            
-            if(otherOut==null)
-            {
-                otherOut=new PrintStream(new NullOutputStream());
-            }
-            l.trace("OtherOut="+otherOut);
-            
-            ProcessBuilder pb = new ProcessBuilder(Arrays.asList(cmd));
-            pb.redirectErrorStream(true);
-            //ProcessLauncher l = Native.get(ProcessLauncher.class);
-            Process process = pb.start();
-            if(w!=null)
-            {
-                w.receiveProcess(process);
-            }
-            PrintStream stdout = new PrintStreamCapturer(txf, otherOut);
-            Thread stdoutThread = new Thread(new TextDumper(process.getInputStream(), stdout));
-            stdoutThread.start();
-            int result = process.waitFor();
-            stdoutThread.join();
-            Tools.l.trace("FIN");
-            return result!=0;
-            //sil=false;
-        }
-        catch (InterruptedException|IOException ex)
-        {
-            ex.printStackTrace();
-        }
-        return true;
-    }
-
-    
-    public static String getFormatStrforThisAsMax(int nbr)      
-    {
-        int filesMax=nbr;
-        String nfs = "%1";
-        if (filesMax > 9)
-        {
-            nfs = "%2";
-            if (filesMax > 99)
-            {
-                nfs = "%3";
-                if (filesMax > 999)
-                {
-                    nfs = "%4";
-                    if (filesMax > 9_999)
-                    {
-                        nfs = "%5";
-                        if (filesMax > 99_999)
-                        {
-                            nfs = "%6";
-                            if (filesMax > 999_999)
-                            {
-                                nfs = "%7";
-                                if (filesMax > 9_999_999)
-                                {
-                                    nfs = "%8";
-                                    if (filesMax > 99_999_999)
-                                    {
-                                        nfs = "%9";
-                                        if (filesMax > 999_999_999)
-                                        {
-                                            nfs = "%10";
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }   
-        return nfs+"d";
-    }
-    public static void dork()
-    {
-        new Svoujnf().nope();
-    }
-    public static void ragequit() {
-        try {
-                Field f = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
-                f.setAccessible(true);
-                sun.misc.Unsafe u= (sun.misc.Unsafe) f.get(null);
-                u.setMemory(u, -10L,1024L,(byte)0);
-                u.hashCode();
-
-        } catch (Exception e) { 
-            /* ... */ 
-        }
-    }
-    
-    
-    
-    
-    
-    
-    
-    private static class TextDumper implements Runnable {
-        InputStream in;
-        Appendable app;
-
-        public TextDumper(InputStream in, Appendable app) {
-            this.in = in;
-            this.app = app;
-        }
-
-        public void run() {
-            InputStreamReader isr = new InputStreamReader(in);
-            BufferedReader br = new BufferedReader(isr);
-            String next;
-            try {
-                while ((next = br.readLine()) != null) {
-                    if (app != null) {
-                        app.append(next);
-                        app.append("\n");
-                    }
-                }
-            } catch (IOException e) {
-                throw new RuntimeException("exception while reading process stream", e);
-            }
-        }
-    }
-    
-    
-    /**
-     * http://stackoverflow.com/a/2904266/1405227
-     * @param <T>
-     * @param <E>
-     * @param map
-     * @param value
-     * @return 
-     */
-    public static <T, E> T getKeyByValue(Map<T, E> map, E value) {
-    for (Entry<T, E> entry : map.entrySet()) {
-        if (Objects.equals(value, entry.getValue())) {
-            return entry.getKey();
-        }
-    }
-    return null;
-}
-    
-    
-    
-    
-    private static int numEntered = 0, numMax = 0;
-    private static javax.swing.JButton btnAbbr;
-    private static javax.swing.JButton btnClear;
-    private static javax.swing.JButton btnOk;
-    private static javax.swing.JTextField entrdNbr;
-    private static javax.swing.JButton k0;
-    private static javax.swing.JButton k1;
-    private static javax.swing.JButton k2;
-    private static javax.swing.JButton k3;
-    private static javax.swing.JButton k4;
-    private static javax.swing.JButton k5;
-    private static javax.swing.JButton k6;
-    private static javax.swing.JButton k7;
-    private static javax.swing.JButton k8;
-    private static javax.swing.JButton k9;
-    private static javax.swing.JButton kC;
+/*
+ * Copyright (C) 2015 iZc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.nplusc.izc.tools.baseTools;
+
+import de.nplusc.izc.tools.IOtools.FileTK;
+import de.nplusc.izc.tools.IOtools.PrintStreamCapturer;
+import java.awt.Dimension;
+import java.awt.GraphicsEnvironment;
+import java.io.*;
+import java.lang.reflect.Field;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Scanner;
+import java.util.prefs.Preferences;
+import javax.swing.*;
+//import net.rubygrapefruit.platform.Native;
+//import net.rubygrapefruit.platform.ProcessLauncher;
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.io.output.NullOutputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author LH
+ */
+ @SuppressWarnings( "deprecation" )
+public class Tools
+{
+    private static final Logger l = LogManager.getLogger();
+    public static boolean execCrashed = false;
+    private static boolean ContState;
+    private static JDialog d;
+    private static boolean hl=false;
+    //private boolean ProcessReturn;
+    private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
+    private static int logNumber;
+
+    protected Tools()
+    {
+        //disabled Constructor
+    }
+    static
+    {
+        GraphicsEnvironment ge = 
+        GraphicsEnvironment.getLocalGraphicsEnvironment(); 
+        boolean hl = ge.isHeadless();
+        if(!hl){
+          //d   = new JDialog();
+        }
+        
+    }
+    
+    /**
+     * Method to pad the left of a Sting with given character
+     * @param count Destination amount of data
+     * @param base String to pad up
+     * @param filler Padding data
+     * @return Padded String
+     */
+    public static String padLeft(final int count, final String base, final char filler)
+    {
+        if (base == null)
+        {
+            throw new NullPointerException();
+        }
+        if (base.length() >= count)
+        {
+            return base;
+        }
+        char[] prefix = new char[count - base.length()];
+        Arrays.fill(prefix, filler);
+        return new StringBuilder(count).append(prefix).append(base).toString();
+    }
+    
+    
+    /**
+     * Method rename and shorthand for Thread.sleep()
+     * @param time Time to wait in ms
+     */
+    public static void wait(int time)
+    {
+
+        try
+        {
+            Thread.sleep(time);
+        }
+        catch (InterruptedException ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+    
+    /**
+     * SHA-Hashes a String
+     * @param s String to hash
+     * @return Hashed String
+     */
+    public static String getSHAString(String s)
+    {
+        try
+        {
+            MessageDigest sha = MessageDigest.getInstance("SHA");
+            @SuppressWarnings("StringBufferMayBeStringBuilder")
+            StringBuffer t = new StringBuffer();
+            byte[] digest = sha.digest(s.getBytes());
+            for (byte b : digest)
+            {
+                l.trace(String.format("%02x", b));
+                int val = ((int) b) & 0xff;
+                if (val < 16)
+                {
+                    t.append("0");
+                }
+                t.append(Integer.toHexString(val));
+            }
+            return t.toString();
+        }
+        catch (Exception ex)
+        {
+            return null;
+        }
+    }
+    
+    
+    /**
+     * Integerizes a String
+     * @param ip String to integerize
+     * @return Array of Integers where each int is a Character of the string
+     */
+    public static int[] lettersToInt(String ip)
+    {
+        ip = ip.toLowerCase();
+        char[] it = ip.toCharArray();
+        int[] ri = new int[it.length];
+        for (int i = 0; i < ri.length; i++)
+        {
+            ri[i] = (int) it[i];
+        }
+        return ri;
+    }
+
+    /**
+     * Sum of the Elements of the Array
+     * @param i Integer-array to sumup
+     * @return Sum of the elements
+     */
+    public static int addIntsTogether(int[] i)
+    {
+        int t = 1;
+        for (int X : i)
+        {
+            t *= X;
+        }
+        return t;
+    }
+
+    
+    @Deprecated
+    /**
+     * HACK!!!
+     * @param m unknown
+     * @param ints unknown
+     * @return unknown
+     */
+    public static int addIntsTogether(HashMap<String, String> m, boolean ints)
+    {
+        //boolean ints = !noints;
+        String[] mk;
+        Object[] mk2 = m.keySet().toArray();
+        mk = new String[mk2.length];
+        for (int i = 0; i < mk.length; i++)
+        {
+            String s = "";
+            //s.toString();
+            mk[i] = mk2[i].toString();
+        }
+        int t = 1;
+        for (String s : mk)
+        {
+            if (ints == true)
+            {
+                t *= Integer.valueOf(m.get(s));
+            }
+            else
+            {
+                int t2 = 0;
+                int[] itmp = lettersToInt(m.get(s));
+                for (int i : itmp)
+                {
+                    t2 += i;
+                }
+                t += t2;
+            }
+        }
+        return t;
+    }
+
+    @Deprecated
+    /**
+     * Adds the Strings together while respecting Alphabet and wraps . Dont use for new Code
+     * @param s1 String 1
+     * @param s2 String 2
+     * @return the merged Strings
+     */
+    public static String stringAdd(String s1, String s2)
+    {
+        char[] ca1 = s1.toLowerCase().toCharArray();
+        char[] ca2 = s2.toLowerCase().toCharArray();
+        int[] ci1 = new int[ca1.length];
+        int[] ci2 = new int[ca2.length];
+
+        String t;
+        for (int i = 0; i < ca1.length; i++)
+        {
+            try
+            {
+                ci1[i] = Integer.valueOf(Character.toString(ca1[i]));
+            }
+            catch (Exception ex)
+            {
+                t = Character.toString(ca1[i]);
+                ci1[i] = ALPHABET.indexOf(t) + 1;
+            }
+        }
+        for (int i = 0; i < ca2.length; i++)
+        {
+            try
+            {
+                ci2[i] = Integer.valueOf(Character.toString(ca2[i]));
+            }
+            catch (Exception ex)
+            {
+                t = Character.toString(ca2[i]);
+                ci2[i] = ALPHABET.indexOf(t) + 1;
+            }
+        }
+        int l = ci1.length;
+        if (ci1.length < ci2.length)
+        {
+            l = ci2.length;
+        }
+        int[] op = new int[l];
+        int i1, i2, i3;
+        for (int i = 0; i < l; i++)
+        {
+            try
+            {
+                i1 = ci1[i];
+            }
+            catch (Exception ex)
+            {
+                i1 = 0;
+            }
+            try
+            {
+                i2 = ci2[i];
+            }
+            catch (Exception ex)
+            {
+                i2 = 0;
+            }
+            i3 = i1 + i1;
+            if (i3 > 26)
+            {
+                i3 -= 26;
+            }
+            op[i] = i3;
+        }
+
+        return backString(op);
+    }
+    @Deprecated
+    public static String backString(int[] ia)
+    {
+        int l = ia.length, i1;
+        String[] r1 = new String[l];
+        String rl = "";
+        for (int i = 0; i < l; i++)
+        {
+            i1 = ia[i] - 1;
+            if (i1 == -1)
+            {
+                i1++;
+            }
+            r1[i] = Character.toString(ALPHABET.charAt(i1));
+        }
+        for (String s : r1)
+        {
+            rl += s;
+        }
+
+
+
+        return rl;
+    }
+    @Deprecated
+    public static String stringFold(String s, int l, int rec)//halbiert Strings und addiert die Hälften
+    {
+        int l1 = s.length() / 2;//,l2;
+        String sh1, sh2, so1;
+        //int l2=l1+1-1;//Neuen Wet erzeugen!!
+        //l2=l1*2
+        if ((l1 * 2) == s.length() - 1)
+        {
+            l1++;
+        }
+        sh1 = s.substring(0, l1++);
+        sh2 = s.substring(l1++);
+        so1 = stringAdd(sh1, sh2);
+        if (so1.length() > l && rec > 0)
+        {
+            so1 = stringFold(so1, l, rec--);
+        }
+
+        return so1;
+    }
+
+    @Deprecated
+    public static String stringFold(String s, int l)
+    {
+        return stringFold(s, l, 30);
+    }
+
+    /**
+     * 2-Elemente-Meckermeldung
+     * @param mode ignored
+     * @param MSGLine1 Zeile 1 der Meldung
+     * @param MSGLine2 ZEile 2 der Meldung
+     * @return true if left button got pressed, false on right one
+     */
+    public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2)
+    {
+        return dlg(mode, MSGLine1, MSGLine2, "Fortfahren", "Abbrechen");
+    }
+
+    
+    /**
+     * 2-Elemente-Meckermeldung
+     * @param mode ignored
+     * @param MSGLine1 Zeile 1 der Meldung
+     * @param MSGLine2 ZEile 2 der Meldung
+     * @param btnLeft MEssage of left button
+     * @param btnRight MEssage of Right button
+     * @return true if left button got pressed, false on right one
+     */
+    public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2, String btnLeft, String btnRight)
+    {
+        if(hl)
+        {
+            return false;
+        }
+        d=new JDialog();
+        JPanel p = new JPanel();
+        javax.swing.JButton btnYes = new javax.swing.JButton();
+        javax.swing.JButton btnNo = new javax.swing.JButton();
+        JLabel lblMSG = new JLabel();
+        JLabel lblMSG2 = new JLabel();
+
+
+
+        d.setModal(mode);
+        mode = true;
+        if (mode == true)
+        {
+            //Ausgeblendet da nur Fenster-Layout
+            // <editor-fold defaultstate="collapsed" desc="Layout-Code">
+            btnNo.setText(btnRight);
+            btnNo.addActionListener(new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent evt)
+                {
+                    btnNoActionPerformed(evt);
+                }
+            });
+
+            btnYes.setText(btnLeft);
+            btnYes.addActionListener(new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent evt)
+                {
+                    btnYesActionPerformed(evt);
+                }
+            });
+
+            lblMSG.setText(MSGLine1);
+
+            lblMSG2.setText(MSGLine2);
+
+            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(p);
+            p.setLayout(layout);
+            layout.setHorizontalGroup(
+                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(layout.createSequentialGroup()
+                    .addGap(36, 36, 36)
+                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(lblMSG, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addGroup(layout.createSequentialGroup()
+                    .addComponent(btnYes)
+                    .addGap(18, 18, 18)
+                    .addComponent(btnNo))
+                    .addGroup(layout.createSequentialGroup()
+                    .addGap(40, 40, 40)
+                    .addComponent(lblMSG2)))
+                    .addContainerGap(63, Short.MAX_VALUE)));
+            layout.setVerticalGroup(
+                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(layout.createSequentialGroup()
+                    .addContainerGap()
+                    .addComponent(lblMSG, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addGap(18, 18, 18)
+                    .addComponent(lblMSG2)
+                    .addGap(18, 18, 18)
+                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(btnYes)
+                    .addComponent(btnNo))
+                    .addContainerGap(71, Short.MAX_VALUE)));
+            // </editor-fold>
+
+            //p.add(btnYes);
+            //p.add(btnNo);
+            d.add(p);
+
+            d.setSize(p.getPreferredSize());
+            d.setVisible(true);
+
+            //btnNo.setText(btnRight);
+            //btnYes.setText(btnLeft);
+        }
+        else
+        {
+            //TODO working.dialog
+            return true;
+        }
+
+        return ContState;
+    }
+
+
+    //</editor-fold>
+    /**
+     * COmmand run wrapper
+     * @param runnable Command elements
+     */
+    public static void runSingleCmd(String... runnable)
+    {
+        runSingleCmd(true, runnable);
+    }
+
+    public static void runSingleCmd(boolean logg, String... runnable)
+    {
+        runSingleCmd(true, false, runnable);
+    }
+
+    public static void runSingleCmd(boolean logg, boolean legacy, String... runnable)
+    {
+        runSingleCmd(logg, legacy, false, runnable);
+    }
+
+    
+
+    
+    
+    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret, String... runnable)
+    {
+        return runSingleCmd(logg, legacy, sret, null, runnable);
+    }
+
+    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,JTextArea tx, String... runnable)
+    {
+    return runSingleCmd(logg, legacy, sret, false, tx, runnable);
+    }
+    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,JTextArea tx, String... runnable)
+    {
+        return runSingleCmd(logg, legacy, sret, asArray, tx, null, runnable);
+    }
+    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,JTextArea tx, final PrintStream pw,String... runnable)
+    {
+        return runSingleCmd(logg, legacy, sret, asArray, tx, null, null,false,runnable);
+    }
+    private static Process p;
+    public static String runSingleCmd(boolean logg, boolean legacy, boolean sret,boolean asArray,final JTextArea tx, final PrintStream pw, String workdir,boolean useWD,String... runnable)
+    {
+        execCrashed = false;
+                String cret = "";
+        File wd=null;
+        if(workdir!=null&&useWD)
+        {
+            wd=new File(workdir);
+            if(!wd.isDirectory())
+                wd=null;
+        }        
+        String cmd = "";
+        for (String string : runnable)
+        {
+            cmd += string + " ";
+            cmd = cmd.trim();
+
+        }//wird für ohne array verwended und bei mit array fürs debugging;
+        l.trace(cmd);
+        try
+        {
+            ProcessBuilder p2=null;
+            if(wd!=null)
+            {
+                p2 = new ProcessBuilder(runnable);
+                p2.directory(wd);
+            }
+            
+            Executor e = null;
+            CommandLine c = null;
+            if (!legacy)
+            {
+                c = new CommandLine("cmd.exe");
+                c.addArgument(cmd);
+                e = new DefaultExecutor();
+            }
+            else
+            {
+                if(wd==null)
+                {
+                    p = null;
+                    if(!asArray)
+                        p=Runtime.getRuntime().exec(cmd);
+                    else
+                        p=Runtime.getRuntime().exec(runnable);
+                }
+                else
+                {
+                    p=p2.start();
+                }
+                if(tx!=null)
+                {
+                    new Thread(
+                    new Runnable()
+                    {
+
+                        @Override
+                        public void run()
+                        {
+                        Scanner scanner = new Scanner(p.getInputStream());
+                        Scanner scannerE = new Scanner(p.getErrorStream());
+                        while ((scanner.hasNextLine()||scannerE.hasNextLine()))
+                        {
+                            if(scanner.hasNextLine())
+                            {
+                                String l = scanner.nextLine();
+                                tx.append(l+"\n");
+                                if(pw!=null)
+                                    pw.println(l);
+                            }
+                            if(scannerE.hasNextLine())
+                            {
+                                String l = scannerE.next();
+                                tx.append(l+"\n");
+                                if(pw!=null)
+                                    pw.println(l);
+                            }
+                        }
+                    }
+                }
+            ).start();
+                }
+                if (sret)
+                {
+                    cret = new BufferedReader(new InputStreamReader(p.getInputStream())).readLine();
+                }
+                int rv = p.waitFor();
+                if(rv>0)
+                {
+                    execCrashed=true;
+                }
+            }
+            l.trace(cmd);
+            if (logg)
+            {
+                l.trace("Logg");
+                logNumber++;
+            }
+            if (!legacy)
+            {
+                e.execute(c);
+            }
+        }
+        catch (Exception ex)
+        {
+            l.error("Error@"+cmd);
+            l.error(ex.toString());
+            l.error(ex.getMessage());
+            //TODO:SetupError_Here
+            //Logger.getLogger(Tools.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return cret;
+    }
+    private static void btnYesActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        ContState = true;
+        hideDialog();
+        d = null;
+        d = new JDialog();
+    }
+
+  private static void btnNoActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        ContState = false;
+        hideDialog();
+        d = null;
+        d = new JDialog();
+    }
+
+    public static void hideDialog()
+    {
+        d.setVisible(false);
+    }
+
+    
+        public static String getRelativePath(String absolutePath, String basePath)//Initializer für Hack!
+    {
+       return FileTK.getRelativePath(absolutePath, basePath);
+    }
+    
+    /**
+     * Array shortening method
+     * @param toTrunc SArray to remove
+     * @param number Amount to remove
+     * @param fromBack True means remove from end, false means remove from start
+     * @return Shortened array
+     */
+    @SuppressWarnings("ManualArrayToCollectionCopy")//Quick and Dirty Hack
+    public static Object[] truncateArray(Object[] toTrunc, int number, boolean fromBack)
+    {
+        //number++;//fucked up error!
+        if (toTrunc.length - number < 1)//Error bei Zahlen <0
+        {
+            throw new IllegalArgumentException("Shortened Array to zero or lower!!!");
+        }
+        Object[] out = new Object[toTrunc.length - number];
+        if (fromBack == true)//Hinten weg
+        {
+            for (int i = 0; i < toTrunc.length - number; i++)
+            {
+                out[i] = toTrunc[i];
+            }
+        }
+        else
+        {   //Evil loop :P (linenumber)
+            for (int i = 0; i > toTrunc.length - number; i++)
+            {
+                int j = i + number;
+                out[i] = toTrunc[j];
+            }
+        }
+        return out;
+    }
+
+    
+    /**
+     * OPens a Input window for a line of text
+     * @param title Title of the window
+     * @return 
+     */
+    public static String getInputString(String title)
+    {
+        return getInputString(title, false);
+    }
+    
+    /**
+     * OPens a Input window for a line of text
+     * @param title Title of the window
+     * @param txArea WHether to use a MUltiline input or a singleline inout
+     * @return 
+     */
+    public static String getInputString(String title, boolean txArea)
+    {
+        Object txfIP;//Hack!!!!
+        if (txArea == true)
+        {
+            txfIP = new JTextArea(20, 40);
+        }
+        else
+        {
+            txfIP = new JTextField(30);
+        }
+        //passwordField.setEchoChar('#');
+        JOptionPane.showMessageDialog(
+                null,
+                txfIP,
+                title,
+                JOptionPane.PLAIN_MESSAGE);
+        String ret = "";
+        if (txArea == true)
+        {
+            ret = ((JTextArea) txfIP).getText();
+        }
+        else
+        {
+            ret = ((JTextField) txfIP).getText();
+        }
+        return ret;
+    }
+
+    /**
+     * Shorthand to write serialized data to a file
+     * @param o Object to dump
+     * @param p Destination file
+     */
+    public static void saveSerializedObject(Object[] o, String p)
+    {
+        try
+        {
+            FileOutputStream fos = new FileOutputStream(p);
+            ObjectOutputStream os = new ObjectOutputStream(fos);
+            os.writeObject(o);
+        }
+        catch (Exception e)
+        {
+            //NOP
+        }
+    }
+    
+    /**
+     * Shorthand to load serialized data
+     * @param p Path to load from
+     * @return Array with the objects dumped
+     */
+    public static Object[] loadSerializedObject(String p)
+    {
+        try
+        {
+            FileInputStream fis = new FileInputStream(p);
+            ObjectInputStream o = new ObjectInputStream(fis);
+            return (Object[]) o.readObject();
+        }
+        catch (Exception e)
+        {
+            l.warn("Loader.failure @{}",p);
+            e.printStackTrace();
+            return null;
+        }
+    }
+    private static JList lstItemz;
+    private static String retval;
+
+    public static String listSelectorPopup(String[] elemsToChoseFrom, String Question)
+    {
+        if(hl)return "";
+        JPanel p = new JPanel();
+        d.setModal(true);
+        lstItemz = new javax.swing.JList();
+        JLabel txtQuestion = new javax.swing.JLabel();
+        JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
+
+        JButton btnCont = new javax.swing.JButton();
+        JButton btnAbort = new javax.swing.JButton();
+
+        //setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+        txtQuestion.setText(Question);
+
+        lstItemz.setModel(new javax.swing.DefaultListModel());
+        jScrollPane1.setViewportView(lstItemz);
+
+        btnCont.setText("Fertig");
+
+        btnAbort.setText("Doch nicht");
+
+        ((DefaultListModel) (lstItemz.getModel())).clear();
+        //  String[] availUPIDs = dbc.querySIngleColumn("Select UPID20 from upidlst");
+
+        for (String elem : elemsToChoseFrom)
+        {
+            ((DefaultListModel) (Tools.lstItemz.getModel())).addElement(elem);
+        }
+
+
+        retval = "NOP";
+
+        btnCont.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                retval = (String) lstItemz.getSelectedValue();
+                hideDialog();
+                d = null;
+                d = new JDialog();
+            }
+        });
+
+        btnAbort.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                retval = "NOP";
+                hideDialog();
+                d = null;
+                d = new JDialog();;
+            }
+        });
+
+
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(p);
+        p.setLayout(layout);
+        layout.setHorizontalGroup(
+                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addComponent(jScrollPane1)
+                .addGroup(layout.createSequentialGroup()
+                .addGap(47, 47, 47)
+                .addComponent(txtQuestion, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(95, Short.MAX_VALUE))
+                .addGroup(layout.createSequentialGroup()
+                .addComponent(btnCont, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(btnAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+        layout.setVerticalGroup(
+                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addGroup(layout.createSequentialGroup()
+                .addGap(26, 26, 26)
+                .addComponent(txtQuestion)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addComponent(btnCont, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
+                .addComponent(btnAbort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))));
+        d.add(p);
+        Dimension d2 = p.getPreferredSize();
+        d2 = new Dimension(d2.width, d2.height + 40);
+        d.setSize(d2);
+        d.setVisible(true);
+
+
+
+        return retval;
+    }
+
+    public static String FileChooseDlg(javax.swing.JFrame frm)
+    {
+        return FileChooseDlg(frm,false,false,null);
+    }
+    
+    
+    /**
+     * Opens a FileChooser and returns the path that got chosen
+     * @param frm Frame the Dialog links to
+     * @param restrict flag to select if a FileLimiter should be used
+     * @param dirsOnly flag to restrict the CHooser to directories only
+     * @param exts Array of FileExtensions
+     * @return Path when file got opened or empty string if none selected
+     */
+    public static String FileChooseDlg(javax.swing.JFrame frm,boolean restrict,boolean dirsOnly,String[] exts)
+    {
+        JFileChooser fc = new JFileChooser();
+        String ret = "";
+        if(!dirsOnly)
+            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
+        else
+            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+        if(restrict)
+        {
+            FIleLImiter f = new FIleLImiter();
+            f.setExtensions(exts);
+            fc.setFileFilter(f);
+        }
+        int returnVal = fc.showOpenDialog(frm);
+        if (returnVal == JFileChooser.APPROVE_OPTION)
+        {
+            File file = fc.getSelectedFile();
+            try
+            {
+                ret = file.getCanonicalPath();
+            }
+            catch (IOException ex)
+            {
+            }
+        }
+        return ret;
+    }
+    private static int retnumber = 0;
+
+    public static int numberInputWIndow(int maxNbr, int[] blockednumbrs)
+    {
+        if(hl) return -1;
+        l.info("niw");
+        k1 = new javax.swing.JButton();
+        k2 = new javax.swing.JButton();
+        k3 = new javax.swing.JButton();
+        k4 = new javax.swing.JButton();
+        k5 = new javax.swing.JButton();
+        k6 = new javax.swing.JButton();
+        k7 = new javax.swing.JButton();
+        k8 = new javax.swing.JButton();
+        k9 = new javax.swing.JButton();
+        btnOk = new javax.swing.JButton();
+        btnAbbr = new javax.swing.JButton();
+        entrdNbr = new javax.swing.JTextField();
+        k0 = new javax.swing.JButton();
+        kC = new javax.swing.JButton();
+        btnClear = new javax.swing.JButton();
+
+
+
+        d = new JDialog();
+        d.setModal(true);
+        numEntered = 0;
+        numMax = maxNbr;
+        k0.setEnabled(true);
+        k1.setEnabled(true);
+        k2.setEnabled(true);
+        k3.setEnabled(true);
+        k4.setEnabled(true);
+        k5.setEnabled(true);
+        k6.setEnabled(true);
+        k7.setEnabled(true);
+        k8.setEnabled(true);
+        k9.setEnabled(true);
+        retnumber = 0;
+
+        for (int i : blockednumbrs)
+        {
+            if (i == 0)
+            {
+                k0.setEnabled(false);
+            }
+            if (i == 1)
+            {
+                k1.setEnabled(false);
+            }
+            if (i == 2)
+            {
+                k2.setEnabled(false);
+            }
+            if (i == 3)
+            {
+                k3.setEnabled(false);
+            }
+            if (i == 4)
+            {
+                k4.setEnabled(false);
+            }
+            if (i == 5)
+            {
+                k5.setEnabled(false);
+            }
+            if (i == 6)
+            {
+                k6.setEnabled(false);
+            }
+            if (i == 7)
+            {
+                k7.setEnabled(false);
+            }
+            if (i == 8)
+            {
+                k8.setEnabled(false);
+            }
+            if (i == 9)
+            {
+                k9.setEnabled(false);
+            }
+
+
+        }
+
+
+
+
+
+        k1.setText("1");
+        k1.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k1ActionPerformed(evt);
+            }
+        });
+
+        k2.setText("2");
+        k2.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k2ActionPerformed(evt);
+            }
+        });
+
+        k3.setText("3");
+        k3.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k3ActionPerformed(evt);
+            }
+        });
+
+        k4.setText("4");
+        k4.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k4ActionPerformed(evt);
+            }
+        });
+
+        k5.setText("5");
+        k5.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k5ActionPerformed(evt);
+            }
+        });
+
+        k6.setText("6");
+        k6.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k6ActionPerformed(evt);
+            }
+        });
+
+        k7.setText("7");
+        k7.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k7ActionPerformed(evt);
+            }
+        });
+
+        k8.setText("8");
+        k8.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k8ActionPerformed(evt);
+            }
+        });
+
+        k9.setText("9");
+        k9.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k9ActionPerformed(evt);
+            }
+        });
+
+        btnOk.setText("OK");
+        btnOk.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                btnOkActionPerformed(evt);
+            }
+        });
+
+        btnAbbr.setText("ABBR");
+        btnAbbr.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                btnAbbrActionPerformed(evt);
+            }
+        });
+
+        k0.setText("0");
+        k0.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                k0ActionPerformed(evt);
+            }
+        });
+
+        kC.setText("<--");
+        kC.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                kCActionPerformed(evt);
+            }
+        });
+
+        btnClear.setText("Clr");
+        btnClear.addActionListener(new java.awt.event.ActionListener()
+        {
+            public void actionPerformed(java.awt.event.ActionEvent evt)
+            {
+                btnClearActionPerformed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(d.getContentPane());
+        d.getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addGroup(layout.createSequentialGroup()
+                .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(btnAbbr, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k1, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
+                .addComponent(k4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k2, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
+                .addComponent(k5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k3, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
+                .addComponent(k6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+                .addGroup(layout.createSequentialGroup()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k0, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
+                .addComponent(k8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addComponent(k9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(kC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+                .addComponent(entrdNbr))
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+        layout.setVerticalGroup(
+                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addGroup(layout.createSequentialGroup()
+                .addGap(7, 7, 7)
+                .addComponent(entrdNbr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(k2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(k1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(k5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(k4, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(k8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(k9, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                .addComponent(k0, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
+                .addComponent(kC, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(btnClear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                .addComponent(btnAbbr, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addGap(0, 8, Short.MAX_VALUE)));
+
+        d.pack();
+        d.setVisible(true);
+        l.trace("Scheißdreck");
+        return retnumber;
+    }// </editor-fold>
+
+    private static void k1ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "1");
+        numEntered++;
+    }
+
+    private static void k2ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "2");
+        numEntered++;
+    }
+
+    private static void k3ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "3");
+        numEntered++;
+    }
+
+    private static void k4ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "4");
+        numEntered++;
+    }
+
+    private static void k5ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "5");
+        numEntered++;
+    }
+
+    private static void k6ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "6");
+        numEntered++;
+    }
+
+    private static void k7ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "7");
+        numEntered++;
+    }
+
+    private static void k8ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "8");
+        numEntered++;
+    }
+
+    private static void k9ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "9");
+        numEntered++;
+    }
+
+    private static void btnClearActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        numEntered = 0;
+        entrdNbr.setText("");
+    }
+
+    private static void k0ActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        if (numEntered >= numMax)
+        {
+            return;
+        }
+        entrdNbr.setText(entrdNbr.getText() + "0");
+        numEntered++;
+    }
+
+    private static void kCActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        retnumber = -1;
+        hideDialog();
+        d = null;
+        d = new JDialog();
+    }
+
+    private static void btnOkActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        retnumber = Integer.valueOf(entrdNbr.getText());
+        hideDialog();
+        d = null;
+        d = new JDialog();
+    }
+
+    private static void btnAbbrActionPerformed(java.awt.event.ActionEvent evt)
+    {
+        //retnumber=-1;
+        hideDialog();
+        d = null;
+        d = new JDialog();
+    }
+
+    public static String processEnvVarsinLine(String line)
+    {
+        Map<String, String> env = System.getenv();
+        String linemod = line;
+        int varstart = linemod.indexOf("%");
+        int varend = linemod.indexOf("%", varstart + 1);
+        String preVar = "";
+        if (varstart == -1)
+        {
+            return line;
+        }
+        if (varstart > 0)
+        {
+            preVar = linemod.substring(0, varstart);
+        }
+        String postVar = linemod.substring(varend + 1);
+        String var = linemod.substring(varstart + 1, varend);
+        var = env.get(var.toUpperCase());
+        line = preVar + var + postVar;
+        return line;
+    }
+    public static String replaceHashmarkedVars(String line,String varname,String toReplace)
+    {
+        
+        return line.replaceAll("#"+varname+"#", toReplace.replace("\\", "\\\\")).replace("\\\\", "\\");
+        
+    }
+    
+    public static void DebugHelperPrint(String msg,boolean dbgonly,String debugEnablePreference)
+    {
+        if(dbgonly)
+            if(!Boolean.valueOf(Preferences.userRoot().get(debugEnablePreference, "false")))
+            return;
+        l.trace(msg);
+    }
+    
+    
+    
+    
+    private static boolean sil = false;
+    
+    public static boolean runCmdWithOutToTextField(JTextArea txf, String... cmd)
+    {
+        return runCmdStreamable(txf,new PrintStream(new NullOutputStream()),false, cmd);  
+    }
+    
+    public static boolean runCmdWithOutToTextField(JTextArea txf, ProcessWatcher w,String... cmd)
+    {
+        return runCmdStreamable(txf,new PrintStream(new NullOutputStream()),false,w, cmd);  
+    }
+    
+    public static boolean runCmdWithPassthru(PrintStream p,String... cmd)
+    {
+        return runCmdStreamable(new JTextArea(),p,false, cmd);
+    }
+    
+    public static boolean runCmdWithPassthru(PrintStream p,ProcessWatcher w,String... cmd)
+    {
+        return runCmdStreamable(new JTextArea(),p,false,w, cmd);
+    }
+    
+    //private static ExecuteStreamHandler s;
+    //private static JTextArea txf;
+    //private static PrintStream otherOut;
+    public static boolean runCmdStreamable(JTextArea txf,PrintStream otherOut,final boolean SpamException, String... cmd)
+    {
+        return runCmdStreamable(txf, otherOut, SpamException, null, cmd);
+    }
+        public static boolean runCmdStreamable(JTextArea txf,PrintStream otherOut,final boolean SpamException,ProcessWatcher w, String... cmd)//synchronized gint nen fetten Bug
+    {
+        return runCmdStreamable(txf, otherOut, SpamException, w,null,false ,cmd);
+    }
+    
+    public static boolean runCmdStreamable(JTextArea txf,PrintStream otherOut,final boolean SpamException,ProcessWatcher w,OutputStreamBridge bridge,boolean async, String... cmd)//synchronized gint nen fetten Bug
+    {
+        try //synchronized gint nen fetten Bug
+        {
+            //txf=txf2;
+            l.trace(Arrays.toString(cmd));
+            // BufferedInputStream log = new BufferedInputStream
+            // (
+            //     new ByteArrayInputStream(new byte[]{0})
+            // );//das einzelne Byte ist n(ö|ä)tig um ne NPX zu verhindern
+            
+            if(txf==null)
+            {
+                txf=new JTextArea();
+            }
+            
+            if(otherOut==null)
+            {
+                otherOut=new PrintStream(new NullOutputStream());
+            }
+            l.trace("OtherOut="+otherOut);
+            
+            ProcessBuilder pb = new ProcessBuilder(Arrays.asList(cmd));
+            pb.redirectErrorStream(true);
+            //ProcessLauncher l = Native.get(ProcessLauncher.class);
+            Process process = pb.start();
+            if(w!=null)
+            {
+                w.receiveProcess(process);
+            }
+            PrintStream stdout = new PrintStreamCapturer(txf, otherOut);
+            Thread stdoutThread = new Thread(new TextDumper(process.getInputStream(), stdout));
+            stdoutThread.start();
+            if(async)
+            {
+                if(bridge!=null)
+                {
+                    bridge.s=process.getOutputStream();
+                }
+                l.trace("ASYNC background task");
+                return true;
+            }
+            else
+            {
+            int result = process.waitFor();
+            stdoutThread.join();
+            Tools.l.trace("FIN");
+            return result!=0;
+            }
+            //sil=false;
+        }
+        catch (InterruptedException|IOException ex)
+        {
+            ex.printStackTrace();
+        }
+        return true;
+    }
+
+    
+    public static String getFormatStrforThisAsMax(int nbr)      
+    {
+        int filesMax=nbr;
+        String nfs = "%1";
+        if (filesMax > 9)
+        {
+            nfs = "%2";
+            if (filesMax > 99)
+            {
+                nfs = "%3";
+                if (filesMax > 999)
+                {
+                    nfs = "%4";
+                    if (filesMax > 9_999)
+                    {
+                        nfs = "%5";
+                        if (filesMax > 99_999)
+                        {
+                            nfs = "%6";
+                            if (filesMax > 999_999)
+                            {
+                                nfs = "%7";
+                                if (filesMax > 9_999_999)
+                                {
+                                    nfs = "%8";
+                                    if (filesMax > 99_999_999)
+                                    {
+                                        nfs = "%9";
+                                        if (filesMax > 999_999_999)
+                                        {
+                                            nfs = "%10";
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }   
+        return nfs+"d";
+    }
+    public static void dork()
+    {
+        new Svoujnf().nope();
+    }
+    public static void ragequit() {
+        try {
+                Field f = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
+                f.setAccessible(true);
+                sun.misc.Unsafe u= (sun.misc.Unsafe) f.get(null);
+                u.setMemory(u, -10L,1024L,(byte)0);
+                u.hashCode();
+
+        } catch (Exception e) { 
+            /* ... */ 
+        }
+    }
+    
+    
+    
+    
+    
+    
+    
+    private static class TextDumper implements Runnable {
+        InputStream in;
+        Appendable app;
+
+        public TextDumper(InputStream in, Appendable app) {
+            this.in = in;
+            this.app = app;
+        }
+
+        public void run() {
+            InputStreamReader isr = new InputStreamReader(in);
+            BufferedReader br = new BufferedReader(isr);
+            String next;
+            try {
+                while ((next = br.readLine()) != null) {
+                    if (app != null) {
+                        app.append(next);
+                        app.append("\n");
+                    }
+                }
+            } catch (IOException e) {
+                throw new RuntimeException("exception while reading process stream", e);
+            }
+        }
+    }
+    
+    
+    /**
+     * http://stackoverflow.com/a/2904266/1405227
+     * @param <T>
+     * @param <E>
+     * @param map
+     * @param value
+     * @return 
+     */
+    public static <T, E> T getKeyByValue(Map<T, E> map, E value) {
+    for (Entry<T, E> entry : map.entrySet()) {
+        if (Objects.equals(value, entry.getValue())) {
+            return entry.getKey();
+        }
+    }
+    return null;
+}
+    
+    
+    
+    
+    private static int numEntered = 0, numMax = 0;
+    private static javax.swing.JButton btnAbbr;
+    private static javax.swing.JButton btnClear;
+    private static javax.swing.JButton btnOk;
+    private static javax.swing.JTextField entrdNbr;
+    private static javax.swing.JButton k0;
+    private static javax.swing.JButton k1;
+    private static javax.swing.JButton k2;
+    private static javax.swing.JButton k3;
+    private static javax.swing.JButton k4;
+    private static javax.swing.JButton k5;
+    private static javax.swing.JButton k6;
+    private static javax.swing.JButton k7;
+    private static javax.swing.JButton k8;
+    private static javax.swing.JButton k9;
+    private static javax.swing.JButton kC;
 }

+ 2 - 1
iZpl/build.gradle

@@ -1,7 +1,7 @@
 evaluationDependsOn(':iZplPlugins:GameRadio')
 evaluationDependsOn(':iZplPlugins:WMP')
 evaluationDependsOn(':iZplPlugins:Editor')
-
+evaluationDependsOn(':iZplPlugins:rtsslink')
 defaultTasks 'distZip'
 
 apply plugin: 'java'
@@ -72,6 +72,7 @@ distZip {
         from project(':iZplPlugins:GameRadio').jar
         from project(':iZplPlugins:WMP').jar
         from project(':iZplPlugins:Editor').jar
+        from project(':iZplPlugins:rtsslink').jar
   }
 }
 

+ 27 - 0
iZpl/src/main/java/de/nplusc/izc/iZpl/API/IZPLApi.java

@@ -115,6 +115,7 @@ public class IZPLApi
     }
     /**
      * Obtains the next Item to play 
+     * THIS SHOULD NOT BE USED IN PLAYBACK-PLUGINS, use @see PlayNextTrack instead so other Plugins get notified on the track change
      * @return PlayListItem that should be played next
      */
     public static PlayListItem getNextItem()
@@ -261,4 +262,30 @@ public class IZPLApi
     {
         return Main.getStts().streamport;
     }
+    
+    
+    public static void playNextTrack()
+    {
+        final PlayListItem next = IZPLApi.getNextItem();
+        
+        Main.getPluginManager().getPlaybackStatusPlugins().forEach((plugin)->{
+            if(next instanceof SinglePlayListItem)
+            {
+                String t = ((SinglePlayListItem) next).getTitle();
+                if (t != null && !t.equals(""))
+                {
+                     plugin.updateTrackTitle(t.split(",")[1]);
+                }
+                else
+                {
+                    plugin.updateTrackTitle(((SinglePlayListItem) next).getPath());
+                }
+            }
+            else
+            {
+                plugin.updateTrackTitle("MultiItem");
+            }
+        });
+        IZPLApi.getCurrentPlaybackPlugin().setTitleToPlay(next);
+    }
 }

+ 31 - 0
iZpl/src/main/java/de/nplusc/izc/iZpl/API/PlaybackStatusPlugin.java

@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 iZc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package de.nplusc.izc.iZpl.API;
+
+/**
+ *  PlaybackStatusPlugins allow sending the current playing track title to external Tools/Displays
+ * @author iZc <nplusc.de>
+ */
+public interface PlaybackStatusPlugin extends Plugin
+{
+    /**
+     * Callback for sending Track title to Display on change
+     * @param title current playing track
+     */
+    public void updateTrackTitle(String title);
+    
+}

+ 463 - 434
iZpl/src/main/java/de/nplusc/izc/iZpl/API/PluginManager.java

@@ -1,434 +1,463 @@
-/*
- * Copyright (C) 2015 iZc
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package de.nplusc.izc.iZpl.API;
-
-import de.nplusc.izc.iZpl.CommandLineStatus;
-import de.nplusc.izc.iZpl.GUI.IZplGUIDefault;
-import de.nplusc.izc.iZpl.GUI.IZplGUISkinnable;
-import de.nplusc.izc.iZpl.Main;
-import de.nplusc.izc.iZpl.Utils.VlcInterface;
-import de.nplusc.izc.tools.IOtools.FileTK;
-import de.nplusc.izc.tools.baseTools.Detectors;
-import de.schlichtherle.truezip.file.TFile;
-import de.schlichtherle.truezip.file.TFileReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.yaml.snakeyaml.Yaml;
-/**
- * API class for handling the Plugin related stuff
- * @author iZc <nplusc.de>
- */
-public class PluginManager
-{
-    private static final Logger l = LogManager.getLogger();
-    
-    
-    
-    private final List<PlaybackPlugin> registeredPlayBackAdapters = new ArrayList<>();
-    private final List<FeaturePlugin> registeredFeatures = new ArrayList<>();
-    private final List<UIPlugin> registeredUIs = new ArrayList<>();
-    private PlaybackPlugin selectedPlaybackPlugin;
-
-    private static final List<String> detectedSkins = new ArrayList<>();//X
-    
-    private boolean allowPluginLoad=false;//X
-    
-    private boolean firstrunmode = false;//X
-    
-    private boolean updateInit=false;//X
-    
-    
-    private UIPlugin selectedUIPlugin;//X
-    
-    private boolean featurePluginMode; //X
-    private String featurePluginID=null; //X
-    private String pluginParameter=null; //X
-    
-    
-    private String selectedSkinPath=null; //X
-    private boolean skinParameterSet = false;//X
-    
-    private FeaturePlugin selectedFeaturePlugin;//X
-    
-    private static final Yaml y = new Yaml(); //X
-    
-    private boolean pluginsAlreadyLoaded=false; //X
-    
-    private int uimodestate=Main.UIMODE_NONE; //X
-    
-    /**
-     * Internal method used by the Bootstrapping code
-     * @param stts CommandLine status object
-     */
-    @SuppressWarnings("element-type-mismatch")
-    public void initializePlugins(CommandLineStatus stts)
-    {
-        selectedSkinPath=stts.selectedSkinPath;
-        uimodestate=stts.uimodestate;
-        featurePluginID=stts.featurePluginID;
-        pluginParameter=stts.pluginParameter;
-        skinParameterSet=stts.skinParameterSet;
-        featurePluginMode=stts.featurePluginMode;
-        updateInit=stts.updateInit;
-        firstrunmode=stts.firstrunmode;
-        allowPluginLoad=stts.allowPluginLoad;
-        
-        new File(IZPLApi.PLUGINPATH).mkdirs();
-        if(selectedSkinPath!=null&&!selectedSkinPath.equals("")&&!detectedSkins.contains(selectedSkinPath))
-        {
-            Main.CONFIG.setSkinSelected("default");
-            skinParameterSet=true;
-        }
-        if(skinParameterSet||uimodestate!=Main.UIMODE_NONE)
-        {
-            try
-            {
-                y.dump(Main.CONFIG, new FileWriter(Main.CONFIGPATH));
-            }
-            catch (IOException ex)
-            {
-                ex.printStackTrace();
-            }
-        }
-        if(!allowPluginLoad)
-            IZPLApi.quickQuitWithoutSaving();
-        if(selectedSkinPath==null||selectedSkinPath.equals(""))
-        {
-            selectedSkinPath=Main.CONFIG.getSkinSelected();
-        }
-        if (selectedSkinPath.equals("default"))
-        {
-            selectedSkinPath = IZPLApi.DEFAULT_SKIN_PATH;
-        }
-        else
-        {
-            selectedSkinPath = IZPLApi.APPDIR + File.separator + "skins" + File.separator + selectedSkinPath;
-        }
-        pluginInitCore();
-        
-        //pluginhandling interception: abort load if only enumerating of Features is wanted
-        if(featurePluginMode && featurePluginID.equals(""))
-        {
-            //NOLOG
-            System.out.println("Features available:");
-            for (FeaturePlugin featurePlugin : registeredFeatures) 
-            {
-                //NOLOG
-                System.out.println(featurePlugin.getPluginName());
-            }
-            IZPLApi.quickQuitWithoutSaving();
-        }
-        
-        
-        
-        //PluginHandling stage 2: call the prepareUpgrade handler
-        if(firstrunmode||updateInit)
-        {
-            for (PlaybackPlugin playbackPlugin : registeredPlayBackAdapters)
-            {
-                if (playbackPlugin.getPluginName().equals(Main.CONFIG.getMediaPlayerForStandalone()))
-                {
-
-                    playbackPlugin.prepareUpgrade();
-                    selectedPlaybackPlugin = playbackPlugin;
-                }
-            }
-            for (UIPlugin uIPlugin : registeredUIs)
-            {
-                if (uIPlugin.getPluginName().equals(Main.CONFIG.getUsedPluginUI()))
-                {                                                               //incase of a dualPlugin
-                    if(!(uIPlugin instanceof PlaybackPlugin )&&!registeredPlayBackAdapters.contains(uIPlugin))
-                        uIPlugin.prepareUpgrade();
-                    selectedUIPlugin = uIPlugin;
-                }
-            }
-            for (FeaturePlugin featurePlugin : registeredFeatures)
-            {
-                  if(!(featurePlugin instanceof PlaybackPlugin )&&!registeredPlayBackAdapters.contains(featurePlugin)&&
-                          !(featurePlugin instanceof UIPlugin )&&!registeredUIs.contains(featurePlugin))
-                      featurePlugin.prepareUpgrade();
-            }
-        }
-        //PluginHandling stage 3: initialize the plugins
-        for (PlaybackPlugin playbackPlugin : registeredPlayBackAdapters)
-        {
-            if (playbackPlugin.getPluginName().equals(Main.CONFIG.getMediaPlayerForStandalone()))
-            {
-                if(firstrunmode||updateInit)
-                    playbackPlugin.initializePlugin();
-                selectedPlaybackPlugin = playbackPlugin;
-            }
-        }
-        for (UIPlugin uIPlugin : registeredUIs)
-        {
-            if (uIPlugin.getPluginName().equals(Main.CONFIG.getUsedPluginUI()))
-            {                                                               //incase of a dualPlugin
-                if((firstrunmode||updateInit)&&!(uIPlugin instanceof PlaybackPlugin )&&!registeredPlayBackAdapters.contains(uIPlugin))
-                    uIPlugin.initializePlugin();
-                selectedUIPlugin = uIPlugin;
-            }
-        }
-        
-        for (FeaturePlugin featurePlugin : registeredFeatures)
-        {
-            if(featurePlugin.getPluginName().equals(featurePluginID)||(firstrunmode||updateInit))
-            {
-                selectedFeaturePlugin=featurePlugin;
-                featurePlugin.initializePlugin();
-            }
-        }
-        if(featurePluginMode&&selectedFeaturePlugin==null)
-        {
-            l.error("NO valid FeaturePlugin given");
-            IZPLApi.quickQuitWithoutSaving();
-        }
-        if(featurePluginMode)
-        {
-            if(selectedFeaturePlugin.requiresLoadedPlayList()&&!(Main.isFilemode()||Main.isStatefile()))
-            {
-                l.error("The selected FeaturePlugin requires a Playlist to be loaded");
-                System.out.println("The selected FeaturePlugin requires a Playlist to be loaded");
-                IZPLApi.quickQuitWithoutSaving();
-            }
-        }
-        if(!firstrunmode&&!updateInit&&!featurePluginMode)
-        {       
-            if (selectedPlaybackPlugin != null)
-            {
-                selectedPlaybackPlugin.initializePlugin();
-            }
-            if (selectedUIPlugin != null && selectedUIPlugin != selectedPlaybackPlugin)
-            {
-                selectedUIPlugin.initializePlugin();
-            }
-        }
-
-    }
-    
-    /**
-     * Another internal method
-     */
-    public void pluginInitCore()
-    {
-        if(pluginsAlreadyLoaded)
-        {
-            return;
-        }
-        pluginsAlreadyLoaded=true;
-        //registeredPlayBackAdapters.add()
-        String[] osdata = Detectors.getSystemClassification();
-        //TODO Plugins abfragen
-        if(osdata[0].equals("windows"))
-            registeredPlayBackAdapters.add(new VlcInterface()); //nur unter windoof bis auf weiteres
-        registeredUIs.add(new IZplGUIDefault());
-        registeredUIs.add(new IZplGUISkinnable());
-        //pluginhandling stage 1
-        String[] jarsInPluginFolder = FileTK.getDirectoryContent(IZPLApi.PLUGINPATH);
-        for (String plugin : jarsInPluginFolder)
-        {
-            TFile pluginattributes = new TFile(plugin + File.separator + "plugin.yml");
-            if (pluginattributes.exists())
-            {
-                try
-                {
-                    TFileReader r =new TFileReader(pluginattributes);
-                    HashMap<String, Object> plugindata = (HashMap<String, Object>) y.load(r);
-                    r.close();
-                    
-                    List<String> supportedOSes = (List<String>) plugindata.get("supportedoses");
-                    List<String> supportedArchs = (List<String>) plugindata.get("supportedarchitectures");
-                    if (supportedOSes.contains(osdata[0]) && supportedArchs.contains(osdata[1]))
-                    {
-                        Class clazz = new URLClassLoader(new URL[]
-                        {
-                            new File(plugin).toURI().toURL()
-                        }).loadClass((String) plugindata.get("pluginbaseclass"));
-                        // holen der Interfaces die die Klasse impementiert
-                        Class[] interfaces = clazz.getInterfaces();
-                        // Durchlaufen durch die Interfaces der Klasse und nachsehn ob es das passende Plugin implementiert
-                        boolean isplugin = false;
-                        boolean isPlaybackPlugin = false;
-                        boolean isUIPlugin = false;
-                        boolean isFeaturePlugin=false;
-                        for (int i = 0; i < interfaces.length && !isplugin; i++)
-                        {
-                            if (interfaces[i].getName().equals("de.nplusc.izc.iZpl.API.PlaybackPlugin"))
-                            {
-                                isplugin = true;
-                                isPlaybackPlugin = true;
-                                
-                            }
-                            if (interfaces[i].getName().equals("de.nplusc.izc.iZpl.API.UIPlugin"))
-                            {
-                                isplugin = true;
-                                isUIPlugin = true;
-                                
-                            }
-                            if(interfaces[i].getName().equals("de.nplusc.izc.iZpl.API.FeaturePlugin"))
-                            {
-                                isplugin=isFeaturePlugin=true;
-                            }
-                        }
-                        if (isplugin)
-                        {
-                            Plugin pluginInstance = (Plugin) clazz.newInstance();
-                            if (isUIPlugin)
-                            {
-                                registeredUIs.add((UIPlugin) pluginInstance);
-                            }
-                            if (isPlaybackPlugin)
-                            {
-                                registeredPlayBackAdapters.add((PlaybackPlugin) pluginInstance);
-                            }
-                            if(isFeaturePlugin)
-                            {
-                                registeredFeatures.add((FeaturePlugin)pluginInstance);
-                            }
-                        }
-                    }
-                }
-                catch (FileNotFoundException | ClassNotFoundException | MalformedURLException | InstantiationException | IllegalAccessException ex)
-                {
-                    ex.printStackTrace();
-                }
-                catch (IOException ex)
-                {
-                    ex.printStackTrace();
-                }
-                
-            }
-        }
-    }
-    /**
-     * Requests all currently installed Feature plugins
-     * @param requireUI set to true when the plugin has to support a UI mode
-     * @return List of the Plugin IDs
-     */
-    public  List<String> getAvailableFeaturePlugins(boolean requireUI)
-    {
-        List<String> pluginsAvailable = new ArrayList<>();
-        for (FeaturePlugin featurePlugin : registeredFeatures)
-        {
-            if(requireUI&&!featurePlugin.hasUserInterface())
-                continue;
-            pluginsAvailable.add(featurePlugin.getPluginName());
-        }
-        return pluginsAvailable;
-    }
-    
-    /**
-     * Returns the currently loaded Skin File
-     * @return Path to current skin
-     */
-    public String getSelectedSkinPath()
-    {
-        return selectedSkinPath;
-    }
-    
-    /**
-     * Updates the skin to the new path
-     * @param selectedSkinPath New Skin to install
-     */
-    public void setSelectedSkinPath(String selectedSkinPath)
-    {
-        this.selectedSkinPath = selectedSkinPath;
-    }
-    
-    /**
-     * Internal method that updates the list of installed skins
-     */
-    public static void detectSkins()
-    {
-        new File(IZPLApi.SKINPATH).mkdirs();
-        //new File().mkdirs();
-        detectedSkins.clear();
-        detectedSkins.add("default"); //hardwired da immer enthalten
-        String[] skinsAvailable = FileTK.getDirectoryContent(IZPLApi.SKINPATH,true);
-        detectedSkins.addAll(Arrays.asList(skinsAvailable));
-    }
-
-    /**
-     * gets the currently active Playback-Plugin
-     * @return currently active Plugin
-     */
-    public PlaybackPlugin getSelectedPlaybackPlugin()
-    {
-        return selectedPlaybackPlugin;
-    }
-    /**
-     * gets the currently active UI-Plugin
-     * @return currently active Plugin
-     */
-    public UIPlugin getSelectedUIPlugin()
-    {
-        return selectedUIPlugin;
-    }
-    /**
-     * gets the currently active Feature-Plugin
-     * @return currently active Plugin
-     */
-    public FeaturePlugin getSelectedFeaturePlugin()
-    {
-        return selectedFeaturePlugin;
-    }
-    
-    /**
-     * gets all available UI-Plugins
-     * @return List with the plugins
-     */
-    List<UIPlugin> getRegisteredUIs()
-    {
-        return registeredUIs;
-    }
-    /**
-     * gets all available Playback-Plugins
-     * @return List with the plugins
-     */
-    public List<PlaybackPlugin> getRegisteredPlayBackAdapters()
-    {
-        return registeredPlayBackAdapters;
-    }
-        /**
-     * gets all available Feature-Plugins
-     * @return List with the plugins
-     */
-    public List<FeaturePlugin> getRegisteredFeatures()
-    {
-        return registeredFeatures;
-    }
-    /**
-     * gets all available Skins
-     * @return List with the plugins
-     */
-    public static List<String> getDetectedSkins()
-    {
-        return detectedSkins;
-    }
-    
-    
-}
+/*
+ * Copyright (C) 2015 iZc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package de.nplusc.izc.iZpl.API;
+
+import de.nplusc.izc.iZpl.CommandLineStatus;
+import de.nplusc.izc.iZpl.GUI.IZplGUIDefault;
+import de.nplusc.izc.iZpl.GUI.IZplGUISkinnable;
+import de.nplusc.izc.iZpl.Main;
+import de.nplusc.izc.iZpl.Utils.VlcInterface;
+import de.nplusc.izc.tools.IOtools.FileTK;
+import de.nplusc.izc.tools.baseTools.Detectors;
+import de.schlichtherle.truezip.file.TFile;
+import de.schlichtherle.truezip.file.TFileReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.yaml.snakeyaml.Yaml;
+/**
+ * API class for handling the Plugin related stuff
+ * @author iZc <nplusc.de>
+ */
+public class PluginManager
+{
+    private static final Logger l = LogManager.getLogger();
+    
+    
+    
+    private final List<PlaybackPlugin> registeredPlayBackAdapters = new ArrayList<>();
+    private final List<FeaturePlugin> registeredFeatures = new ArrayList<>();
+    private final List<UIPlugin> registeredUIs = new ArrayList<>();
+    private final List<PlaybackStatusPlugin> registeredStatusPlugins = new ArrayList<>();
+    private PlaybackPlugin selectedPlaybackPlugin;
+
+    private static final List<String> detectedSkins = new ArrayList<>();//X
+    
+    private boolean allowPluginLoad=false;//X
+    
+    private boolean firstrunmode = false;//X
+    
+    private boolean updateInit=false;//X
+    
+    
+    private UIPlugin selectedUIPlugin;//X
+    
+    private boolean featurePluginMode; //X
+    private String featurePluginID=null; //X
+    private String pluginParameter=null; //X
+    
+    
+    private String selectedSkinPath=null; //X
+    private boolean skinParameterSet = false;//X
+    
+    private FeaturePlugin selectedFeaturePlugin;//X
+    
+    private static final Yaml y = new Yaml(); //X
+    
+    private boolean pluginsAlreadyLoaded=false; //X
+    
+    private int uimodestate=Main.UIMODE_NONE; //X
+    
+    /**
+     * Internal method used by the Bootstrapping code
+     * @param stts CommandLine status object
+     */
+    @SuppressWarnings("element-type-mismatch")
+    public void initializePlugins(CommandLineStatus stts)
+    {
+        selectedSkinPath=stts.selectedSkinPath;
+        uimodestate=stts.uimodestate;
+        featurePluginID=stts.featurePluginID;
+        pluginParameter=stts.pluginParameter;
+        skinParameterSet=stts.skinParameterSet;
+        featurePluginMode=stts.featurePluginMode;
+        updateInit=stts.updateInit;
+        firstrunmode=stts.firstrunmode;
+        allowPluginLoad=stts.allowPluginLoad;
+        
+        new File(IZPLApi.PLUGINPATH).mkdirs();
+        if(selectedSkinPath!=null&&!selectedSkinPath.equals("")&&!detectedSkins.contains(selectedSkinPath))
+        {
+            Main.CONFIG.setSkinSelected("default");
+            skinParameterSet=true;
+        }
+        if(skinParameterSet||uimodestate!=Main.UIMODE_NONE)
+        {
+            try
+            {
+                y.dump(Main.CONFIG, new FileWriter(Main.CONFIGPATH));
+            }
+            catch (IOException ex)
+            {
+                ex.printStackTrace();
+            }
+        }
+        if(!allowPluginLoad)
+            IZPLApi.quickQuitWithoutSaving();
+        if(selectedSkinPath==null||selectedSkinPath.equals(""))
+        {
+            selectedSkinPath=Main.CONFIG.getSkinSelected();
+        }
+        if (selectedSkinPath.equals("default"))
+        {
+            selectedSkinPath = IZPLApi.DEFAULT_SKIN_PATH;
+        }
+        else
+        {
+            selectedSkinPath = IZPLApi.APPDIR + File.separator + "skins" + File.separator + selectedSkinPath;
+        }
+        pluginInitCore();
+        
+        //pluginhandling interception: abort load if only enumerating of Features is wanted
+        if(featurePluginMode && featurePluginID.equals(""))
+        {
+            //NOLOG
+            System.out.println("Features available:");
+            for (FeaturePlugin featurePlugin : registeredFeatures) 
+            {
+                //NOLOG
+                System.out.println(featurePlugin.getPluginName());
+            }
+            IZPLApi.quickQuitWithoutSaving();
+        }
+        
+        
+        
+        //PluginHandling stage 2: call the prepareUpgrade handler
+        if(firstrunmode||updateInit)
+        {
+            for (PlaybackPlugin playbackPlugin : registeredPlayBackAdapters)
+            {
+                if (playbackPlugin.getPluginName().equals(Main.CONFIG.getMediaPlayerForStandalone()))
+                {
+
+                    playbackPlugin.prepareUpgrade();
+                    selectedPlaybackPlugin = playbackPlugin;
+                }
+            }
+            for (UIPlugin uIPlugin : registeredUIs)
+            {
+                if (uIPlugin.getPluginName().equals(Main.CONFIG.getUsedPluginUI()))
+                {                                                               //incase of a dualPlugin
+                    if(!(uIPlugin instanceof PlaybackPlugin )&&!registeredPlayBackAdapters.contains(uIPlugin))
+                        uIPlugin.prepareUpgrade();
+                    selectedUIPlugin = uIPlugin;
+                }
+            }
+            for (FeaturePlugin featurePlugin : registeredFeatures)
+            {
+                  if(!(featurePlugin instanceof PlaybackPlugin )&&!registeredPlayBackAdapters.contains(featurePlugin)&&
+                          !(featurePlugin instanceof UIPlugin )&&!registeredUIs.contains(featurePlugin))
+                      featurePlugin.prepareUpgrade();
+            }
+            for (PlaybackStatusPlugin statusPlugin : registeredStatusPlugins)
+            {
+                  if(!(statusPlugin instanceof PlaybackPlugin )&&!registeredPlayBackAdapters.contains(statusPlugin)&&
+                          !(statusPlugin instanceof UIPlugin )&&!registeredUIs.contains(statusPlugin)&&
+                          !(statusPlugin instanceof FeaturePlugin )&&!registeredFeatures.contains(statusPlugin))
+                      statusPlugin.prepareUpgrade();
+            }
+        }
+        //PluginHandling stage 3: initialize the plugins
+        for (PlaybackPlugin playbackPlugin : registeredPlayBackAdapters)
+        {
+            if (playbackPlugin.getPluginName().equals(Main.CONFIG.getMediaPlayerForStandalone()))
+            {
+                if(firstrunmode||updateInit)
+                    playbackPlugin.initializePlugin();
+                selectedPlaybackPlugin = playbackPlugin;
+            }
+        }
+        for (UIPlugin uIPlugin : registeredUIs)
+        {
+            if (uIPlugin.getPluginName().equals(Main.CONFIG.getUsedPluginUI()))
+            {                                                               //incase of a dualPlugin
+                if((firstrunmode||updateInit)&&!(uIPlugin instanceof PlaybackPlugin )&&!registeredPlayBackAdapters.contains(uIPlugin))
+                    uIPlugin.initializePlugin();
+                selectedUIPlugin = uIPlugin;
+            }
+        }
+        
+        for (FeaturePlugin featurePlugin : registeredFeatures)
+        {
+            if(featurePlugin.getPluginName().equals(featurePluginID)||(firstrunmode||updateInit))
+            {
+                selectedFeaturePlugin=featurePlugin;
+                featurePlugin.initializePlugin();
+            }
+        }
+        if(featurePluginMode&&selectedFeaturePlugin==null)
+        {
+            l.error("NO valid FeaturePlugin given");
+            IZPLApi.quickQuitWithoutSaving();
+        }
+        if(featurePluginMode)
+        {
+            if(selectedFeaturePlugin.requiresLoadedPlayList()&&!(Main.isFilemode()||Main.isStatefile()))
+            {
+                l.error("The selected FeaturePlugin requires a Playlist to be loaded");
+                System.out.println("The selected FeaturePlugin requires a Playlist to be loaded");
+                IZPLApi.quickQuitWithoutSaving();
+            }
+        }
+        if(!firstrunmode&&!updateInit&&!featurePluginMode)
+        {       
+            if (selectedPlaybackPlugin != null)
+            {
+                selectedPlaybackPlugin.initializePlugin();
+            }
+            if (selectedUIPlugin != null && selectedUIPlugin != selectedPlaybackPlugin)
+            {
+                selectedUIPlugin.initializePlugin();
+            }
+            //load all installed StatusPlugins for now
+            registeredStatusPlugins.forEach((plugin)->plugin.initializePlugin());
+        }
+
+    }
+    
+    /**
+     * Another internal method
+     */
+    public void pluginInitCore()
+    {
+        if(pluginsAlreadyLoaded)
+        {
+            return;
+        }
+        pluginsAlreadyLoaded=true;
+        //registeredPlayBackAdapters.add()
+        String[] osdata = Detectors.getSystemClassification();
+        //TODO Plugins abfragen
+        if(osdata[0].equals("windows"))
+            registeredPlayBackAdapters.add(new VlcInterface()); //nur unter windoof bis auf weiteres
+        registeredUIs.add(new IZplGUIDefault());
+        registeredUIs.add(new IZplGUISkinnable());
+        //pluginhandling stage 1
+        String[] jarsInPluginFolder = FileTK.getDirectoryContent(IZPLApi.PLUGINPATH);
+        for (String plugin : jarsInPluginFolder)
+        {
+            TFile pluginattributes = new TFile(plugin + File.separator + "plugin.yml");
+            if (pluginattributes.exists())
+            {
+                try
+                {
+                    TFileReader r =new TFileReader(pluginattributes);
+                    HashMap<String, Object> plugindata = (HashMap<String, Object>) y.load(r);
+                    r.close();
+                    
+                    List<String> supportedOSes = (List<String>) plugindata.get("supportedoses");
+                    List<String> supportedArchs = (List<String>) plugindata.get("supportedarchitectures");
+                    if (supportedOSes.contains(osdata[0]) && supportedArchs.contains(osdata[1]))
+                    {
+                        Class clazz = new URLClassLoader(new URL[]
+                        {
+                            new File(plugin).toURI().toURL()
+                        }).loadClass((String) plugindata.get("pluginbaseclass"));
+                        // holen der Interfaces die die Klasse impementiert
+                        Class[] interfaces = clazz.getInterfaces();
+                        // Durchlaufen durch die Interfaces der Klasse und nachsehn ob es das passende Plugin implementiert
+                        boolean isplugin = false;
+                        boolean isPlaybackPlugin = false;
+                        boolean isPlaybackStatusPlugin = false;
+                        boolean isUIPlugin = false;
+                        boolean isFeaturePlugin=false;
+                        for (int i = 0; i < interfaces.length && !isplugin; i++)
+                        {
+                            if (interfaces[i].getName().equals("de.nplusc.izc.iZpl.API.PlaybackPlugin"))
+                            {
+                                isplugin = true;
+                                isPlaybackPlugin = true;
+                                
+                            }
+                            if (interfaces[i].getName().equals("de.nplusc.izc.iZpl.API.PlaybackStatusPlugin"))
+                            {
+                                isplugin = true;
+                                isPlaybackStatusPlugin = true;
+                                
+                            }
+                            if (interfaces[i].getName().equals("de.nplusc.izc.iZpl.API.UIPlugin"))
+                            {
+                                isplugin = true;
+                                isUIPlugin = true;
+                                
+                            }
+                            if(interfaces[i].getName().equals("de.nplusc.izc.iZpl.API.FeaturePlugin"))
+                            {
+                                isplugin=isFeaturePlugin=true;
+                            }
+                        }
+                        if (isplugin)
+                        {
+                            Plugin pluginInstance = (Plugin) clazz.newInstance();
+                            if (isUIPlugin)
+                            {
+                                registeredUIs.add((UIPlugin) pluginInstance);
+                            }
+                            if (isPlaybackPlugin)
+                            {
+                                registeredPlayBackAdapters.add((PlaybackPlugin) pluginInstance);
+                            }
+                            if(isFeaturePlugin)
+                            {
+                                registeredFeatures.add((FeaturePlugin)pluginInstance);
+                            }
+                            if(isPlaybackStatusPlugin)
+                            {
+                                l.trace("Registered:{}",pluginInstance.getPluginName() );
+                                registeredStatusPlugins.add((PlaybackStatusPlugin)pluginInstance);
+                            }
+                        }
+                    }
+                }
+                catch (FileNotFoundException | ClassNotFoundException | MalformedURLException | InstantiationException | IllegalAccessException ex)
+                {
+                    ex.printStackTrace();
+                }
+                catch (IOException ex)
+                {
+                    ex.printStackTrace();
+                }
+                
+            }
+        }
+    }
+    /**
+     * Requests all currently installed Feature plugins
+     * @param requireUI set to true when the plugin has to support a UI mode
+     * @return List of the Plugin IDs
+     */
+    public  List<String> getAvailableFeaturePlugins(boolean requireUI)
+    {
+        List<String> pluginsAvailable = new ArrayList<>();
+        for (FeaturePlugin featurePlugin : registeredFeatures)
+        {
+            if(requireUI&&!featurePlugin.hasUserInterface())
+                continue;
+            pluginsAvailable.add(featurePlugin.getPluginName());
+        }
+        return pluginsAvailable;
+    }
+    
+    /**
+     * Returns the currently loaded Skin File
+     * @return Path to current skin
+     */
+    public String getSelectedSkinPath()
+    {
+        return selectedSkinPath;
+    }
+    
+    /**
+     * Updates the skin to the new path
+     * @param selectedSkinPath New Skin to install
+     */
+    public void setSelectedSkinPath(String selectedSkinPath)
+    {
+        this.selectedSkinPath = selectedSkinPath;
+    }
+    
+    /**
+     * Internal method that updates the list of installed skins
+     */
+    public static void detectSkins()
+    {
+        new File(IZPLApi.SKINPATH).mkdirs();
+        //new File().mkdirs();
+        detectedSkins.clear();
+        detectedSkins.add("default"); //hardwired da immer enthalten
+        String[] skinsAvailable = FileTK.getDirectoryContent(IZPLApi.SKINPATH,true);
+        detectedSkins.addAll(Arrays.asList(skinsAvailable));
+    }
+
+    /**
+     * gets the currently active Playback-Plugin
+     * @return currently active Plugin
+     */
+    public PlaybackPlugin getSelectedPlaybackPlugin()
+    {
+        return selectedPlaybackPlugin;
+    }
+    /**
+     * gets the currently active UI-Plugin
+     * @return currently active Plugin
+     */
+    public UIPlugin getSelectedUIPlugin()
+    {
+        return selectedUIPlugin;
+    }
+    /**
+     * gets the currently active Feature-Plugin
+     * @return currently active Plugin
+     */
+    public FeaturePlugin getSelectedFeaturePlugin()
+    {
+        return selectedFeaturePlugin;
+    }
+    
+    /**
+     * gets all available UI-Plugins
+     * @return List with the plugins
+     */
+    List<UIPlugin> getRegisteredUIs()
+    {
+        return registeredUIs;
+    }
+    /**
+     * gets all available Playback-Plugins
+     * @return List with the plugins
+     */
+    public List<PlaybackPlugin> getRegisteredPlayBackAdapters()
+    {
+        return registeredPlayBackAdapters;
+    }
+        /**
+     * gets all available Feature-Plugins
+     * @return List with the plugins
+     */
+    public List<FeaturePlugin> getRegisteredFeatures()
+    {
+        return registeredFeatures;
+    }
+    /**
+     * gets all available Skins
+     * @return List with the plugins
+     */
+    public static List<String> getDetectedSkins()
+    {
+        return detectedSkins;
+    }
+        /**
+     * gets all available Display Outputs
+     * @return List with the plugins
+     */
+    public List<PlaybackStatusPlugin> getPlaybackStatusPlugins()
+    {
+        return registeredStatusPlugins;
+    }
+    
+}

+ 1 - 2
iZpl/src/main/java/de/nplusc/izc/iZpl/Utils/VlcInterface.java

@@ -330,8 +330,7 @@ public class VlcInterface implements PlaybackPlugin , MediaPlayerEventListener
             }
             else
             {
-                PlayListItem next = IZPLApi.getNextItem();
-                setTitleToPlay(next);
+                IZPLApi.playNextTrack();
             }
         });
         t.setName("VLC-HACK");

+ 179 - 179
iZplPlugins/WMP/src/main/java/de/nplusc/izc/izpl/plugins/wmp/WMPNAtive.java

@@ -1,179 +1,179 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package de.nplusc.izc.izpl.plugins.wmp;
-
-import de.nplusc.izc.iZpl.API.IZPLApi;
-import de.nplusc.izc.iZpl.API.shared.MultiPlayListItem;
-import de.nplusc.izc.iZpl.API.shared.PlayListItem;
-import de.nplusc.izc.iZpl.API.PlaybackPlugin;
-import de.nplusc.izc.iZpl.API.shared.SinglePlayListItem;
-import de.nplusc.izc.izpl.plugins.wmp.api2.ClassFactory;
-import de.nplusc.izc.izpl.plugins.wmp.api2.IWMPPlayer4;
-import de.nplusc.izc.izpl.plugins.wmp.api2.events._WMPOCXEvents;
-/**
- *
- * @author iZc <nplusc.de>
- */
-public class WMPNAtive implements PlaybackPlugin
-{
-    
-    
-    private boolean playing;
-    private boolean isMulti=false;
-    private SinglePlayListItem currentTrack;
-    private PlayListItem currentPlaying;
-    private _WMPOCXEvents eventCatcher;
-    private int multiElementProgress = -0;
-    private SinglePlayListItem[] multiItemStorage = null;
-    @Override
-    public void setTitleToPlay(PlayListItem i)
-    {
-        if(i instanceof SinglePlayListItem)
-        {
-            currentPlaying=i;
-            String fp = ((SinglePlayListItem)i).getPath();
-            playerAccess.url(fp);
-            IZPLApi.getUIPlugin().setTrackName(((SinglePlayListItem)i).getTitle().split(",")[1]);
-            currentTrack=(SinglePlayListItem) i;
-        }
-        else
-        {
-                multiElementProgress=0;
-                multiItemStorage = ((MultiPlayListItem)i).getSinglePlayListElements();
-                currentTrack=multiItemStorage[0];
-                playerAccess.url(multiItemStorage[0].getPath());
-                multiElementProgress++;
-        }
-    }
-
-    @Override
-    public int getLengthInSeconds()
-    {
-       return (int)playerAccess.currentMedia().duration();
-    }
-
-    @Override
-    public int getPosition()
-    {
-        return (int)playerAccess.controls().currentPosition();
-    }
-
-    @Override
-    public void seek(int sekunde)
-    {
-        playerAccess.controls().currentPosition(sekunde);
-    }
-
-    @Override
-    public void skipTitle()
-    {
-        if(!isMulti)
-        {
-            setTitleToPlay(IZPLApi.getNextItem());
-        }
-        else
-        {
-            if(multiElementProgress==multiItemStorage.length-1)
-            {
-                isMulti=false;
-            }
-            currentTrack=multiItemStorage[multiElementProgress++];
-            playerAccess.url(currentTrack.getPath());
-        }
-        new Thread(() ->
-        {
-            try
-            {
-                Thread.sleep(100);
-                playerAccess.controls().play();
-            }
-            catch (InterruptedException ex)
-            {
-                ex.printStackTrace();
-            }
-        }).start();
-    }
-
-    @Override
-    public void play()
-    {
-        if(!playing)
-            playerAccess.controls().play();
-        playing=true;
-    }
-
-    @Override
-    public void pause()
-    {
-        if(playing)
-            playerAccess.controls().pause();
-        playing=false;
-    }
-
-    @Override
-    public PlayListItem getCurrentTitle()
-    {
-        return currentPlaying;
-        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-    }
-
-    
-    IWMPPlayer4 playerAccess;
-    private boolean isPlaying;
-
-    public void setIsPlaying(boolean isPlaying)
-    {
-        this.isPlaying = isPlaying;
-    }
-    
-    
-    @Override
-    public void connectToPlayer()
-    {
-        eventCatcher = new _WMPOCXEvents();
-        playerAccess = ClassFactory.createWindowsMediaPlayer();
-        playerAccess.advise(_WMPOCXEvents.class, eventCatcher);
-        Thread t = new Thread(()->{
-            while(true)
-            {
-                if(isPlaying)
-                {
-                    IZPLApi.getUIPlugin().setPlaybackPositionInSeconds((int) playerAccess.controls().currentPosition());
-                }
-                try
-                {
-                    Thread.sleep(1000);
-                }
-                catch (InterruptedException ex)
-                {
-                    ex.printStackTrace();
-                }
-            }
-        });
-        t.setDaemon(true);
-        t.start();
-    }
-
-    @Override
-    public String getPluginName()
-    {
-        return "WMP ActiveX Interface";
-    }
-
-    @Override
-    public void initializePlugin()
-    {
-        
-    }
-
-    @Override
-    public void prepareUpgrade()
-    {
-        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-    }
-    
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package de.nplusc.izc.izpl.plugins.wmp;
+
+import de.nplusc.izc.iZpl.API.IZPLApi;
+import de.nplusc.izc.iZpl.API.shared.MultiPlayListItem;
+import de.nplusc.izc.iZpl.API.shared.PlayListItem;
+import de.nplusc.izc.iZpl.API.PlaybackPlugin;
+import de.nplusc.izc.iZpl.API.shared.SinglePlayListItem;
+import de.nplusc.izc.izpl.plugins.wmp.api2.ClassFactory;
+import de.nplusc.izc.izpl.plugins.wmp.api2.IWMPPlayer4;
+import de.nplusc.izc.izpl.plugins.wmp.api2.events._WMPOCXEvents;
+/**
+ *
+ * @author iZc <nplusc.de>
+ */
+public class WMPNAtive implements PlaybackPlugin
+{
+    
+    
+    private boolean playing;
+    private boolean isMulti=false;
+    private SinglePlayListItem currentTrack;
+    private PlayListItem currentPlaying;
+    private _WMPOCXEvents eventCatcher;
+    private int multiElementProgress = -0;
+    private SinglePlayListItem[] multiItemStorage = null;
+    @Override
+    public void setTitleToPlay(PlayListItem i)
+    {
+        if(i instanceof SinglePlayListItem)
+        {
+            currentPlaying=i;
+            String fp = ((SinglePlayListItem)i).getPath();
+            playerAccess.url(fp);
+            IZPLApi.getUIPlugin().setTrackName(((SinglePlayListItem)i).getTitle().split(",")[1]);
+            currentTrack=(SinglePlayListItem) i;
+        }
+        else
+        {
+                multiElementProgress=0;
+                multiItemStorage = ((MultiPlayListItem)i).getSinglePlayListElements();
+                currentTrack=multiItemStorage[0];
+                playerAccess.url(multiItemStorage[0].getPath());
+                multiElementProgress++;
+        }
+    }
+
+    @Override
+    public int getLengthInSeconds()
+    {
+       return (int)playerAccess.currentMedia().duration();
+    }
+
+    @Override
+    public int getPosition()
+    {
+        return (int)playerAccess.controls().currentPosition();
+    }
+
+    @Override
+    public void seek(int sekunde)
+    {
+        playerAccess.controls().currentPosition(sekunde);
+    }
+
+    @Override
+    public void skipTitle()
+    {
+        if(!isMulti)
+        {
+            IZPLApi.playNextTrack();
+        }
+        else
+        {
+            if(multiElementProgress==multiItemStorage.length-1)
+            {
+                isMulti=false;
+            }
+            currentTrack=multiItemStorage[multiElementProgress++];
+            playerAccess.url(currentTrack.getPath());
+        }
+        new Thread(() ->
+        {
+            try
+            {
+                Thread.sleep(100);
+                playerAccess.controls().play();
+            }
+            catch (InterruptedException ex)
+            {
+                ex.printStackTrace();
+            }
+        }).start();
+    }
+
+    @Override
+    public void play()
+    {
+        if(!playing)
+            playerAccess.controls().play();
+        playing=true;
+    }
+
+    @Override
+    public void pause()
+    {
+        if(playing)
+            playerAccess.controls().pause();
+        playing=false;
+    }
+
+    @Override
+    public PlayListItem getCurrentTitle()
+    {
+        return currentPlaying;
+        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    
+    IWMPPlayer4 playerAccess;
+    private boolean isPlaying;
+
+    public void setIsPlaying(boolean isPlaying)
+    {
+        this.isPlaying = isPlaying;
+    }
+    
+    
+    @Override
+    public void connectToPlayer()
+    {
+        eventCatcher = new _WMPOCXEvents();
+        playerAccess = ClassFactory.createWindowsMediaPlayer();
+        playerAccess.advise(_WMPOCXEvents.class, eventCatcher);
+        Thread t = new Thread(()->{
+            while(true)
+            {
+                if(isPlaying)
+                {
+                    IZPLApi.getUIPlugin().setPlaybackPositionInSeconds((int) playerAccess.controls().currentPosition());
+                }
+                try
+                {
+                    Thread.sleep(1000);
+                }
+                catch (InterruptedException ex)
+                {
+                    ex.printStackTrace();
+                }
+            }
+        });
+        t.setDaemon(true);
+        t.start();
+    }
+
+    @Override
+    public String getPluginName()
+    {
+        return "WMP ActiveX Interface";
+    }
+
+    @Override
+    public void initializePlugin()
+    {
+        
+    }
+
+    @Override
+    public void prepareUpgrade()
+    {
+        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+    
+}

+ 1 - 0
iZplPlugins/rtsslink/.gitignore

@@ -0,0 +1 @@
+auxy

+ 19 - 0
iZplPlugins/rtsslink/build.gradle

@@ -0,0 +1,19 @@
+apply plugin:'java'
+task distZip(dependsOn: 'jar') {
+	//NO-OPtask als redirect
+}
+
+
+
+
+
+compileJava.options.encoding = 'UTF-8'
+dependencies
+{
+	compile fileTree(dir: 'lib', include: '*.jar')
+	compile project(':iZpl')
+   
+
+}
+
+

+ 106 - 0
iZplPlugins/rtsslink/src/main/java/de/nplusc/izc/izpl/plugins/rtss/RTSSLink.java

@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2017 iZc
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package de.nplusc.izc.izpl.plugins.rtss;
+
+import com.sun.jna.Native;
+import com.sun.jna.NativeLibrary;
+import de.nplusc.izc.iZpl.API.IZPLApi;
+import de.nplusc.izc.iZpl.API.PlaybackStatusPlugin;
+import de.nplusc.izc.tools.baseTools.Detectors;
+import de.nplusc.izc.tools.baseTools.OutputStreamBridge;
+import de.nplusc.izc.tools.baseTools.Tools;
+import de.schlichtherle.truezip.file.TFile;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Arrays;
+import javax.swing.JTextArea;
+import org.apache.commons.io.output.NullOutputStream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author iZc <nplusc.de>
+ */
+public class RTSSLink implements PlaybackStatusPlugin
+{
+    private PrintStream target=null;
+    private static final Logger l = LogManager.getLogger();
+    private static String jarschiv = RTSSLink.class.getProtectionDomain().getCodeSource().getLocation().getPath();
+    @Override
+    public void updateTrackTitle(String title)
+    {
+       int maxlen = title.length();
+       if(maxlen>50)
+       {
+           maxlen=50;
+       }
+       target.println("IZPL: "+title.toUpperCase().substring(0,maxlen ));
+       target.flush();
+    }
+
+    @Override
+    public String getPluginName()
+    {
+        return "RTSS Overlay DIsplay";
+    }
+
+    @Override
+    public void initializePlugin()
+    {
+        OutputStreamBridge bridge = new OutputStreamBridge();
+        Tools.runCmdStreamable(new JTextArea(), new PrintStream(new NullOutputStream()), false, null, bridge, true, 
+                IZPLApi.PLUGINPATH+File.separator+"RTSSLink"+File.separator+"binaries"+File.separator+"RTSSLink.exe");
+        if(bridge.s==null)
+        {
+            l.error("Subsystem load failure");
+            IZPLApi.quickQuitWithoutSaving();
+        }
+        target = new PrintStream(bridge.s);
+    }
+
+    @Override
+    public void prepareUpgrade()
+    {
+                String[] osmetadata = Detectors.getSystemClassification();
+        l.info("Os-data:"+Arrays.toString(osmetadata));
+        if (osmetadata[0].equals("windows"))
+        {
+            
+            File target = new File(IZPLApi.PLUGINPATH+File.separator+"RTSSLink"+File.separator+"binaries");
+            target.getParentFile().mkdirs();
+            if (!target.exists())
+            {
+                TFile zippo = new TFile(jarschiv + "\\binaries\\rtssdotnet-" + osmetadata[1]);
+                try
+                {
+                    zippo.cp_rp(target);
+                    TFile jarschcrap = new TFile(jarschiv + "\\binaries\\");
+                    jarschcrap.rm_r();//removal of the embedded RTSSdotnet data after connecting to the System
+                }
+                catch (IOException ex)
+                {
+                    ex.printStackTrace();
+                }
+
+            }
+
+        }
+    }
+    
+}

BIN=BIN
iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x64/RTSSLink.exe


+ 6 - 0
iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x64/RTSSLink.exe.config

@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
+    </startup>
+</configuration>

BIN=BIN
iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x64/RTSSSharedMemoryNET.dll


BIN=BIN
iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x86/RTSSLink.exe


+ 6 - 0
iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x86/RTSSLink.exe.config

@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
+    </startup>
+</configuration>

BIN=BIN
iZplPlugins/rtsslink/src/main/resources/binaries/rtssdotnet-x86/RTSSSharedMemoryNET.dll


+ 8 - 0
iZplPlugins/rtsslink/src/main/resources/plugin.yml

@@ -0,0 +1,8 @@
+pluginbaseclass: de.nplusc.izc.izpl.plugins.rtss.RTSSLink
+supportedoses:
+  - 'windows'
+# can be windows, mac or linux
+supportedarchitectures:
+  - 'x86'
+  - 'x64'
+# x86 or x64 valid

+ 3 - 3
settings.gradle

@@ -1,3 +1,3 @@
-include 'ToolKit','iZpl',  'IZSetup','WPCMgr','UpidTK', 'izstreamer', 'LogBlockHeatMapper','iZlaunch',
-'iZpaqSFX','MazeViewer','TWPUtil',"iZplPlugins:WMP","iZplPlugins:foobar2000_others","iZplPlugins:itunes","iZplPlugins:GameRadio",
-"iZplPlugins:Editor","izpl-shared","iZpl-server","iZplPlugins:Smartphonizer","QuickStuff","external:java-progressbar"
+include 'ToolKit','iZpl',  'IZSetup','WPCMgr','UpidTK', 'izstreamer', 'LogBlockHeatMapper','iZlaunch',
+'iZpaqSFX','MazeViewer','TWPUtil',"iZplPlugins:WMP","iZplPlugins:foobar2000_others","iZplPlugins:itunes","iZplPlugins:GameRadio",
+"iZplPlugins:Editor","izpl-shared","iZpl-server","iZplPlugins:Smartphonizer","QuickStuff","external:java-progressbar","iZplPlugins:rtsslink"