1 19 20 package org.netbeans.modules.apisupport.project.ui.platform; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.HashSet ; 25 import java.util.Iterator ; 26 import java.util.Set ; 27 import org.netbeans.modules.apisupport.project.Util; 28 import org.netbeans.modules.apisupport.project.ui.ModuleUISettings; 29 import org.netbeans.modules.apisupport.project.ui.UIUtil; 30 import org.netbeans.modules.apisupport.project.universe.NbPlatform; 31 import org.openide.NotifyDescriptor; 32 import org.openide.util.Mutex; 33 import org.openide.util.NbBundle; 34 35 40 class HarnessUpgrader { 41 42 private HarnessUpgrader() {} 43 44 public static void checkForUpgrade() { 45 if (ModuleUISettings.getDefault().getHarnessesUpgraded()) { 46 return; 47 } 48 ModuleUISettings.getDefault().setHarnessesUpgraded(true); 49 final Set <NbPlatform> toUpgrade = new HashSet (); 50 Iterator it = NbPlatform.getPlatforms().iterator(); 51 while (it.hasNext()) { 52 NbPlatform p = (NbPlatform) it.next(); 53 if (p.isDefault() && !p.isValid()) { 54 continue; 55 } 56 if (p.getHarnessVersion() >= NbPlatform.HARNESS_VERSION_50u1) { 57 continue; 58 } 59 if (!p.getHarnessLocation().equals(p.getBundledHarnessLocation())) { 60 continue; 62 } 63 toUpgrade.add(p); 64 } 65 if (!toUpgrade.isEmpty()) { 66 Mutex.EVENT.readAccess(new Runnable () { 67 public void run() { 68 promptForUpgrade(toUpgrade); 69 } 70 }); 71 } 72 } 73 74 private static void promptForUpgrade(Set <NbPlatform> platforms) { 75 if (UIUtil.showAcceptCancelDialog( 76 NbBundle.getMessage(HarnessUpgrader.class, "HarnessUpgrader.title"), 77 NbBundle.getMessage(HarnessUpgrader.class, "HarnessUpgrader.text"), 78 NbBundle.getMessage(HarnessUpgrader.class, "HarnessUpgrader.upgrade"), 79 NbBundle.getMessage(HarnessUpgrader.class, "HarnessUpgrader.skip"), 80 NotifyDescriptor.QUESTION_MESSAGE)) { 81 try { 82 doUpgrade(platforms); 83 } catch (IOException e) { 84 Util.err.notify(e); 85 } 86 } 87 } 88 89 private static void doUpgrade(Set <NbPlatform> platforms) throws IOException { 90 File defaultHarness = NbPlatform.getDefaultPlatform().getHarnessLocation(); 91 Iterator it = platforms.iterator(); 92 while (it.hasNext()) { 93 NbPlatform p = (NbPlatform) it.next(); 94 p.setHarnessLocation(defaultHarness); 95 } 96 } 97 98 } 99 | Popular Tags |