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

The following examples show how to use org.eclipse.core.runtime.Platform#inDevelopmentMode() . 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: UsagePlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void stop(BundleContext context) throws Exception
{
	try
	{
		if (job != null)
		{
			job.shutdown(); // tell job to stop, clean up and send end event
			job = null;
		}
		if (!Platform.inDevelopmentMode())
		{
			AptanaDB.getInstance().shutdown();
		}
	}
	finally
	{
		fAnalyticsInfoManager = null;
		plugin = null;
		super.stop(context);
	}
}
 
Example 2
Source File: Constants.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public static String getOAuthClientId() {
  if (Platform.inDevelopmentMode()) {
    return System.getProperty("oauth.client.id", "(unset:oauth.client.id)");
  } else {
    return OAUTH_CLIENT_ID;
  }
}
 
Example 3
Source File: Constants.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public static String getOAuthClientSecret() {
  if (Platform.inDevelopmentMode()) {
    return System.getProperty("oauth.client.secret", "(unset:oauth.client.secret)");
  } else {
    return OAUTH_CLIENT_SECRET;
  }
}
 
Example 4
Source File: AnalyticsPingManager.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public static synchronized AnalyticsPingManager getInstance() {
  if (instance == null) {
    String collectionUrl = null;
    if (!Platform.inDevelopmentMode() && !Constants.FIRELOG_API_KEY.startsWith("@")) {
      collectionUrl = FIRELOG_COLLECTION_URL + "?key=" + Constants.FIRELOG_API_KEY;
    }
    instance = new AnalyticsPingManager(collectionUrl, AnalyticsPreferences.getPreferenceNode(),
        new ConcurrentLinkedQueue<PingEvent>());
  }
  return instance;
}
 
Example 5
Source File: StudioAnalytics.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void sendEvent(AnalyticsEvent event)
{
	if (Platform.inDevelopmentMode() && !EclipseUtil.isTesting())
	{
		return;
	}

	// Cascade the event to all the registered handlers.
	Set<IAnalyticsEventHandler> handlers = AnalyticsHandlersManager.getInstance().getHandlers();
	for (IAnalyticsEventHandler handler : handlers)
	{
		handler.sendEvent(event);
	}
}
 
Example 6
Source File: UsagePlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static void logError(String message)
{
	// Only logs analytics errors when in development
	if (Platform.inDevelopmentMode())
	{
		IdeLog.logError(getDefault(), message);
	}
}
 
Example 7
Source File: UsagePlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static void logError(Exception e)
{
	// Only logs analytics errors when in development
	if (Platform.inDevelopmentMode())
	{
		IdeLog.logError(getDefault(), e);
	}
}
 
Example 8
Source File: JSCAModel.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * log
 * 
 * @param message
 */
protected void log(String message)
{
	if (Platform.inDevelopmentMode())
	{
		System.out.println(message); // $codepro.audit.disable debuggingCode
	}
	else
	{
		IdeLog.logError(JSCorePlugin.getDefault(), message);
	}
}
 
Example 9
Source File: TestExtensionProject.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void testExtensionProjectClasspathDoesNotContainAbsoluteFile() throws JavaModelException {
    for (IClasspathEntry entry : RepositoryManager.getInstance().getCurrentRepository().getJavaProject()
            .getRawClasspath()) {
        if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
            File file = new File(entry.getPath().toString());
            if (file.exists() && file.isAbsolute() && !Platform.inDevelopmentMode()) {
                fail("Classpath should not contain absolute entry: " + entry.getPath().toString());
            }
        }
    }
}
 
Example 10
Source File: TargetPlatformUtil.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Sets the target platform for tests (to be used in tycho mainly)
 * @param context any class of the test bundle to be able to determine the test bundle
 * @since 2.14
 */
public static void setTargetPlatform(Class<?> context) throws Exception {
	if (isPdeLaunch()) {
		return;
	}
	Bundle currentBundle = FrameworkUtil.getBundle(context);
	ITargetPlatformService tpService = TargetPlatformService.getDefault();
	ITargetDefinition targetDef = tpService.newTarget();
	targetDef.setName("Tycho platform");
	Bundle[] bundles = Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles();
	List<ITargetLocation> bundleContainers = new ArrayList<ITargetLocation>();
	Set<File> dirs = new HashSet<File>();
	for (Bundle bundle : bundles) {
		if (bundle.equals(currentBundle)) {
			// we skip the current bundle, otherwise the folder for the target platform
			// will include the absolute directory of the maven parent project
			// since the projects are nested in the parent project the result
			// would be that Java packages of our project will be available twice
			// and Java won't be able to find our classes leading in compilation
			// errors during our tests.
			continue;
		}
		EquinoxBundle bundleImpl = (EquinoxBundle) bundle;
		Generation generation = (Generation) bundleImpl.getModule().getCurrentRevision().getRevisionInfo();
		File file = generation.getBundleFile().getBaseFile();
		File folder = file.getParentFile();
		if ((file.isFile() || Platform.inDevelopmentMode()) && !dirs.contains(folder)) {
			dirs.add(folder);
			bundleContainers.add(tpService.newDirectoryLocation(folder.getAbsolutePath()));
		}
	}
	targetDef.setTargetLocations(bundleContainers.toArray(new ITargetLocation[bundleContainers.size()]));
	targetDef.setArch(Platform.getOSArch());
	targetDef.setOS(Platform.getOS());
	targetDef.setWS(Platform.getWS());
	targetDef.setNL(Platform.getNL());
	// targetDef.setJREContainer()
	tpService.saveTargetDefinition(targetDef);

	Job job = new LoadTargetDefinitionJob(targetDef);
	job.schedule();
	job.join();
}
 
