diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 6bb8e110b..14cbd57f9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -35,6 +35,8 @@ import java.util.Timer; import java.util.TimerTask; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; +import javax.swing.text.Document; +import jsyntaxpane.SyntaxDocument; public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretListener { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java index d48cb41f1..84f8b1dd8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java @@ -134,6 +134,23 @@ public class DetailPanel extends JPanel implements ActionListener { layout.show(innerPanel, name); boolean b = cardMap.get(name) instanceof TraitDetail; buttonsPanel.setVisible(b); + + TraitDetail newDetail = null; + if (b) { + newDetail = (TraitDetail) cardMap.get(name); + } + for (JComponent v : cardMap.values()) { + if (v instanceof TraitDetail) { + if (v != newDetail) { + TraitDetail oldDetail = (TraitDetail) v; + oldDetail.setActive(false); + } + } + } + if (newDetail != null) { + newDetail.setActive(true); + } + selectedCard = name; selectedLabel.setText(selectedCard); if (trait == null) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/LineMarkedEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/LineMarkedEditorPane.java index 0895ae761..5433c8ef0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/LineMarkedEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/LineMarkedEditorPane.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.gui.abc; import java.awt.Color; import java.awt.FontMetrics; import java.awt.Graphics; -import javax.swing.JEditorPane; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.text.Element; @@ -29,7 +28,7 @@ import jsyntaxpane.actions.ActionUtils; * * @author JPEXS */ -public class LineMarkedEditorPane extends JEditorPane { +public class LineMarkedEditorPane extends UndoFixedEditorPane { int lastLine = -1; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodInfoPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodInfoPanel.java index a762e1fc8..2865686ab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodInfoPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodInfoPanel.java @@ -43,7 +43,7 @@ public class MethodInfoPanel extends JPanel { private JLabel methodIndexLabel; public MethodInfoPanel() { - returnTypeEditor = new JEditorPane(); + returnTypeEditor = new UndoFixedEditorPane(); paramEditor = new LineMarkedEditorPane(); setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); JPanel miPanel = new JPanel(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodTraitDetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodTraitDetailPanel.java index 69b7ad542..763928a18 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodTraitDetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodTraitDetailPanel.java @@ -63,4 +63,10 @@ public class MethodTraitDetailPanel extends JTabbedPane implements TraitDetail { methodBodyParamsPanel.setEditMode(val); methodInfoPanel.setEditMode(val); } + private boolean active = false; + + @Override + public void setActive(boolean val) { + this.active = val; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java index 3a8669093..2358e11ad 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java @@ -41,7 +41,7 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { private boolean showWarning = false; public SlotConstTraitDetailPanel() { - slotConstEditor = new JEditorPane(); + slotConstEditor = new UndoFixedEditorPane(); setLayout(new BorderLayout()); add(new JLabel(translate("abc.detail.slotconst.typevalue")), BorderLayout.NORTH); add(new JScrollPane(slotConstEditor), BorderLayout.CENTER); @@ -97,9 +97,15 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { @Override public void setEditMode(boolean val) { - if (val) { + if (val && active) { JOptionPane.showMessageDialog(null, translate("warning.initializers"), translate("message.warning"), JOptionPane.WARNING_MESSAGE); } slotConstEditor.setEditable(val); } + private boolean active = false; + + @Override + public void setActive(boolean val) { + this.active = val; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitDetail.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitDetail.java index 2e4042020..47d128be9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitDetail.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitDetail.java @@ -25,4 +25,6 @@ public interface TraitDetail { public void setEditMode(boolean val); public boolean save(); + + public void setActive(boolean val); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/UndoFixedEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/UndoFixedEditorPane.java new file mode 100644 index 000000000..bed13cd88 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/UndoFixedEditorPane.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2013 JPEXS + * + * This program 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. + * + * This program 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 this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.abc; + +import javax.swing.JEditorPane; +import javax.swing.text.Document; +import jsyntaxpane.SyntaxDocument; + +/** + * + * @author JPEXS + */ +public class UndoFixedEditorPane extends JEditorPane { + + @Override + public void setText(String t) { + super.setText(t); + clearUndos(); + } + + public void clearUndos() { + Document doc = getDocument(); + if (doc instanceof SyntaxDocument) { + SyntaxDocument sdoc = (SyntaxDocument) doc; + sdoc.clearUndos(); + } + } +}