@Override
    public void earlyStartup() {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

                // get preference store of this plugin
                IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();

                // check auto word wrap on startup
                if (preferenceStore.getBoolean("de.cdhq.eclipse.wordwrap.autoenable.onstartup")) {
                    WordWrapUtils.setWordWrapInWindow(workbenchWindow, true);
                }

                // auto word wrap: listen to opening of editors events  
                if (workbenchWindow != null) {
                    workbenchWindow.getPartService().addPartListener(new IPartListener2() {
                        @Override
                        public void partVisible(IWorkbenchPartReference partRef) {
                        }

                        @Override
                        public void partOpened(IWorkbenchPartReference partRef) {
                            // a new part was opened: hand over part reference to word wrap handler
                            ActivateOnFileOpenHandler.handleFileOpenEvent(partRef);
                        }

                        @Override
                        public void partInputChanged(IWorkbenchPartReference partRef) {
                        }

                        @Override
                        public void partHidden(IWorkbenchPartReference partRef) {
                        }

                        @Override
                        public void partDeactivated(IWorkbenchPartReference partRef) {
                        }

                        @Override
                        public void partClosed(IWorkbenchPartReference partRef) {
                        }

                        @Override
                        public void partBroughtToTop(IWorkbenchPartReference partRef) {
                        }

                        @Override
                        public void partActivated(IWorkbenchPartReference partRef) {
                        }
                    });
                }
            }
        });
    }