/** * Determines if this platform is an instance of the platform family name. * * @param name the platform family name * @return {@code true} if the platform is an instance of <tt>name</tt> */ public boolean isA(Name name) { return isA(this.name, name); }
/** * Constructs a {@code FileQueueFactory}. * * @param platform the current platform * @param librarian the librarian */ public FileQueueFactory(Platform platform, Librarian librarian) { supportsQueue = platform.isA(Platform.Name.WINDOWS); this.librarian = librarian; }
private String getJavaCommand(String[] args) { String java; boolean console = false; if(args.length > 0) { console = true; } if (platform.isA(WINDOWS)) { if (console) { java = "java.exe"; } else { java = "javaw.exe"; } } else { java = "java"; } return System.getProperty("java.home") + File.separator + "bin" + File.separator + java; }
/** * Returns the command to launch java on the current platform. * * @return the command. This will be fully qualified if the command is found */ public static String getJavaCommand() { String executable = "java"; if (OsVersion.PLATFORM.isA(WINDOWS) || OsVersion.PLATFORM.isA(OS_2)) { executable += ".exe"; } String dir = new File(JAVA_HOME + "/bin").getAbsolutePath(); File exe = new File(dir, executable); if (!exe.exists()) { // if java.home isn't pointing to the correct location, assume java is somewhere on the PATH. return executable; } return exe.getAbsolutePath(); }
private void setInstallDriveFromPath(String path, String variable) { if (getPlatform().isA(WINDOWS)) { String[] parts = path.trim().split(":", 2); if (parts.length > 0 && parts[0].length() == 1) { setVariable(variable, parts[0] + ":"); } } }
/** * Determines if the current name is an instance of the specified platform family name. * * @param current the current name * @param name the plaform family name * @return {@code true} if current is an instance of <tt>name</tt> */ private boolean isA(Name current, Name name) { if (name == current) { return true; } else { for (Name parent : current.getParents()) { if (isA(parent, name)) { return true; } } } return false; }
/** * Normalize a path. Compresses consecutive file separators and replace the "~" with the users * home directory if installation is being run on a UNIX platform. * * @param path path to normalize * @return normalized path */ public static String normalizePath(String path) { if (path == null) { return ""; } else if (path.startsWith("~") && installData.getPlatform().isA(Platform.Name.UNIX)) { String home = System.getProperty("user.home"); path = home + path.substring(1); } return new File(path).getAbsolutePath(); } }
if (platform.isA(WINDOWS))
public int relaunchWithElevatedRights(String ... args) throws Exception { if(!platform.isA(WINDOWS)) { throw new Exception("Installer should be run as admin"); } String javaCommand = getJavaCommand(args); String installer = getInstallerJar(); ProcessBuilder builder = new ProcessBuilder(getElevator(javaCommand, installer, args)); if (logger.isLoggable(Level.INFO)) { logger.info("Relaunching: " + StringTool.listToString(builder.command(), " ")); } builder.environment().put("izpack.mode", "privileged"); Process process = builder.start(); return process.waitFor(); }
if (installData.getPlatform().isA(Platforms.WINDOWS))
if (platform.isA(Platforms.WINDOWS))
if (platform.isA(WINDOWS))
/** * Creates a condition to determine if the current platform is that specified. * * @param conditionId the condition identifier * @param current the current platform * @param platform the platform to compare against */ private void createPlatformCondition(String conditionId, Platform current, Platform platform) { boolean isA = current.isA(platform); // create a condition that simply returns the isA value. This condition doesn't need to be serializable Condition condition = new StaticCondition(isA); condition.setInstallData(installData); condition.setId(conditionId); conditionsMap.put(condition.getId(), condition); }
if (platform.isA(Platform.Name.WINDOWS))
/** * Determines if a platform is more specific than the current fallback platform. * * @param requested the requested platform * @param fallback the current fallback platform * @param platform the platform to check. * @return <tt>true</tt> if <tt>platform</tt> is a <tt>fallback</tt> or has the same version as that requested * and the fallback doesn't specify a version */ private boolean moreSpecific(Platform requested, Platform fallback, Platform platform) { boolean result = platform.isA(fallback); if (!result) { if (requested.getVersion() != null && requested.getVersion().equals(platform.getVersion()) && fallback.getVersion() == null) { result = true; } } return result; }
/** * Determines if this platform is an instance of another. * * @param platform the platform to compare against * @return {@code true} if the platform is an instance of <tt>platform</tt> */ public boolean isA(Platform platform) { boolean result = false; if (isA(platform.name) && hasSymbolicName(platform.symbolicName) && hasArch(platform.arch) && hasVersion(platform.version) && hasJavaVersion(platform.javaVersion)) { result = true; } return result; }
for (Platform.Name name : runOn.value()) if (platform.isA(name))
/** * Helper to format a message to create shortcuts for the current platform. * * @return a formatted message */ public String getCreateShortcutsPrompt() { Messages messages = installData.getMessages(); String menuKind = messages.get("ShortcutPanel.regular.StartMenu:Start-Menu"); if (installData.getPlatform().isA(UNIX) && UnixHelper.kdeIsInstalled()) { menuKind = messages.get("ShortcutPanel.regular.StartMenu:K-Menu"); } return StringTool.replace(messages.get("ShortcutPanel.regular.create"), "StartMenu", menuKind); }