<commit_before>package org.semanticweb.ontop.protege4.core;

/*
 * #%L
 * ontop-protege4
 * %%
 * Copyright (C) 2009 - 2013 KRDB Research Centre. Free University of Bozen Bolzano.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.google.inject.Guice;
import com.google.inject.Injector;
import org.protege.editor.core.editorkit.EditorKit;
import org.protege.editor.core.editorkit.plugin.EditorKitHook;
import org.protege.editor.core.prefs.Preferences;
import org.protege.editor.core.prefs.PreferencesManager;
import org.protege.editor.owl.OWLEditorKit;
import org.semanticweb.ontop.injection.NativeQueryLanguageComponentFactory;
import org.semanticweb.ontop.injection.OBDACoreModule;
import org.semanticweb.ontop.injection.OBDAFactoryWithException;
import org.semanticweb.ontop.model.impl.OBDAModelImpl;
import org.semanticweb.ontop.owlrefplatform.core.QuestConstants;
import org.semanticweb.ontop.owlrefplatform.core.QuestPreferences;
import org.semanticweb.ontop.owlrefplatform.injection.QuestComponentModule;
import org.semanticweb.ontop.utils.OBDAPreferences;

/***
 * This class is responsible for initializing all base classes for the OBDA
 * plugin. In particular this class will register an instance of
 * OBDAPluginController and server preference holder objects into the current
 * EditorKit. These instances can be retrieved by other components (Tabs, Views,
 * Actions, etc) by doing EditorKit.get(key).
 * 
 * @author <NAME>
 * 
 */
public class OBDAEditorKitSynchronizerPlugin extends EditorKitHook {

	OBDAModelManager instance = null;
	OWLEditorKit kit = null;
//	OWLModelManager mmgr = null;
	ProtegeOBDAPreferences obdaPref = null;
	ProtegeReformulationPlatformPreferences refplatPref = null;
	
	@Override
	protected void setup(EditorKit editorKit) {
        super.setup(editorKit);
    } 
	
	@Override
	public void initialise() throws Exception {

        /***
         * Preferences for the OBDA plugin (gui, etc)
         */
        obdaPref = new ProtegeOBDAPreferences();
        getEditorKit().put(OBDAPreferences.class.getName(), obdaPref);

        /***
         * Preferences for Quest
         */
        refplatPref = new ProtegeReformulationPlatformPreferences();
        getEditorKit().put(QuestPreferences.class.getName(),refplatPref);
        loadPreferences();

        Injector injector = Guice.createInjector(new OBDACoreModule(refplatPref),
                new QuestComponentModule(refplatPref));

        NativeQueryLanguageComponentFactory nativeQLFactory = injector.getInstance(
                NativeQueryLanguageComponentFactory.class);

        OBDAFactoryWithException obdaFactoryWithException = injector.getInstance(
                OBDAFactoryWithException.class);
		
		/***
		 * Each editor kit has its own instance of the ProtegePluginController.
		 * Note, the OBDA model is inside this object (do
		 * .getOBDAModelManager())
		 */
		instance = new OBDAModelManager(this.getEditorKit(), nativeQLFactory,
                obdaFactoryWithException);
		getEditorKit().put(OBDAEditorKitSynchronizerPlugin.class.getName(), this);
		kit = (OWLEditorKit)getEditorKit();
//		mmgr = (OWLModelManager)kit.getModelManager();
//		mmgr.addListener(instance.getModelManagerListener());
		getEditorKit().put(OBDAModelImpl.class.getName(), instance);

		// getEditorKit().getModelManager().put(APIController.class.getName(),
		// instance);
	}
<commit_msg>The OBDAModelManager can now be accessed correctly though the editor kit.<commit_after>package org.semanticweb.ontop.protege4.core;

/*
 * #%L
 * ontop-protege4
 * %%
 * Copyright (C) 2009 - 2013 KRDB Research Centre. Free University of Bozen Bolzano.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.google.inject.Guice;
import com.google.inject.Injector;
import org.protege.editor.core.editorkit.EditorKit;
import org.protege.editor.core.editorkit.plugin.EditorKitHook;
import org.protege.editor.core.prefs.Preferences;
import org.protege.editor.core.prefs.PreferencesManager;
import org.protege.editor.owl.OWLEditorKit;
import org.semanticweb.ontop.injection.NativeQueryLanguageComponentFactory;
import org.semanticweb.ontop.injection.OBDACoreModule;
import org.semanticweb.ontop.injection.OBDAFactoryWithException;
import org.semanticweb.ontop.model.impl.OBDAModelImpl;
import org.semanticweb.ontop.owlrefplatform.core.QuestConstants;
import org.semanticweb.ontop.owlrefplatform.core.QuestPreferences;
import org.semanticweb.ontop.owlrefplatform.injection.QuestComponentModule;
import org.semanticweb.ontop.utils.OBDAPreferences;

/***
 * This class is responsible for initializing all base classes for the OBDA
 * plugin. In particular this class will register an instance of
 * OBDAPluginController and server preference holder objects into the current
 * EditorKit. These instances can be retrieved by other components (Tabs, Views,
 * Actions, etc) by doing EditorKit.get(key).
 * 
 * @author <NAME>
 * 
 */
public class OBDAEditorKitSynchronizerPlugin extends EditorKitHook {

	OBDAModelManager instance = null;
	OWLEditorKit kit = null;
//	OWLModelManager mmgr = null;
	ProtegeOBDAPreferences obdaPref = null;
	ProtegeReformulationPlatformPreferences refplatPref = null;
	
	@Override
	protected void setup(EditorKit editorKit) {
        super.setup(editorKit);
    } 
	
	@Override
	public void initialise() throws Exception {

        /***
         * Preferences for the OBDA plugin (gui, etc)
         */
        obdaPref = new ProtegeOBDAPreferences();
        getEditorKit().put(OBDAPreferences.class.getName(), obdaPref);

        /***
         * Preferences for Quest
         */
        refplatPref = new ProtegeReformulationPlatformPreferences();
        getEditorKit().put(QuestPreferences.class.getName(),refplatPref);
        loadPreferences();

        Injector injector = Guice.createInjector(new OBDACoreModule(refplatPref),
                new QuestComponentModule(refplatPref));

        NativeQueryLanguageComponentFactory nativeQLFactory = injector.getInstance(
                NativeQueryLanguageComponentFactory.class);

        OBDAFactoryWithException obdaFactoryWithException = injector.getInstance(
                OBDAFactoryWithException.class);
		
		/***
		 * Each editor kit has its own instance of the ProtegePluginController.
		 * Note, the OBDA model is inside this object (do
		 * .getOBDAModelManager())
		 */
		instance = new OBDAModelManager(this.getEditorKit(), nativeQLFactory,
                obdaFactoryWithException);
		getEditorKit().put(OBDAEditorKitSynchronizerPlugin.class.getName(), this);
		kit = (OWLEditorKit)getEditorKit();
//		mmgr = (OWLModelManager)kit.getModelManager();
//		mmgr.addListener(instance.getModelManagerListener());

		getEditorKit().put(OBDAModelManager.class.getName(), instance);
		/**
		 * TODO: Not sound!! remove it!!!
		 */
		getEditorKit().put(OBDAModelImpl.class.getName(), instance);

		// getEditorKit().getModelManager().put(APIController.class.getName(),
		// instance);
	}

{'fraction_non_alphanumeric': 0.0944804797454412, 'fraction_numerical': 0.0034267531513890587, 'mean_word_length': 4.133165829145729, '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': '5112514', 'n_tokens_mistral': 2413, 'n_tokens_neox': 2307, 'n_words': 581}