当前位置: 首页>>代码示例>>Java>>正文


Java OsVersion类代码示例

本文整理汇总了Java中com.izforge.izpack.util.OsVersion的典型用法代码示例。如果您正苦于以下问题:Java OsVersion类的具体用法?Java OsVersion怎么用?Java OsVersion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OsVersion类属于com.izforge.izpack.util包,在下文中一共展示了OsVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaultPath

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
String getDefaultPath(AutomatedInstallData idata) {
	String chosenPath = "";
	if (idata.getVariable(getVariableName()) != null) {
		chosenPath = idata.getVariable(getVariableName());
	} else {
		if (OsVersion.IS_WINDOWS)	{
			chosenPath = idata.getVariable(getVariableName()+".windows");
		}
		if (OsVersion.IS_OSX)	{
			chosenPath = idata.getVariable(getVariableName()+".mac");
		} else {
			if (OsVersion.IS_UNIX)	{
				chosenPath = idata.getVariable(getVariableName()+".unix");
			}
		}
	}
	VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
	chosenPath = vs.substitute(chosenPath, null);
	return chosenPath;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:21,代码来源:DerbyPathPanel.java

示例2: isElevationNeeded

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
/**
 * Checks if the current user is an administrator or not.
 *
 * @return <code>true</code> if elevation is needed to have administrator permissions, <code>false</code> otherwise.
 */
public boolean isElevationNeeded()
{
    if (vetoed)
    {
        return false;
    }

    if (OsVersion.IS_WINDOWS)
    {
        return !isPrivilegedMode() && !canWriteToProgramFiles();
    }
    else
    {
        return !System.getProperty("user.name").equals("root");
    }
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:22,代码来源:PrivilegedRunner.java

示例3: itemRequiredForOs

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
/**
 * Verifies if an item is required for the operating system the installer executed. The
 * configuration for this feature is: <br/>
 * &lt;os family="unix"/&gt; <br>
 * <br>
 * <b>Note:</b><br>
 * If the list of the os is empty then <code>true</code> is always returnd.
 *
 * @param os The <code>Vector</code> of <code>String</code>s. containing the os names
 * @return <code>true</code> if the item is required for the os, otherwise returns
 * <code>false</code>.
 */
public boolean itemRequiredForOs(Vector<IXMLElement> os)
{
    if (os.size() == 0) { return true; }

    for (int i = 0; i < os.size(); i++)
    {
        String family = (os.elementAt(i)).getAttribute(FAMILY);
        boolean match = false;

        if ("windows".equals(family))
        {
            match = OsVersion.IS_WINDOWS;
        }
        else if ("mac".equals(family))
        {
            match = OsVersion.IS_OSX;
        }
        else if ("unix".equals(family))
        {
            match = OsVersion.IS_UNIX;
        }
        if (match) { return true; }
    }
    return false;
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:38,代码来源:UserInputPanelConsoleHelper.java

示例4: isWriteable

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
/**
 * This method determines whether the chosen dir is writeable or not.
 * 
 * @return whether the chosen dir is writeable or not
 */
private static boolean isWriteable(File path)
{
    File existParent = IoHelper.existingParent(path);
    if (existParent == null) { return false; }

    // On windows we cannot use canWrite because
    // it looks to the dos flags which are not valid
    // on NT or 2k XP or ...
    if (OsVersion.IS_WINDOWS)
    {
        File tmpFile;
        try
        {
            tmpFile = File.createTempFile("izWrTe", ".tmp", existParent);
            tmpFile.deleteOnExit();
        }
        catch (IOException e)
        {
            Debug.trace(e.toString());
            return false;
        }
        return true;
    }
    return existParent.canWrite();
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:31,代码来源:DirInputField.java

示例5: getKdeApplinkFolderName

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
/**
 * Gets the name of the applink folder for the currently used distribution. Currently
 * "applnk-redhat for RedHat, "applnk-mdk" for Mandrake, and simply "applnk" for all others.
 * 
 * @return result
 */
private String getKdeApplinkFolderName()
{
    String applinkFolderName = "applnk";

    if (OsVersion.IS_REDHAT_LINUX)
    {
        applinkFolderName = "applnk-redhat";
    }

    if (OsVersion.IS_MANDRAKE_LINUX)
    {
        applinkFolderName = "applnk-mdk";
    }

    return applinkFolderName;
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:23,代码来源:Unix_Shortcut.java

示例6: TigaseJDKPathPanel

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
/**
 * The constructor.
 *
 * @param parent The parent window.
 * @param idata  The installation data.
 */
public TigaseJDKPathPanel(InstallerFrame parent, InstallData idata)
{
    super(parent, TigaseInstallerCommon.init(idata));
    setMustExist(true);
    if (!OsVersion.IS_OSX)
    {
        setExistFiles(TigaseJDKPathPanel.testFiles);
    }
    setMinVersion(idata.getVariable("JDKPathPanel.minVersion"));
    setMaxVersion(idata.getVariable("JDKPathPanel.maxVersion"));
    setVariableName("JDKPath");

   
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:21,代码来源:TigaseJDKPathPanel.java

示例7: getDBUri

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
private String getDBUri(VariablesSource variablesSource) {
	String db_uri = "jdbc:";
	String database = getUserDB(variablesSource);
	Debug.trace("getDBUri | database: "  +database);
	if (database.equals("pgsql")) {
		db_uri += "postgresql:";
	} else if (database.equals("sqlserver")) {
		db_uri += "jtds:sqlserver:";
	} else {
		db_uri += database + ":";
	}
	if (database.equals("derby")) {
		String derby_path = variablesSource.getVariable("DerbyDBPath");
		if (OsVersion.IS_WINDOWS) {
			derby_path = derby_path.replace("\\", "\\\\");
		}
		db_uri += derby_path;
	} else if ( database.equals( "sqlserver" ) ){
		db_uri += "//" + variablesSource.getVariable("dbHost");
		db_uri += ";databaseName=" + variablesSource.getVariable("dbName");
		db_uri += ";user=" + variablesSource.getEncodedVariable("dbUser");
		if ( variablesSource.getEncodedVariable( "dbPass" ) != null
				 && !variablesSource.getEncodedVariable( "dbPass" ).isEmpty() ){
			db_uri += ";password=" + variablesSource.getEncodedVariable( "dbPass" );
		}
		db_uri += ";schema=dbo";
		db_uri += ";lastUpdateCount=false";
		db_uri += ";cacheMetaData=false";
	} else {
		db_uri += "//" + variablesSource.getVariable("dbHost");
		db_uri += "/" + variablesSource.getVariable("dbName");
		db_uri += "?user=" + variablesSource.getEncodedVariable("dbUser");
		if (variablesSource.getEncodedVariable("dbPass") != null
			&& !variablesSource.getEncodedVariable("dbPass").isEmpty()) {
			db_uri += "&password=" + variablesSource.getEncodedVariable("dbPass");
		}
	}
	return db_uri;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:40,代码来源:TigaseConfigSavePanel.java

示例8: getElevator

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
private List<String> getElevator(String javaCommand, String installer) throws IOException, InterruptedException
{
    List<String> elevator = new ArrayList<String>();

    if (OsVersion.IS_OSX)
    {
        elevator.add(extractMacElevator().getCanonicalPath());
        elevator.add(javaCommand);
        elevator.add("-jar");
        elevator.add(installer);
    }
    else if (OsVersion.IS_UNIX)
    {
        elevator.add("xterm");
        elevator.add("-title");
        elevator.add("Installer");
        elevator.add("-e");
        elevator.add("sudo");
        elevator.add(javaCommand);
        elevator.add("-jar");
        elevator.add(installer);
    }
    else if (OsVersion.IS_WINDOWS)
    {
        elevator.add("wscript");
        elevator.add(extractVistaElevator().getCanonicalPath());
        elevator.add(javaCommand);
        elevator.add("-Dizpack.mode=privileged");
        elevator.add("-jar");
        elevator.add(installer);
    }

    return elevator;
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:35,代码来源:PrivilegedRunner.java

示例9: getJavaExecutable

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
private String getJavaExecutable()
{
    if (OsVersion.IS_WINDOWS)
    {
        return "javaw.exe";
    }
    else
    {
        return "java";
    }
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:12,代码来源:PrivilegedRunner.java

示例10: JDKPathPanel

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
/**
 * The constructor.
 *
 * @param parent The parent window.
 * @param idata  The installation data.
 */
public JDKPathPanel(InstallerFrame parent, InstallData idata)
{
    super(parent, idata);
    setMustExist(true);
    if (!OsVersion.IS_OSX)
    {
        setExistFiles(JDKPathPanel.testFiles);
    }
    setMinVersion(idata.getVariable("JDKPathPanel.minVersion"));
    setMaxVersion(idata.getVariable("JDKPathPanel.maxVersion"));
    setVariableName("JDKPath");
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:19,代码来源:JDKPathPanel.java

示例11: hyperlinkUpdate

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent e) {
    try {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) 
            {
                String urls = e.getURL().toExternalForm();
                // if the link points to a chapter in the same page
                // don't open a browser
                if (urls.contains("HTMLInfoPanel.info#")) 
                    {
                        textArea.setPage(e.getURL());
                    } else {
                    if (com.izforge.izpack.util.OsVersion.IS_OSX) 
                        {
                            Runtime.getRuntime().exec("open " + urls);
                        } else if (com.izforge.izpack.util.OsVersion.IS_UNIX) 
                        {
                            String[] launchers = {"htmlview QqzURL", "xdg-open QqzURL"
                                                  , "gnome-open QqzURL", "kfmclient openURL QqzURL"
                                                  , "call-browser QqzURL", "firefox QqzURL"
                                                  , "opera QqzURL", "konqueror QqzURL"
                                                  , "epiphany QqzURL", "mozilla QqzURL", "netscape QqzURL"};                         
                            //String launchers = "/bin/sh -c \"htmlview QqzURL || xdg-open QqzURL || gnome-open QqzURL || kfmclien$
                            for (String launcher : launchers) 
                                {
                                    
                                    try 
                                        {
                                            Runtime.getRuntime().exec(launcher.replaceAll("QqzURL", urls));
                                            System.out.println("OK");
                                            break;
                                        } catch (Exception ignore) {
                                        System.out.println(launcher + " NOT OK");
                                    }
                                }
                        } else 
                        {
                            Runtime.getRuntime().exec("cmd /C start " + urls);
                        }
                }
            }
    } catch (Exception err) 
        {
            // no action
        }
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:46,代码来源:TigaseJDKPathPanel.java

示例12: addExtension

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
private static String addExtension(String command)
{
    // This is the most common extension case - exe for windows and OS/2,
    // nothing for *nix.
    return command + (OsVersion.IS_WINDOWS || OsVersion.IS_OS2 ? ".exe" : "");
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:7,代码来源:SelfModifier.java

示例13: elevationShouldBeInvestigated

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
private static boolean elevationShouldBeInvestigated()
{
    return (Uninstaller.class.getResource("/exec-admin") != null) ||
            (OsVersion.IS_WINDOWS && !(new PrivilegedRunner().canWriteToProgramFiles()));
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:6,代码来源:Uninstaller.java

示例14: run

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
/**
 * The run method.
 */
public void run()
{
    try
    {
        // We get the list of uninstaller listeners
        List[] listeners = getListenerLists();
        // We get the list of the files to delete
        ArrayList<ExecutableFile> executables = getExecutablesList();

        FileExecutor executor = new FileExecutor(executables);
        executor.executeFiles(ExecutableFile.UNINSTALL, this.handler);

        ArrayList<File> files = getFilesList();
        int size = files.size();

        // Custem action listener stuff --- beforeDeletion ----
        informListeners(listeners[0], UninstallerListener.BEFORE_DELETION, files, handler);

        handler.startAction("destroy", size);

        // We destroy the files
        for (int i = 0; i < size; i++)
        {
            File file = files.get(i);
            // Custem action listener stuff --- beforeDelete ----
            informListeners(listeners[1], UninstallerListener.BEFORE_DELETE, file, handler);

            file.delete();

            // Custem action listener stuff --- afterDelete ----
            informListeners(listeners[1], UninstallerListener.AFTER_DELETE, file, handler);

            handler.progress(i, file.getAbsolutePath());
        }

        // Custem action listener stuff --- afterDeletion ----
        informListeners(listeners[0], UninstallerListener.AFTER_DELETION, files, handler);

        if (OsVersion.IS_UNIX)
        {
            ArrayList<String> rootScripts = getRootScripts(); 
            Iterator<String> rsi = rootScripts.iterator();
            while (rsi.hasNext())
            {
              execRootScript((String) rsi.next() );                    
            }
            
        }
        // We make a complementary cleanup
        handler.progress(size, "[ cleanups ]");
        cleanup(new File(installPath));

        handler.stopAction();
    }
    catch (Throwable err)
    {
        handler.stopAction();
        err.printStackTrace();

        StringWriter trace = new StringWriter();
        err.printStackTrace(new PrintWriter(trace));

        handler.emitError("exception caught", trace.toString());
    }
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:69,代码来源:Destroyer.java

示例15: panelActivate

import com.izforge.izpack.util.OsVersion; //导入依赖的package包/类
/**
 * Called when the panel becomes active.
 */
public void panelActivate()
{
    // Resolve the default for chosenPath
    super.panelActivate();
    String chosenPath;
    // The variable will be exist if we enter this panel
    // second time. We would maintain the previos
    // selected path.
    if (idata.getVariable(getVariableName()) != null)
    {
        chosenPath = idata.getVariable(getVariableName());
    }
    else
    {
        if (OsVersion.IS_OSX)
        {
            chosenPath = OSX_JDK_HOME;
        }
        else
        {
            // Try the JAVA_HOME as child dir of the jdk path
            chosenPath = (new File(idata.getVariable("JAVA_HOME"))).getParent();
        }
    }
    // Set the path for method pathIsValid ...
    pathSelectionPanel.setPath(chosenPath);

    if (!pathIsValid() || !verifyVersion())
    {
        chosenPath = resolveInRegistry();
        if (!pathIsValid() || !verifyVersion())
        {
            chosenPath = "";
        }
    }
    // Set the default to the path selection panel.
    pathSelectionPanel.setPath(chosenPath);
    String var = idata.getVariable("JDKPathPanel.skipIfValid");
    // Should we skip this panel?
    if (chosenPath.length() > 0 && var != null && "yes".equalsIgnoreCase(var))
    {
        idata.setVariable(getVariableName(), chosenPath);
        parent.skipPanel();
    }

}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:50,代码来源:JDKPathPanel.java


注:本文中的com.izforge.izpack.util.OsVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。