Example 11
Source File: DTDScanner.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * getToken
 * 
 * @return
 */
protected IToken getToken()
{
	IToken token = null;

	while (this._nestedScanners.size() > 0)
	{
		DTDParserScanner nestedScanner = this._nestedScanners.peek();

		token = nestedScanner.nextToken();

		if (token.isWhitespace() == false && token.getData() == null)
		{
			this._nestedScanners.pop();
			token = null;

			if (Platform.inDevelopmentMode())
			{
				int end = nestedScanner.getTokenOffset() + nestedScanner.getTokenLength();
				int length = nestedScanner.getDocument().getLength();

				if (end != length)
				{
					System.out.println("end = " + end + ", length = " + length); //$NON-NLS-1$ //$NON-NLS-2$
					System.out.println(nestedScanner.getDocument().get());
				}
			}
		}
		else
		{
			break;
		}
	}

	if (token == null)
	{
		token = this._sourceScanner.nextToken();
	}

	return token;
}
 
Example 12
Source File: AnalysisEngineLaunchConfigurationDelegate.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
   * Adds the launcher and uima core jar to the class path,
   * depending on normal mode or PDE development mode.
   */
  @Override
  public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
    
    // The class path already contains the jars which are specified in the Classpath tab
    
    List<String> extendedClasspath = new ArrayList<>();
    Collections.addAll(extendedClasspath, super.getClasspath(configuration));
    
    // Normal mode, add the launcher plugin and uima runtime jar to the classpath
    try {
      if (!Platform.inDevelopmentMode()) {     
        // Add this plugin jar to the classpath 
        extendedClasspath.add(pluginIdToJarPath(LauncherPlugin.ID)); }
      else {
        // When running inside eclipse with PDE in development mode the plugins
        // are not installed inform of jar files and the classes must be loaded
        // from the target/classes folder or target/org.apache.uima.runtime.*.jar file
        extendedClasspath.add(pluginIdToJarPath(LauncherPlugin.ID) + "target/classes");
      }
      // UIMA jar should be added the end of the class path, because user uima jars
      // (maybe a different version) should appear first on the class path

      // Add org.apache.uima.runtime jar to class path
      Bundle bundle = LauncherPlugin.getDefault().getBundle("org.apache.uima.runtime");
      
      // Ignore the case when runtime bundle does not exist ...
      if (bundle != null) {
        // find entries: starting point, pattern, whether or not to recurse
        //   all the embedded jars are at the top level, no recursion needed
        //   All the jars are not needed - only the uimaj core one
        //     any other jars will be provided by the launching project's class path
        //     uimaj-core provided because the launcher itself needs uimaj-core classes
        //  Found empirically that recursion is need to find the jar in development mode
        Enumeration<?> jarEnum = bundle.findEntries("/", "uimaj-core*.jar", Platform.inDevelopmentMode());
        while (jarEnum != null && jarEnum.hasMoreElements()) {
          URL element = (URL) jarEnum.nextElement();
          extendedClasspath.add(FileLocator.toFileURL(element).getFile());
        }
      }        
      // adds things like the top level metainf info, 
      // probably not required in most cases
      extendedClasspath.add(pluginIdToJarPath("org.apache.uima.runtime"));
    } catch (IOException e) {
      throw new CoreException(new Status(IStatus.ERROR, LauncherPlugin.ID, IStatus.OK, 
              "Failed to compose classpath!", e));
    }
    
    // Dump classpath
//    for (String cp : extendedClasspath) {
//      System.out.println("Uima Launcher CP entry: " + cp);
//    }
    return extendedClasspath.toArray(new String[extendedClasspath.size()]);
  }
 
Example 13
Source File: JDTEnvironmentUtils.java    From eclipse.jdt.ls with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Has no effect, and always returns with {@code false} if the JDT LS has been
 * started from the source either in debug or development mode. If the
 * {@code CLIENT_HOST} and {@code CLIENT_PORT} environment variables are set and
 * the {@link JDTEnvironmentUtils#SOCKET_STREAM_DEBUG socket.stream.debug} is
 * set to {@code true}, the the server will start with plain socket connection
 * and will wait until the client connects.
 */
public static boolean inSocketStreamDebugMode() {
	return Boolean.parseBoolean(Environment.get(SOCKET_STREAM_DEBUG, "false")) && (Platform.inDebugMode() || Platform.inDevelopmentMode()) && getClientHost() != null && getClientPort() != null;
}