package jav.gui.wizard.newProject;
import java.util.ResourceBundle;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor;
import org.openide.util.ChangeSupport;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
/**
*Copyright (c) 2012, IMPACT working group at the Centrum für Informations- und Sprachverarbeitung, University of Munich.
*All rights reserved.
*Redistribution and use in source and binary forms, with or without
*modification, are permitted provided that the following conditions are met:
*Redistributions of source code must retain the above copyright
*notice, this list of conditions and the following disclaimer.
*Redistributions in binary form must reproduce the above copyright
*notice, this list of conditions and the following disclaimer in the
*documentation and/or other materials provided with the distribution.
*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
*IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
*TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
*PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
*HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
*SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
*LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
*DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
*THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the ocr-postcorrection tool developed
* by the IMPACT working group at the Centrum für Informations- und Sprachverarbeitung, University of Munich.
* For further information and contacts visit http://ocr.cis.uni-muenchen.de/
*
* @author thorsten (thorsten.vobl@googlemail.com)
*/
public class NewProjectWizardPanel3 implements WizardDescriptor.Panel<WizardDescriptor>, ChangeListener {
/**
* The visual component that displays this panel. If you need to access the
* component from this class, just use getComponent().
*/
private NewProjectVisualPanel3 view = null;
private WizardDescriptor model = null;
private ResourceBundle bundle = NbBundle.getBundle(NewProjectWizardPanel3.class);
private boolean isValid = false;
private ChangeSupport changeSupport = new ChangeSupport(this);
// Get the visual component for the panel. In this template, the component
// is kept separate. This can be more efficient: if the wizard is created
// but never displayed, or not all panels are displayed, it is better to
// create only those which really need to be visible.
@Override
public NewProjectVisualPanel3 getComponent() {
if (view == null) {
view = new NewProjectVisualPanel3(this);
view.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(3));
view.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
view.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
view.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
}
return view;
}
public String getName() {
return bundle.getString("Panel3.Name");
}
@Override
public HelpCtx getHelp() {
// Show no Help button for this panel:
return HelpCtx.DEFAULT_HELP;
// If you have context help:
// return new HelpCtx(SampleWizardPanel1.class);
}
@Override
public boolean isValid() {
return isValid;
}
@Override
public void readSettings(WizardDescriptor data) {
this.model = data;
}
@Override
public void storeSettings(WizardDescriptor data) {
model.putProperty("Configuration", getComponent().getConfiguration());
}
private void setMessage(String message) {
model.putProperty("WizardPanel_errorMessage", message);
}
@Override
public void addChangeListener(ChangeListener cl) {
changeSupport.addChangeListener(cl);
}
@Override
public void removeChangeListener(ChangeListener cl) {
changeSupport.removeChangeListener(cl);
}
@Override
public void stateChanged(ChangeEvent ce) {
if (getComponent().getConfiguration().equals("")) {
setMessage(bundle.getString("Panel3.Error1"));
} else {
isValid = true;
setMessage(null);
changeSupport.fireChange();
}
}
}