001    /**
002     * Copyright (C) 2007-2008, Jens Lehmann
003     *
004     * This file is part of DL-Learner.
005     * 
006     * DL-Learner is free software; you can redistribute it and/or modify
007     * it under the terms of the GNU General Public License as published by
008     * the Free Software Foundation; either version 3 of the License, or
009     * (at your option) any later version.
010     *
011     * DL-Learner is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014     * GNU General Public License for more details.
015     *
016     * You should have received a copy of the GNU General Public License
017     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018     *
019     */
020    
021    package org.dllearner.tools.ore;
022    
023    import javax.swing.event.ListSelectionEvent;
024    
025    
026    import org.dllearner.core.owl.NamedClass;
027    
028    
029    
030    /**
031     * Wizard panel descriptor for selecting one of the atomic classes in OWL-ontology that 
032     * has to be (re)learned.
033     * @author Lorenz Buehmann
034     *
035     */
036    public class ClassPanelOWLDescriptor extends WizardPanelDescriptor implements javax.swing.event.ListSelectionListener{
037        
038            /**
039             * Identification string for class choose panel.
040             */
041        public static final String IDENTIFIER = "CLASS_CHOOSE_OWL_PANEL";
042        /**
043         * Information string for class choose panel.
044         */
045        public static final String INFORMATION = "In this panel all atomic classes in the ontology are shown in the list above. " 
046                                                                                     + "Select one of them which should be (re)learned from, then press \"Next-Button\"";
047        
048        private ClassPanelOWL owlClassPanel;
049        
050        /**
051         * Constructor creates new panel and adds listener to list.
052         */
053        public ClassPanelOWLDescriptor() {
054            owlClassPanel = new ClassPanelOWL();
055            owlClassPanel.addSelectionListener(this);
056                 
057            setPanelDescriptorIdentifier(IDENTIFIER);
058            setPanelComponent(owlClassPanel);
059          
060        }
061        
062        @Override
063            public Object getNextPanelDescriptor() {
064            return LearningPanelDescriptor.IDENTIFIER;
065        }
066        
067        @Override
068            public Object getBackPanelDescriptor() {
069            return KnowledgeSourcePanelDescriptor.IDENTIFIER;
070        }
071        
072        @Override
073            public void aboutToDisplayPanel() {
074            getWizard().getInformationField().setText(INFORMATION);
075            setNextButtonAccordingToConceptSelected();
076        }
077        
078        /**
079         * Method is called when other element in list is selected, and sets next button enabled.
080         * @param e ListSelectionEvent
081         */
082            public void valueChanged(ListSelectionEvent e) {
083                    setNextButtonAccordingToConceptSelected(); 
084                    if (!e.getValueIsAdjusting()) {
085                             getWizardModel().getOre().setClassToLearn((NamedClass) owlClassPanel.getList().getSelectedValue());
086                    }
087            }
088            
089            private void setNextButtonAccordingToConceptSelected() {
090            
091            if (owlClassPanel.getList().getSelectedValue()!= null){
092                    getWizard().setNextFinishButtonEnabled(true);
093            }else{
094                    getWizard().setNextFinishButtonEnabled(false);
095            }
096       
097        }
098            
099            /**
100             * Returns the JPanel with the GUI elements.
101             * @return extended JPanel
102             */
103            public ClassPanelOWL getOwlClassPanel() {
104                    return owlClassPanel;
105            }
106            
107            
108    
109            
110        
111       
112    
113        
114        
115    }