public static void setWordWrap(IEditorPart editor, boolean state) {
        if (editor == null) {
            return;
        }

        // editor (IEditorPart) adapter returns StyledText
        Object text = editor.getAdapter(Control.class);
        if (text instanceof StyledText) {
            StyledText styledText = (StyledText) text;

            // set wrapping
            styledText.setWordWrap(state);
        }
    }