if (prefs.getProveJdic()){ //wenn nicht ausgestellt
AssociationService as = new AssociationService();
if (as.getFileExtensionAssociation ("jm3") == null){ //noch nicht registriert
int x = new MyDialog (null, resource.getString("nojdic"), resource.getString("warning")).showDialog(); //Nochmal nachfragen
if (x == MyDialog.DONTSHOW){ //"Nicht wieder anzeigen"
prefs.setProveJdic(false);
}else if (x == MyDialog.CONTINUE){
try {
File startbat = new File ("JMind.bat"); //Batchdatei
BufferedWriter bw = new BufferedWriter (new FileWriter (startbat));
File chosen = new File (System.getProperty("user.dir"));
bw.write("@echo off"); //Datei schreiben
bw.newLine();
bw.write(chosen.getAbsolutePath().substring(0, 2));
bw.newLine();
bw.write("cd " + chosen.getAbsolutePath());
bw.newLine();
String javahome = System.getProperty("java.home", "");
String filesep = File.separator;
bw.write ("START " + javahome + filesep + "bin" + filesep + "javaw.exe -jar jMindMap3D.jar " + ((args.length != 0 && args[0].equals("-debug")) ? "-debug" : "") + "%1");
bw.close(); //Batchdatei fertig
Association jm3 = new Association ();
jm3.addFileExtension ("jm3");
org.jdesktop.jdic.filetypes.Action jm3Action = new org.jdesktop.jdic.filetypes.Action ("open", startbat.getAbsolutePath() + " \"%1\"", "Open jMindMap3D"); //eintrag zur Batchdatei
jm3.addAction (jm3Action);
InputStream is = ClassLoader.getSystemResourceAsStream("icon.ico"); //icon entpacken
OutputStream os = new FileOutputStream ("jMindMapIcon.ico");
byte[] buf = new byte[512];
int len;
while ((len = is.read(buf)) >= 0){
os.write(buf, 0, len);
}
is.close();
os.close(); //icon entpackt
jm3.setIconFileName (new File ("jMindMapIcon.ico").getAbsolutePath()); //icon setzen
as.registerSystemAssociation (jm3); //fertigstellen
}catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
ex.printStackTrace();
}
}
}
}