Java Code Examples for org.eclipse.core.runtime.Platform#getOS()

The following examples show how to use org.eclipse.core.runtime.Platform#getOS() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvPath.java    From typescript.java with MIT License 6 votes vote down vote up
/** Creates a OS-Dependent LineCommand to set the Path-Variable. */
public static LineCommand createSetPathCommand(String path) {
	String os = Platform.getOS();
	String command = null;
	switch (os) {
	case Platform.OS_WIN32:
		command = "SET " + path;
		break;
	case Platform.OS_LINUX:
	case Platform.OS_MACOSX:
		command = "export " + path;
		break;
	//case Platform.OS_AIX:
	//case Platform.OS_SOLARIS:
	//case Platform.OS_HPUX:
	//case Platform.OS_QNX:
	default:
		// Verification needed
		command = "export " + path;
		break;
	}
	return new LineCommand(command);
}
 
Example 2
Source File: Util.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Gets the platform name: windows, mac, or linux.
 */
public static String getPlatformName() {
  String os = Platform.getOS();
  if (Platform.OS_WIN32.equals(os)) {
    return PLATFORM_WINDOWS;
  }
  if (Platform.OS_MACOSX.equals(os)) {
    return PLATFORM_MAC;
  }
  if (Platform.OS_LINUX.equals(os)) {
    return PLATFORM_LINUX;
  }

  // If it's not one of the official GWT-supported platforms, just return the
  // the platform name as reported to us by Eclipse
  return os;
}
 
Example 3
Source File: InitializeLaunchConfigurations.java    From wildwebdeveloper with Eclipse Public License 2.0 5 votes vote down vote up
private static String getDefaultNodePath() {
	switch (Platform.getOS()) {
		case Platform.OS_MACOSX:
			return "/usr/local/bin/node";
		case Platform.OS_WIN32:
			return "C:\\Program Files\\nodejs\\node.exe";
		default:
			return "/usr/bin/node";
	}
}
 
Example 4
Source File: PortValidator.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isUnix ()
{
    final String os = Platform.getOS ();
    if ( Platform.OS_WIN32.equals ( os ) )
    {
        return false;
    }
    return true;
}
 
Example 5
Source File: AbstractOsPreferences.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Gets the platform specific preferences object from the specified
 * preferences for the current operating system (the OS we are running under).
 * If the OS cannot be determined or its specific preferences are not
 * implemented, the platform specific preferences for Linux are returned as a
 * fall-back.
 *
 * @return the platform specific or fall-back preferences
 */
public static AbstractOsPreferences extractOsPreferences(
    CMakePreferences prefs) {
  final String os = Platform.getOS();
  if (Platform.OS_WIN32.equals(os)) {
    return prefs.getWindowsPreferences();
  } else {
    // fall back to linux, if OS is unknown
    return prefs.getLinuxPreferences();
  }
}
 
Example 6
Source File: BrowserManager.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Initialize
 */
private void init( )
{
	// Find all available browsers
	browsersDescriptors = createBrowserDescriptors( );

	// 1. set default browser from preferences
	String defBrowserID = ViewerPlugin.getDefault( )
			.getPluginPreferences( )
			.getDefaultString( DEFAULT_BROWSER_ID_KEY );

	if ( defBrowserID != null && ( !"".equals( defBrowserID ) ) ) //$NON-NLS-1$
	{
		setDefaultBrowserID( defBrowserID );
	}

	// 2. set default browser to embedded
	if ( defaultBrowserDesc == null )
	{
		setDefaultBrowserID( BROWSER_ID_EMBEDDED );
	}

	// 3. set default browser to help implementation of system specific
	// browser
	String os = Platform.getOS( );

	if ( defaultBrowserDesc == null )
	{
		if ( Constants.WS_WIN32.equalsIgnoreCase( os ) )
		{
			// Win32 uses system browser
			setDefaultBrowserID( BROWSER_ID_SYSTEM );
		}
	}

	// 4. set browser to one of externally contributed
	if ( defaultBrowserDesc == null )
	{
		for ( int i = 0; i < browsersDescriptors.length; i++ )
		{
			if ( BROWSER_ID_CUSTOM.equals( browsersDescriptors[i].getID( ) ) )
			{
				defaultBrowserDesc = browsersDescriptors[i];
			}
		}
	}

	// 5. let user specify program
	if ( defaultBrowserDesc == null )
	{
		setDefaultBrowserID( BROWSER_ID_CUSTOM );
	}

	// initialize current browser
	String curBrowserID = ViewerPlugin.getDefault( )
			.getPluginPreferences( )
			.getString( DEFAULT_BROWSER_ID_KEY );

	if ( curBrowserID != null && ( !"".equals( curBrowserID ) ) ) //$NON-NLS-1$
	{
		setCurrentBrowserID( curBrowserID );
		// may fail if such browser does not exist
	}

	if ( currentBrowserDesc == null )
	{
		setCurrentBrowserID( getDefaultBrowserID( ) );
	}

	setAlwaysUseExternal( ViewerPlugin.getDefault( )
			.getPluginPreferences( )
			.getBoolean( ALWAYS_EXTERNAL_BROWSER_KEY ) );
}
 
Example 7
Source File: EclipsePlatform.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public String getOS( )
{
	return Platform.getOS( );
}