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

The following examples show how to use org.eclipse.core.runtime.Platform#getLog() . 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: ProblemReporter.java    From EasyMPermission with MIT License 6 votes vote down vote up
private void msg(int msgType, String message, Throwable error) {
	int ct = squelchTimeout != 0L ? 0 : counter.incrementAndGet();
	boolean printSquelchWarning = false;
	if (squelchTimeout != 0L) {
		long now = System.currentTimeMillis();
		if (squelchTimeout > now) return;
		squelchTimeout = now + SQUELCH_TIMEOUT;
		printSquelchWarning = true;
	} else if (ct >= MAX_LOG) {
		squelchTimeout = System.currentTimeMillis() + SQUELCH_TIMEOUT;
		printSquelchWarning = true;
	}
	ILog log = Platform.getLog(bundle);
	log.log(new Status(msgType, DEFAULT_BUNDLE_NAME, message, error));
	if (printSquelchWarning) {
		log.log(new Status(IStatus.WARNING, DEFAULT_BUNDLE_NAME, "Lombok has logged too many messages; to avoid memory issues, further lombok logs will be squelched for a while. Restart eclipse to start over."));
	}
}
 
Example 2
Source File: HybridUI.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;
	logger = Platform.getLog(this.getBundle());
	IPreferenceStore store = getPreferenceStore();
	HybridToolsPreferences.init(store);
	store.addPropertyChangeListener(new IPropertyChangeListener() {
		
		@Override
		public void propertyChange(PropertyChangeEvent event) {
			HybridToolsPreferences.getPrefs().loadValues(event);
			
		}
	});
	HybridToolsPreferences.getPrefs().loadValues();
	ResourcesPlugin.getWorkspace().addResourceChangeListener(projectRestoreListener, IResourceChangeEvent.POST_CHANGE);
	
}
 
Example 3
Source File: DocumentProvider.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Defines the standard procedure to handle <code>CoreExceptions</code>.
 * Exceptions are written to the plug-in log.
 * 
 * @param exception
 *            the exception to be logged
 * @param message
 *            the message to be logged
 */
protected void handleCoreException( CoreException exception, String message )
{

	Bundle bundle = Platform.getBundle( PlatformUI.PLUGIN_ID );
	ILog log = Platform.getLog( bundle );

	if ( message != null )
		log.log( new Status( IStatus.ERROR,
				PlatformUI.PLUGIN_ID,
				0,
				message,
				exception ) );
	else
		log.log( exception.getStatus( ) );
}
 
Example 4
Source File: EclipseLogAppender.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private synchronized void ensureInitialized() {
	if (!initialized) {
		if (!Platform.isRunning()) {
			LOGGER.warn(
					"You appear to be running outside Eclipse; you might want to remove the jar org.eclipse.xtext.logging*.jar from your classpath and supply your own log4j.properties.");
		} else {
			log = Platform.getLog(Platform.getBundle(LOG4J_BUNDLE_NAME));
		}
		initialized = true;
	}
}
 
Example 5
Source File: EclipseLogAppender.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private synchronized void ensureInitialized() {
	if (!initialized) {
		if (!Platform.isRunning()) {
			LOGGER.warn("You appear to be running outside Eclipse; you might want to remove the jar org.eclipse.xtext.logging*.jar from your classpath and supply your own log4j.properties.");
		} else {
			log = Platform.getLog(Platform.getBundle(LOG4J_BUNDLE_NAME));
		}
		initialized = true;
	}
}
 
Example 6
Source File: TestEditor.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
protected void validateState(final IEditorInput input) {

        final IDocumentProvider provider = getDocumentProvider();
        if (!(provider instanceof IDocumentProviderExtension))
            return;

        final IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;

        try {

            extension.validateState(input, getSite().getShell());

        } catch (final CoreException x) {
            final IStatus status = x.getStatus();
            if (status == null || status.getSeverity() != IStatus.CANCEL) {
                final Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
                final ILog log = Platform.getLog(bundle);
                log.log(x.getStatus());

                final Shell shell = getSite().getShell();
                final String title = "EditorMessages.Editor_error_validateEdit_title";
                final String msg = "EditorMessages.Editor_error_validateEdit_message";
                ErrorDialog.openError(shell, title, msg, x.getStatus());
            }
            return;
        }

        if (fSourceViewer != null)
            fSourceViewer.setEditable(isEditable());

    }
 
Example 7
Source File: AndroidCore.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
public void start(BundleContext context) throws Exception {
	AndroidCore.context = context;
	logger = Platform.getLog(getContext().getBundle());
	Hashtable<String,Object> props = new Hashtable<String, Object>();
	props.put(org.eclipse.osgi.service.debug.DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID);
	context.registerService(DebugOptionsListener.class.getName(), this, props);


}
 
Example 8
Source File: IOSCore.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
public void start(BundleContext bundleContext) throws Exception {
	IOSCore.context = bundleContext;
	logger = Platform.getLog(getContext().getBundle());
	Hashtable<String,Object> props = new Hashtable<String, Object>();
	props.put(org.eclipse.osgi.service.debug.DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID);
	context.registerService(DebugOptionsListener.class.getName(), this, props);

}
 
Example 9
Source File: HybridCore.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
public void start(BundleContext bundleContext) throws Exception {
	HybridCore.context = bundleContext;
	logger = Platform.getLog(getContext().getBundle());
	Hashtable<String,Object> props = new Hashtable<String, Object>();
	props.put(org.eclipse.osgi.service.debug.DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID);
	context.registerService(DebugOptionsListener.class.getName(), this, props);
	ResourcesPlugin.getWorkspace().addResourceChangeListener(derivedFoldersChangeListener, IResourceChangeEvent.POST_CHANGE);
}
 
Example 10
Source File: TestEditor.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
protected void validateState(IEditorInput input) {

		IDocumentProvider provider = getDocumentProvider();
		if (!(provider instanceof IDocumentProviderExtension))
			return;

		IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;

		try {

			extension.validateState(input, getSite().getShell());

		} catch (CoreException x) {
			IStatus status = x.getStatus();
			if (status == null || status.getSeverity() != IStatus.CANCEL) {
				Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
				ILog log = Platform.getLog(bundle);
				log.log(x.getStatus());

				Shell shell = getSite().getShell();
				String title = "EditorMessages.Editor_error_validateEdit_title";
				String msg = "EditorMessages.Editor_error_validateEdit_message";
				ErrorDialog.openError(shell, title, msg, x.getStatus());
			}
			return;
		}

		if (fSourceViewer != null)
			fSourceViewer.setEditable(isEditable());

	}
 
Example 11
Source File: EclipseStartup.java    From os-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void earlyStartup() {
    final Bundle bundle = Platform.getBundle(ID);
    logger = Platform.getLog(bundle);
    detect(new Properties(), Collections.<String>emptyList());
}
 
Example 12
Source File: WinCore.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
public void start(BundleContext bundleContext) throws Exception {
	WinCore.context = bundleContext;
	logger = Platform.getLog(getContext().getBundle());
}
 
Example 13
Source File: WPCore.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
public void start(BundleContext bundleContext) throws Exception {
	WPCore.context = bundleContext;
	logger = Platform.getLog(getContext().getBundle());
}
 
Example 14
Source File: Activator.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public ILog getLogger(){
    return Platform.getLog(Platform.getBundle(Activator.PLUGIN_ID));
}