Fix AppearanceBuilder change listener removal
This commit is contained in:
parent
05a033dee4
commit
ab8fe16b62
@ -3,9 +3,6 @@ package net.sf.openrocket.gui.configdialog;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.awt.event.WindowListener;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
|
|
||||||
@ -61,7 +58,7 @@ import net.sf.openrocket.util.LineStyle;
|
|||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||||
|
|
||||||
public class AppearancePanel extends JPanel implements WindowListener {
|
public class AppearancePanel extends JPanel {
|
||||||
private static final long serialVersionUID = 2709187552673202019L;
|
private static final long serialVersionUID = 2709187552673202019L;
|
||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
@ -110,14 +107,7 @@ public class AppearancePanel extends JPanel implements WindowListener {
|
|||||||
|
|
||||||
private static final JColorChooser colorChooser = new JColorChooser();
|
private static final JColorChooser colorChooser = new JColorChooser();
|
||||||
|
|
||||||
@Override
|
public void clearConfigListeners() {
|
||||||
public void windowOpened(WindowEvent e) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowClosing(WindowEvent e) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowClosed(WindowEvent e) {
|
|
||||||
if (ab != null) {
|
if (ab != null) {
|
||||||
ab.clearConfigListeners();
|
ab.clearConfigListeners();
|
||||||
}
|
}
|
||||||
@ -126,18 +116,6 @@ public class AppearancePanel extends JPanel implements WindowListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowIconified(WindowEvent e) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowDeiconified(WindowEvent e) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowActivated(WindowEvent e) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowDeactivated(WindowEvent e) {}
|
|
||||||
|
|
||||||
private class ColorActionListener implements ActionListener {
|
private class ColorActionListener implements ActionListener {
|
||||||
private final String valueName;
|
private final String valueName;
|
||||||
private final Object o;
|
private final Object o;
|
||||||
|
@ -17,6 +17,7 @@ import net.sf.openrocket.l10n.Translator;
|
|||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.BugException;
|
import net.sf.openrocket.util.BugException;
|
||||||
@ -64,6 +65,7 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
|
|||||||
* In fact, it should trigger for any method of closing the dialog.
|
* In fact, it should trigger for any method of closing the dialog.
|
||||||
*/
|
*/
|
||||||
public void windowClosed(WindowEvent e){
|
public void windowClosed(WindowEvent e){
|
||||||
|
configurator.clearConfigListeners();
|
||||||
configurator.invalidate();
|
configurator.invalidate();
|
||||||
document.getRocket().removeComponentChangeListener(ComponentConfigDialog.this);
|
document.getRocket().removeComponentChangeListener(ComponentConfigDialog.this);
|
||||||
ComponentConfigDialog.this.dispose();
|
ComponentConfigDialog.this.dispose();
|
||||||
@ -231,9 +233,10 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
|
|||||||
*/
|
*/
|
||||||
public static void showDialog(Window parent, OpenRocketDocument document, RocketComponent component, boolean rememberPreviousTab) {
|
public static void showDialog(Window parent, OpenRocketDocument document, RocketComponent component, boolean rememberPreviousTab) {
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
// Don't remember the previous tab for stages, because this will leave you in the override tab for
|
// Don't remember the previous tab for rockets or stages, because this will leave you in the override tab for
|
||||||
// the next component, which is generally not what you want.
|
// the next component, which is generally not what you want.
|
||||||
if (dialog.getComponent() instanceof AxialStage && !(component instanceof AxialStage)) {
|
if (dialog.getComponent() instanceof Rocket ||
|
||||||
|
(dialog.getComponent() instanceof AxialStage && !(component instanceof AxialStage))) {
|
||||||
previousSelectedTab = null;
|
previousSelectedTab = null;
|
||||||
} else {
|
} else {
|
||||||
previousSelectedTab = dialog.getSelectedTabName();
|
previousSelectedTab = dialog.getSelectedTabName();
|
||||||
|
@ -66,6 +66,7 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
private final TextFieldListener textFieldListener;
|
private final TextFieldListener textFieldListener;
|
||||||
|
|
||||||
private JPanel buttonPanel;
|
private JPanel buttonPanel;
|
||||||
|
private AppearancePanel appearancePanel = null;
|
||||||
|
|
||||||
private JLabel infoLabel;
|
private JLabel infoLabel;
|
||||||
private StyledLabel multiCompEditLabel;
|
private StyledLabel multiCompEditLabel;
|
||||||
@ -125,7 +126,8 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
trans.get("RocketCompCfg.tab.MassandCGoverride"));
|
trans.get("RocketCompCfg.tab.MassandCGoverride"));
|
||||||
if (allMassive) {
|
if (allMassive) {
|
||||||
//// Appearance options
|
//// Appearance options
|
||||||
tabbedPane.addTab(trans.get("RocketCompCfg.tab.Appearance"), null, new AppearancePanel(document, component),
|
appearancePanel = new AppearancePanel(document, component);
|
||||||
|
tabbedPane.addTab(trans.get("RocketCompCfg.tab.Appearance"), null, appearancePanel,
|
||||||
"Appearance Tool Tip");
|
"Appearance Tool Tip");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +239,12 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
multiCompEditLabel.setText("");
|
multiCompEditLabel.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearConfigListeners() {
|
||||||
|
if (appearancePanel != null) {
|
||||||
|
appearancePanel.clearConfigListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected JPanel materialPanel(Material.Type type) {
|
protected JPanel materialPanel(Material.Type type) {
|
||||||
////Component material: and Component finish:
|
////Component material: and Component finish:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user