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 java.awt.event.ActionEvent;
024    import java.awt.event.ActionListener;
025    
026    /**
027     * Wizard panel descriptor that provides saving ontology and going back to class choose panel.
028     * @author Lorenz Buehmann
029     *
030     */
031    public class SavePanelDescriptor extends WizardPanelDescriptor implements ActionListener{
032            public static final String IDENTIFIER = "SAVE_PANEL";
033        public static final String INFORMATION = "Press 'Save and exit' button to save the changes you made and exit the program, " +
034                                                     "or 'Save and choose another class' button to save the changes and go back to class choose panel.";
035    
036        private SavePanel savePanel;
037        
038        public SavePanelDescriptor() {
039            savePanel = new SavePanel();
040            
041            savePanel.addActionListeners(this);
042            
043            setPanelDescriptorIdentifier(IDENTIFIER);
044            setPanelComponent(savePanel);
045            
046        }
047        
048        @Override
049            public Object getNextPanelDescriptor() {
050            return FINISH;
051        }
052        
053        @Override
054            public void aboutToDisplayPanel() {
055            getWizard().getInformationField().setText(INFORMATION);
056        }    
057        
058        @Override
059            public Object getBackPanelDescriptor() {
060            return "REPAIR_PANEL";
061        }
062    
063            @Override
064            public void actionPerformed(ActionEvent e) {
065                    if(e.getActionCommand().equals("Save and go to class choose panel")){
066                            getWizardModel().getOre().getModifier().saveOntology();
067                            getWizard().setCurrentPanel(ClassPanelOWLDescriptor.IDENTIFIER);
068                    }else if(e.getActionCommand().equals("Save and Exit")){
069                            getWizardModel().getOre().getModifier().saveOntology();
070                            getWizard().close(0);
071                    }
072    
073                    
074            }
075        
076         
077    }