Issue #53 Displaying trait names with indices, method indices

This commit is contained in:
Jindra Pet��k
2013-04-20 15:02:47 +02:00
parent b4adf93945
commit ab9275b53f
3 changed files with 38 additions and 10 deletions
@@ -45,7 +45,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
private ABCPanel abcPanel;
public void setNoTrait() {
abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD);
abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD, null);
}
public void hilightOffset(long offset) {
@@ -72,7 +72,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
this.classIndex = classIndex;
}
private boolean displayMethod(int pos, int methodIndex, String name) {
private boolean displayMethod(int pos, int methodIndex, String name, Trait trait) {
if (abc == null) {
return false;
}
@@ -80,7 +80,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
if (bi == -1) {
return false;
}
abcPanel.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD);
abcPanel.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD, trait);
if (reset || (abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex() != bi)) {
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abc, name);
abcPanel.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]);
@@ -139,11 +139,12 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
if (abc != null) {
name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants);
}
Trait t = null;
for (Highlighting th : traitHighlights) {
if ((pos >= th.startPos) && (pos < th.startPos + th.len)) {
lastTraitIndex = (int) th.offset;
if (abc != null) {
Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex);
t = abc.findTraitByTraitId(classIndex, lastTraitIndex);
if (t != null) {
name += ":" + t.getName(abc).getName(abc.constants, new ArrayList<String>());
}
@@ -151,7 +152,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
}
}
displayMethod(pos, (int) tm.offset, name);
displayMethod(pos, (int) tm.offset, name, t);
currentMethodHighlight = tm;
@@ -170,22 +171,23 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
if (tr != null) {
if (tr instanceof TraitSlotConst) {
abcPanel.detailPanel.slotConstTraitPanel.load((TraitSlotConst) tr, abc);
abcPanel.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD);
abcPanel.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD, tr);
abcPanel.detailPanel.setEditMode(false);
return;
}
}
currentMethodHighlight = th;
String name = "";
Trait t = null;
if (abc != null) {
name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants);
Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex);
t = abc.findTraitByTraitId(classIndex, lastTraitIndex);
if (t != null) {
name += ":" + t.getName(abc).getName(abc.constants, new ArrayList<String>());
}
}
displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name);
displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name, t);
return;
}
}
@@ -16,13 +16,16 @@
*/
package com.jpexs.decompiler.flash.abc.gui;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.helpers.Helper;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.*;
import javax.swing.border.BevelBorder;
@@ -49,6 +52,7 @@ public class DetailPanel extends JPanel implements ActionListener {
private boolean editMode = false;
private JPanel buttonsPanel;
private ABCPanel abcPanel;
private JLabel traitNameLabel;
public DetailPanel(ABCPanel abcPanel) {
this.abcPanel = abcPanel;
@@ -98,7 +102,15 @@ public class DetailPanel extends JPanel implements ActionListener {
selectedLabel.setText(selectedCard);
selectedLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
selectedLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(selectedLabel, BorderLayout.NORTH);
JPanel topPanel = new JPanel(new BorderLayout());
topPanel.add(selectedLabel, BorderLayout.NORTH);
traitNameLabel = new JLabel("");
JPanel traitInfoPanel = new JPanel();
traitInfoPanel.setLayout(new BoxLayout(traitInfoPanel, BoxLayout.LINE_AXIS));
traitInfoPanel.add(new JLabel(" Name:"));
traitInfoPanel.add(traitNameLabel);
topPanel.add(traitInfoPanel, BorderLayout.CENTER);
add(topPanel, BorderLayout.NORTH);
}
public void setEditMode(boolean val) {
@@ -110,13 +122,18 @@ public class DetailPanel extends JPanel implements ActionListener {
editMode = val;
}
public void showCard(String name) {
public void showCard(String name, Trait trait) {
CardLayout layout = (CardLayout) innerPanel.getLayout();
layout.show(innerPanel, name);
boolean b = cardMap.get(name) instanceof TraitDetail;
buttonsPanel.setVisible(b);
selectedCard = name;
selectedLabel.setText(selectedCard);
if (trait == null) {
traitNameLabel.setText("-");
} else {
traitNameLabel.setText(" m[" + trait.name_index + "]\"" + Helper.escapeString(trait.getName(abcPanel.abc).toString(abcPanel.abc.constants, new ArrayList<String>())) + "\"");
}
}
@Override
@@ -38,11 +38,18 @@ public class MethodInfoPanel extends JPanel {
public JEditorPane returnTypeEditor;
private MethodInfo methodInfo;
private ABC abc;
private JLabel methodIndexLabel;
public MethodInfoPanel() {
returnTypeEditor = new JEditorPane();
paramEditor = new LineMarkedEditorPane();
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
JPanel miPanel = new JPanel();
miPanel.setLayout(new BoxLayout(miPanel, BoxLayout.LINE_AXIS));
miPanel.add(new JLabel("Method Index:"));
methodIndexLabel = new JLabel(" ");
miPanel.add(methodIndexLabel);
add(miPanel);
add(new JLabel("Parameters:"));
add(new JScrollPane(paramEditor));
add(new JLabel("Return value type:"));
@@ -63,6 +70,8 @@ public class MethodInfoPanel extends JPanel {
if (methodInfoIndex <= 0) {
paramEditor.setText("");
}
methodIndexLabel.setText("" + methodInfoIndex);
this.methodInfo = abc.method_info[methodInfoIndex];
int p = 0;
String ret = "";