ModeSel.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package de.nplusc.izc.InstallPak;
  6. import de.nplusc.izc.tools.IOtools.FileTK;
  7. import de.nplusc.izc.tools.UiToolz.BootStrap;
  8. import de.nplusc.izc.tools.UiToolz.UiTools;
  9. import de.nplusc.izc.tools.baseTools.Tools;
  10. import java.io.File;
  11. import java.lang.reflect.Field;
  12. import java.net.URISyntaxException;
  13. import javax.swing.UIManager;
  14. import javax.swing.UnsupportedLookAndFeelException;
  15. /**
  16. *
  17. * @author LH
  18. */
  19. public class ModeSel// extends javax.swing.JFrame
  20. {
  21. public static boolean silentMode=false;
  22. public static boolean packMode = false;
  23. public static String filePath = "";
  24. public static boolean isBundle = false;
  25. public static int topleft_coords_x = -1;//Detektion gegen diese Werte. -1=nicht initialisiert
  26. public static int topleft_coords_y = -1;//^
  27. private static String[] pargs;
  28. public static String[] getArgs()
  29. {
  30. return pargs;
  31. }
  32. /**
  33. * @param args the command line arguments
  34. */
  35. public static void main(String args[])
  36. {
  37. pargs=args;
  38. String libpath = "";
  39. try
  40. {
  41. //http://www.softicons.com/free-icons/application-icons/installer-icon-by-macuser64/installer-icon
  42. //http://www.iconfinder.com/icondetails/61818/128/box_icon
  43. //http://openclipart.org/detail/172351/ppa-icon-by-myromance123-172351
  44. //installs to C:\program files\iZsetup\
  45. //setDefauötPosition
  46. //852, 331
  47. //HAX_ALERT
  48. libpath = FileTK.getFilePath(new File(ModeSel.class.getProtectionDomain()
  49. .getCodeSource().getLocation().toURI().getPath()).getPath());
  50. }
  51. catch (URISyntaxException ex)
  52. {
  53. ex.printStackTrace();
  54. }
  55. System.setProperty( "java.library.path", libpath);
  56. Field fieldSysPath;
  57. try
  58. {
  59. fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
  60. fieldSysPath.setAccessible( true );
  61. fieldSysPath.set( null, null );
  62. }
  63. catch (NoSuchFieldException | SecurityException |IllegalAccessException ex)
  64. {
  65. ex.printStackTrace();
  66. }
  67. topleft_coords_x = (UiTools.getScreenRes()[0]/2)-(852/2);
  68. topleft_coords_y = (UiTools.getScreenRes()[1]/2)-(330/2);
  69. //args = new String[]{"-file",""
  70. for (int i = 0; i < args.length; i++)
  71. {
  72. System.err.println(i+"|"+args[i]);
  73. }
  74. //String file = "default.izsetup";
  75. //if(izsetupReader.getSysSpezSetupFile(file,true)!=null)
  76. //{
  77. // packMode=true;
  78. //}
  79. //DSAB_FOR_DBG
  80. //if(izsetupReader.getSysSpezSetupFile(file)==null&&!args[0].equals("-file"))
  81. //{
  82. // return;
  83. //}
  84. String file="";
  85. boolean enableFile = false;
  86. if(args.length>1)
  87. {
  88. //Tester.main(args);
  89. if(args[0].equals("-file"))
  90. {
  91. file=args[1];
  92. enableFile = true;
  93. //-file gamestls.izsetup --silent
  94. }
  95. if(args[0].equals("-bundle"))
  96. {
  97. file=args[1];
  98. isBundle = true;
  99. enableFile = true;
  100. //-file gamestls.izsetup --silent
  101. }
  102. else
  103. {
  104. isBundle=false;
  105. }
  106. for (String arg : args)
  107. {
  108. if(arg.equals("--silent"))
  109. {
  110. silentMode=true;
  111. //packMode=false;
  112. if(izsetupReader.getSysSpezSetupFile(file,true)!=null)
  113. {
  114. packMode=true;
  115. }
  116. else
  117. {
  118. packMode=false;
  119. }
  120. }
  121. if(arg.equals("--pack"))
  122. {
  123. packMode=true;
  124. }
  125. }
  126. }
  127. //DBG_START
  128. //silentMode=false;
  129. //packMode=false;
  130. if(!enableFile)
  131. {
  132. System.out.println("Usage help for iZsetup CLI");
  133. System.out.println("izsetup [-file|-bundle] <path> <options>");
  134. System.out.println("-file for izsetup or izpackage (requires --pack option to use izpackage");
  135. System.out.println("--pack file is packfile");
  136. System.out.println("--silent unattended mode");
  137. return;
  138. }
  139. // isBundle = true;
  140. //file="default.izbundle";
  141. //DBG_END
  142. Tools.DebugHelperPrint(file, true, "iZsetup.enableCoreDebug");
  143. Tools.DebugHelperPrint("isBundle+|+packMode+|+silentMode", true, "iZsetup.enableCoreDebug");
  144. Tools.DebugHelperPrint(isBundle+"|"+packMode+"|"+silentMode, true, "iZsetup.enableCoreDebug");
  145. if(!isBundle&&!packMode)
  146. {
  147. InstallManager.Main.setInstallScript(file);
  148. }
  149. filePath=file;
  150. try {
  151. UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
  152. } catch( ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e ) {
  153. //e.printStackTrace();
  154. }
  155. java.awt.EventQueue.invokeLater(new Runnable()
  156. {
  157. @SuppressWarnings("ResultOfObjectAllocationIgnored")
  158. @Override
  159. public void run()
  160. {
  161. System.err.println(packMode+"|"+silentMode);
  162. if(packMode&&!silentMode)
  163. {
  164. new BootStrap(new PackagerGUI());
  165. }
  166. else
  167. {
  168. if(silentMode)
  169. {
  170. if(!packMode)
  171. {
  172. InstallManager.Main.createQueue();
  173. new BootStrap(new InstallProgressGui());
  174. }
  175. else
  176. {
  177. PackManager p = new PackManager();
  178. p.loadPackageData(filePath);
  179. p.createQueue();
  180. new BootStrap(new InstallProgressGui(p.getQueue()));
  181. }
  182. }
  183. else
  184. {
  185. if(isBundle)
  186. {
  187. new BootStrap(new BundleVerifyGui(filePath));
  188. }
  189. else
  190. {
  191. new BootStrap(new ModeSelectionGUI());
  192. }
  193. }
  194. }
  195. }
  196. });
  197. }
  198. }