Issues #316: Fixed undoable readonly editor panes

Warning about static const initializers shown only in const/static.
This commit is contained in:
Jindra Pet��k
2013-08-11 10:55:22 +02:00
parent 443aa3c98d
commit 1cc46522e7
8 changed files with 79 additions and 5 deletions
@@ -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 {
@@ -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) {
@@ -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;
@@ -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();
@@ -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;
}
}
@@ -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;
}
}
@@ -25,4 +25,6 @@ public interface TraitDetail {
public void setEditMode(boolean val);
public boolean save();
public void setActive(boolean val);
}
@@ -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 <http://www.gnu.org/licenses/>.
*/
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();
}
}
}