- fix problem with upgrader

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10133 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 6b7daa4af1
commit 0a6c41cb1c
  1. 13
      sdk/jme3-core/src/com/jme3/gde/core/Installer.java
  2. 28
      sdk/jme3-upgrader/src/com/jme3/gde/upgrader/Upgrader.java
  3. 9
      sdk/jme3-upgrader/src/org/netbeans/upgrade/AutoUpgrade.java

@ -32,9 +32,11 @@
package com.jme3.gde.core;
import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.upgrader.Upgrader;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPopupMenu;
import org.netbeans.upgrade.AutoUpgrade;
import org.openide.filesystems.FileChooserBuilder;
import org.openide.modules.ModuleInstall;
import org.openide.util.Exceptions;
@ -47,6 +49,8 @@ import org.openide.util.NbPreferences;
*/
public class Installer extends ModuleInstall {
private static final Logger logger = Logger.getLogger(Installer.class.getName());
@Override
public boolean closing() {
SceneApplication.getApplication().stop();
@ -68,8 +72,9 @@ public class Installer extends ModuleInstall {
String projectDir = NbPreferences.forModule(Installer.class).get("projects_path", null);
if (projectDir == null) {
try {
AutoUpgrade.main(new String[]{});
NbPreferences.root().sync();
Upgrader.checkUpgrade();
NbPreferences.forModule(Installer.class).sync();
logger.log(Level.INFO, "Synced settings");
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
@ -90,12 +95,14 @@ public class Installer extends ModuleInstall {
}
}
//netbeans.default_userdir_root
logger.log(Level.INFO, "Set project dir {0}", projectDir);
System.setProperty("netbeans.projects.dir", projectDir);
//set extraction dir for platform natives
String jmpDir = System.getProperty("netbeans.user");
File file = new File(jmpDir);
if (!file.exists()) {
logger.log(Level.INFO, "Create settings dir {0}", projectDir);
file.mkdirs();
}
com.jme3.system.Natives.setExtractionDir(jmpDir);

@ -0,0 +1,28 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.upgrader;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.upgrade.AutoUpgrade;
import org.openide.util.Exceptions;
/**
*
* @author normenhansen
*/
public class Upgrader {
private static final Logger logger = Logger.getLogger(Upgrader.class.getName());
public static void checkUpgrade(){
try {
logger.log(Level.INFO, "Start upgrade..");
AutoUpgrade.main(new String[0]);
logger.log(Level.INFO, "Finished upgrade.");
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
}

@ -49,6 +49,7 @@ import java.net.URL;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
@ -126,18 +127,20 @@ public final class AutoUpgrade {
private static File checkPreviousOnOsSpecificPlace (final List<String> versionsToCheck) {
String defaultUserdirRoot = System.getProperty ("netbeans.default_userdir_root"); // NOI18N
//normen: to test in ide
if(defaultUserdirRoot==null){
if(defaultUserdirRoot == null){
try {
defaultUserdirRoot = new File(System.getProperty("netbeans.user")).getParentFile().getCanonicalPath();
} catch (IOException ex) {
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
LOGGER.log(Level.INFO, "determined userdir root of {0}", defaultUserdirRoot);
File sourceFolder;
if (defaultUserdirRoot != null) {
File userHomeFile = new File (defaultUserdirRoot);
for (String ver : versionsToCheck) {
sourceFolder = new File (userHomeFile.getAbsolutePath (), ver);
LOGGER.log(Level.INFO, "Look for {0} ", userHomeFile);
if (sourceFolder.exists () && sourceFolder.isDirectory ()) {
return sourceFolder;
}
@ -157,7 +160,7 @@ public final class AutoUpgrade {
while (it.hasNext () && sourceFolder == null) {
ver = it.next ();
sourceFolder = new File (userHomeFile.getAbsolutePath (), ver);
LOGGER.log(Level.INFO, "Look for previous {0} ", userHomeFile);
if (sourceFolder.isDirectory ()) {
break;
}

Loading…
Cancel
Save