/*
 * Copyright (C) 2009-2013, Free University of Bozen Bolzano
 * This source code is available under the terms of the Affero General Public
 * License v3.
 * 
 * Please see LICENSE.txt for full license terms, including the availability of
 * proprietary exceptions.
 */
package it.unibz.krdb.obda.protege4.gui.action;

import it.unibz.krdb.obda.owlrefplatform.owlapi3.QuestOWL;

import java.awt.event.ActionEvent;

import javax.swing.JOptionPane;

import org.protege.editor.core.ui.action.ProtegeAction;
import org.protege.editor.owl.OWLEditorKit;
import org.protege.editor.owl.model.OWLModelManager;
import org.protege.editor.owl.model.OWLWorkspace;
import org.semanticweb.owlapi.reasoner.OWLReasoner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class InconsistencyCheckAction extends ProtegeAction {
	
	private static final long serialVersionUID = 1L;
	private OWLEditorKit editorKit = null;
	private OWLWorkspace workspace;	
	private OWLModelManager modelManager;
	
	private Logger log = LoggerFactory.getLogger(AboxMaterializationAction.class);
	
	@Override
	public void initialise() throws Exception {
		editorKit = (OWLEditorKit)getEditorKit();
		workspace = editorKit.getWorkspace();	
		modelManager = editorKit.getOWLModelManager();
	}

	@Override
	public void dispose() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		OWLReasoner reasoner = modelManager.getOWLReasonerManager().getCurrentReasoner();
		if (reasoner instanceof QuestOWL) {
			try {
				QuestOWL questReasoner = (QuestOWL) reasoner;
				boolean isConsistent = questReasoner.isQuestConsistent();
				if (isConsistent) {
					JOptionPane.showMessageDialog(workspace, "Your ontology is consistent! Great job!");
				} else {
					JOptionPane.showMessageDialog(workspace, "Your ontology is not consistent. The axiom creating inconsistency is: "
							+questReasoner.getInconsistentAxiom().toString());
				}
				
			}catch(Exception ex){
				JOptionPane.showMessageDialog(workspace, "An error occured. For more info, see the logs.");
				log.error("Error during inconsistency checking. \n"+ex.getMessage()+"\n"+ex.getLocalizedMessage());
			}
		}
	}

}

@@ -1,6 +1,86 @@
-/*
+package it.unibz.krdb.obda.protege4.gui.action;%0A%0A/*%0A * #%25L%0A * ontop-protege4%0A * %25%25
 %0A * 
@@ -101,14 +101,37 @@
 2009
--
+ - 
 2013
-,
+ KRDB Research Centre.
  Fre
@@ -163,89 +163,182 @@
 zano
+.
 %0A * 
-This source code is available under the terms of the Affero General Public%0A *
+%25%25%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the
  Lic
@@ -346,19 +346,18 @@
 nse 
-v3.
+at
 %0A * %0A * 
 Plea
@@ -356,163 +356,391 @@
 %0A * 
-Please see LICENSE.txt for full license terms, including the availability of%0A * proprietary exceptions.%0A */%0Apackage it.unibz.krdb.obda.protege4.gui.action;
+     http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * #L%25%0A */
 %0A%0Aim

change header of new file