nl.cloudfarming.client.fleet.machine.wizard.MachineWizardPanel Maven / Gradle / Ivy
/**
* Copyright (C) 2008-2012 AgroSense Foundation.
*
* AgroSense is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* There are special exceptions to the terms and conditions of the GPLv3 as it is applied to
* this software, see the FLOSS License Exception
* .
*
* AgroSense is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AgroSense. If not, see .
*/
package nl.cloudfarming.client.fleet.machine.wizard;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeListener;
import nl.cloudfarming.client.util.swing.ASBodyPanel;
import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;
import org.openide.util.ImageUtilities;
import org.openide.windows.WindowManager;
/**
*
* @author Wytse Visser
*/
public abstract class MachineWizardPanel implements WizardDescriptor.FinishablePanel {
private JComponent component;
@Override
public JComponent getComponent() {
if (component == null) {
component = createComponent();
}
return component;
}
protected JComponent createComponent() {
return new WizardComponent();
}
@Override
public HelpCtx getHelp() {
return HelpCtx.DEFAULT_HELP;
}
@Override
public boolean isValid() {
return true;
}
@Override
public boolean isFinishPanel() {
return isValid();
}
@Override
public void addChangeListener(ChangeListener l) {
}
@Override
public void removeChangeListener(ChangeListener l) {
}
protected static ImageIcon getIcon() {
return ImageUtilities.loadImageIcon("nl/cloudfarming/client/fleet/vehicle/steering_wheel_332.png", true);
}
protected void setTitle(final String title) {
WindowManager.getDefault().invokeWhenUIReady(
new Runnable() {
@Override
public void run() {
((WizardComponent) getComponent()).setTitle(title);
}
});
}
protected abstract JPanel getVisual();
@Override
public abstract void readSettings(WizardDescriptor wiz);
@Override
public abstract void storeSettings(WizardDescriptor wiz);
private class WizardComponent extends JScrollPane {
private ASBodyPanel bodyPanel;
public WizardComponent() {
bodyPanel = new ASBodyPanel(getVisual());
bodyPanel.setIcon(getIcon());
super.setViewportView(bodyPanel);
}
public void setTitle(String title) {
bodyPanel.setTitle(title);
}
@Override
public String getName() {
return getVisual().getName();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy