Search in sources :

Example 1 with ExtensionClassLoader

use of net.sf.eclipsecs.core.util.ExtensionClassLoader in project eclipse-cs by checkstyle.

the class CheckstyleUIPlugin method start.

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    mQuickfixExtensionClassLoader = new ExtensionClassLoader(context.getBundle(), QUICKFIX_PROVIDER_EXT_PT_ID);
    // add listeners for the Check-On-Open support
    final IWorkbench workbench = getWorkbench();
    workbench.getDisplay().asyncExec(new Runnable() {

        @Override
        public void run() {
            IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
            for (IWorkbenchWindow window : windows) {
                if (window != null) {
                    // collect open editors and have then run against Checkstyle if
                    // appropriate
                    Collection<IWorkbenchPartReference> parts = new HashSet<>();
                    // add already opened files to the filter
                    // bugfix for 2923044
                    IWorkbenchPage[] pages = window.getPages();
                    for (IWorkbenchPage page : pages) {
                        IEditorReference[] editorRefs = page.getEditorReferences();
                        for (IEditorReference ref : editorRefs) {
                            parts.add(ref);
                        }
                    }
                    mPartListener.partsOpened(parts);
                    // remove listener first for safety, we don't want
                    // register the same listener twice accidently
                    window.getPartService().removePartListener(mPartListener);
                    window.getPartService().addPartListener(mPartListener);
                }
            }
            workbench.addWindowListener(mWindowListener);
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) ExtensionClassLoader(net.sf.eclipsecs.core.util.ExtensionClassLoader) Collection(java.util.Collection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 2 with ExtensionClassLoader

use of net.sf.eclipsecs.core.util.ExtensionClassLoader in project eclipse-cs by checkstyle.

the class CheckstylePlugin method start.

/**
 * {@inheritDoc}
 */
@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    mAddonExtensionClassLoader = new ExtensionClassLoader(context.getBundle(), ADDON_PROVIDER_EXT_PT_ID);
    try {
        // $NON-NLS-1$
        Logger checkstyleErrorLog = Logger.getLogger("com.puppycrawl.tools.checkstyle.ExceptionLog");
        checkstyleErrorLog.addHandler(new EclipseLogHandler(this));
        checkstyleErrorLog.setLevel(Level.ALL);
    } catch (Exception ioe) {
        CheckstyleLog.log(ioe);
    }
}
Also used : ExtensionClassLoader(net.sf.eclipsecs.core.util.ExtensionClassLoader) EclipseLogHandler(net.sf.eclipsecs.core.util.EclipseLogHandler) Logger(java.util.logging.Logger)

Aggregations

ExtensionClassLoader (net.sf.eclipsecs.core.util.ExtensionClassLoader)2 Collection (java.util.Collection)1 Logger (java.util.logging.Logger)1 EclipseLogHandler (net.sf.eclipsecs.core.util.EclipseLogHandler)1 IEditorReference (org.eclipse.ui.IEditorReference)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1