<commit_before>package isabelle.eclipse.ui.views;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import isabelle.Command;
import isabelle.Document.Snapshot;
import isabelle.Markup;
import isabelle.Session;
import isabelle.Session.Commands_Changed;
import isabelle.XML.Tree;
import isabelle.eclipse.core.text.DocumentModel;
import isabelle.eclipse.core.util.SafeSessionActor;
import isabelle.eclipse.ui.IsabelleEclipsePlugin;
import isabelle.eclipse.ui.editors.TheoryEditor;
import isabelle.eclipse.ui.util.SessionEventSupport;
import isabelle.scala.ISessionCommandsListener;
import isabelle.scala.SessionActor;
import isabelle.scala.SessionEventType;
import isabelle.scala.SnapshotUtil;

import org.apache.commons.lang.ObjectUtils;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.IPostSelectionProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.Page;
import org.osgi.framework.Bundle;

import scala.Option;
import scala.collection.JavaConversions;


public class ProverOutputPage extends Page {

	/*
	 * TODO implement for IE: http://www.quirksmode.org/dom/range_intro.html, http://help.dottoro.com/ljumcfud.php
	 */
	private static final String SELECT_ALL_JAVASCRIPT = "window.getSelection().selectAllChildren(document.body);";
	
	private final TheoryEditor editor;
	
	private Composite mainComposite;
	private Browser outputArea;
	private Command currentCommand;
	
	private ISelectionChangedListener editorListener;
	
	private boolean showTrace = false;
	private boolean followSelection = true;
	private int lastEditorCaretOffset = 0;
	
	private Job updateJob = new UpdateOutputJob(0, Collections.<Command>emptySet());
	private SessionEventSupport sessionEvents;
	
	public ProverOutputPage(TheoryEditor editor) {
		this.editor = editor;
		
		this.sessionEvents = new SessionEventSupport(EnumSet.of(SessionEventType.COMMAND)) {
			
			@Override
			protected SessionActor createSessionActor(Session session) {
				return new SafeSessionActor().commandsChanged(new ISessionCommandsListener() {
					@Override
					public void commandsChanged(Commands_Changed changed) {
						updateOutput(0L, lastEditorCaretOffset, JavaConversions.setAsJavaSet(changed.commands()));
					}
				});
			}
		};
	}

	@Override
	public void createControl(Composite parent) {
		mainComposite = new Composite(parent, SWT.NULL);
        mainComposite.setLayout(new FillLayout());
        
        outputArea = new Browser(mainComposite, SWT.NONE);
        outputArea.setText("Initialised output view");
	}

	@Override
	public Control getControl() {
		return mainComposite;
	}

	@Override
	public void init(IPageSite pageSite) {
		super.init(pageSite);
		
		editorListener = new ISelectionChangedListener() {

			@Override<commit_msg>removed test message about init<commit_after>package isabelle.eclipse.ui.views;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import isabelle.Command;
import isabelle.Document.Snapshot;
import isabelle.Markup;
import isabelle.Session;
import isabelle.Session.Commands_Changed;
import isabelle.XML.Tree;
import isabelle.eclipse.core.text.DocumentModel;
import isabelle.eclipse.core.util.SafeSessionActor;
import isabelle.eclipse.ui.IsabelleEclipsePlugin;
import isabelle.eclipse.ui.editors.TheoryEditor;
import isabelle.eclipse.ui.util.SessionEventSupport;
import isabelle.scala.ISessionCommandsListener;
import isabelle.scala.SessionActor;
import isabelle.scala.SessionEventType;
import isabelle.scala.SnapshotUtil;

import org.apache.commons.lang.ObjectUtils;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.IPostSelectionProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.Page;
import org.osgi.framework.Bundle;

import scala.Option;
import scala.collection.JavaConversions;


public class ProverOutputPage extends Page {

	/*
	 * TODO implement for IE: http://www.quirksmode.org/dom/range_intro.html, http://help.dottoro.com/ljumcfud.php
	 */
	private static final String SELECT_ALL_JAVASCRIPT = "window.getSelection().selectAllChildren(document.body);";
	
	private final TheoryEditor editor;
	
	private Composite mainComposite;
	private Browser outputArea;
	private Command currentCommand;
	
	private ISelectionChangedListener editorListener;
	
	private boolean showTrace = false;
	private boolean followSelection = true;
	private int lastEditorCaretOffset = 0;
	
	private Job updateJob = new UpdateOutputJob(0, Collections.<Command>emptySet());
	private SessionEventSupport sessionEvents;
	
	public ProverOutputPage(TheoryEditor editor) {
		this.editor = editor;
		
		this.sessionEvents = new SessionEventSupport(EnumSet.of(SessionEventType.COMMAND)) {
			
			@Override
			protected SessionActor createSessionActor(Session session) {
				return new SafeSessionActor().commandsChanged(new ISessionCommandsListener() {
					@Override
					public void commandsChanged(Commands_Changed changed) {
						updateOutput(0L, lastEditorCaretOffset, JavaConversions.setAsJavaSet(changed.commands()));
					}
				});
			}
		};
	}

	@Override
	public void createControl(Composite parent) {
		mainComposite = new Composite(parent, SWT.NULL);
        mainComposite.setLayout(new FillLayout());
        
        outputArea = new Browser(mainComposite, SWT.NONE);
//        outputArea.setText("Initialised output view");
	}

	@Override
	public Control getControl() {
		return mainComposite;
	}

	@Override
	public void init(IPageSite pageSite) {
		super.init(pageSite);
		
		editorListener = new ISelectionChangedListener() {

			@Override
{'fraction_non_alphanumeric': 0.09580838323353294, 'fraction_numerical': 0.000855431993156544, 'mean_word_length': 5.41811527904849, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1117389', 'n_tokens_mistral': 2220, 'n_tokens_neox': 2070, 'n_words': 409}