mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-25 13:05:33 +00:00
Fixes around adding classes.
Adding classes in taglist view.
This commit is contained in:
@@ -60,6 +60,10 @@ public class AS3Package extends AS3ClassTreeItem {
|
||||
public boolean isDefaultPackage() {
|
||||
return defaultPackage;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return flat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -66,15 +66,20 @@ public class AddClassDialog extends AppDialog {
|
||||
private Openable openable;
|
||||
|
||||
private int abcCount = 0;
|
||||
|
||||
private ABCContainerTag preselectedAbcContainer;
|
||||
|
||||
private JRadioButton existingAbcTagRadioButton = new JRadioButton(translate("abc.where.existing"));
|
||||
private JRadioButton newAbcTagRadioButton = new JRadioButton(translate("abc.where.new"));
|
||||
|
||||
public AddClassDialog(Window owner, Openable openable) {
|
||||
public AddClassDialog(Window owner, Openable openable, ABCContainerTag abcContainer) {
|
||||
super(owner);
|
||||
this.openable = openable;
|
||||
abcCount = 0;
|
||||
if (openable instanceof SWF) {
|
||||
this.preselectedAbcContainer = abcContainer;
|
||||
if (abcContainer != null) {
|
||||
abcCount = 1;
|
||||
} else if (openable instanceof SWF) {
|
||||
SWF swf = (SWF) openable;
|
||||
for (Tag t : swf.getTags()) {
|
||||
if (t instanceof ABCContainerTag) {
|
||||
@@ -118,7 +123,7 @@ public class AddClassDialog extends AppDialog {
|
||||
abcTargetPanel.setVisible(false);
|
||||
}
|
||||
|
||||
if (openable instanceof ABC) {
|
||||
if (preselectedAbcContainer != null) {
|
||||
existingAbcTagRadioButton.setSelected(true);
|
||||
abcTargetPanel.setVisible(false);
|
||||
}
|
||||
@@ -221,8 +226,8 @@ public class AddClassDialog extends AppDialog {
|
||||
return;
|
||||
}
|
||||
setVisible(false);
|
||||
if (openable instanceof ABC) {
|
||||
selectedAbcContainer = ((ABC) openable).parentTag;
|
||||
if (preselectedAbcContainer != null) {
|
||||
selectedAbcContainer = preselectedAbcContainer;
|
||||
} else {
|
||||
if (existingAbcTagRadioButton.isSelected()) {
|
||||
SelectDoABCDialog selectDoABCDialog = new SelectDoABCDialog(owner, (SWF) openable);
|
||||
|
||||
@@ -1576,6 +1576,9 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
if (path[p] instanceof ABC) {
|
||||
break;
|
||||
}
|
||||
if (path[p] instanceof ABCContainerTag) {
|
||||
break;
|
||||
}
|
||||
if (((AS3Package) path[p]).isDefaultPackage()) {
|
||||
break;
|
||||
}
|
||||
@@ -1584,12 +1587,25 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
}
|
||||
|
||||
TreePath scriptsPath = tree.getSelectionPaths()[0];
|
||||
while (!(scriptsPath.getLastPathComponent() instanceof ClassesListTreeModel) && !(scriptsPath.getLastPathComponent() instanceof ABC)) {
|
||||
while (!(scriptsPath.getLastPathComponent() instanceof ClassesListTreeModel) &&
|
||||
!(scriptsPath.getLastPathComponent() instanceof ABC) &&
|
||||
!(scriptsPath.getLastPathComponent() instanceof ABCContainerTag)
|
||||
) {
|
||||
scriptsPath = scriptsPath.getParentPath();
|
||||
}
|
||||
|
||||
{
|
||||
AddClassDialog acd = new AddClassDialog(Main.getDefaultDialogsOwner(), openable);
|
||||
ABCContainerTag preselectedContainer = null;
|
||||
|
||||
TreeItem scriptsNode = (TreeItem) scriptsPath.getLastPathComponent();
|
||||
|
||||
if (scriptsNode instanceof ABC) {
|
||||
preselectedContainer = ((ABC)scriptsNode).parentTag;
|
||||
} else if (scriptsNode instanceof ABCContainerTag) {
|
||||
preselectedContainer = (ABCContainerTag) scriptsNode;
|
||||
}
|
||||
|
||||
AddClassDialog acd = new AddClassDialog(Main.getDefaultDialogsOwner(), openable, preselectedContainer);
|
||||
if (acd.showDialog(preselected) != AppDialog.OK_OPTION) {
|
||||
return;
|
||||
}
|
||||
@@ -1647,23 +1663,39 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
swf.setModified(true);
|
||||
mainPanel.refreshTree(swf);
|
||||
|
||||
Object item = mainPanel.tagTree.getModel().getScriptsNode(swf);
|
||||
Object item;
|
||||
|
||||
if ((mainPanel.getCurrentView() == MainPanel.VIEW_RESOURCES) && (openable instanceof SWF)) {
|
||||
item = mainPanel.tagTree.getModel().getScriptsNode((SWF) openable);
|
||||
} else if (openable instanceof ABC) {
|
||||
item = openable;
|
||||
} else { //SWF on taglist, should be DoABCContainer
|
||||
item = scriptsPath.getLastPathComponent();
|
||||
}
|
||||
|
||||
TreePath classPath = scriptsPath;
|
||||
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
//Object item = scriptsPath.getLastPathComponent();
|
||||
loopparts: for (int i = 0; i < parts.length; i++) {
|
||||
for (TreeItem ti : tree.getModel().getAllChildren(item)) {
|
||||
if ((ti instanceof AS3Package) && ((AS3Package)ti).isFlat()) {
|
||||
AS3Package pti = (AS3Package) ti;
|
||||
if ((pkg.isEmpty() && pti.isDefaultPackage()) || (!pti.isDefaultPackage() && pkg.equals(pti.packageName))) {
|
||||
item = pti;
|
||||
i = parts.length - 1 - 1;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (ti instanceof AS3ClassTreeItem) {
|
||||
AS3ClassTreeItem cti = (AS3ClassTreeItem) ti;
|
||||
|
||||
if (parts[i].equals(cti.getNameWithNamespaceSuffix())) {
|
||||
classPath = classPath.pathByAddingChild(ti);
|
||||
item = ti;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mainPanel.tagTree.setSelectionPath(classPath);
|
||||
mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), (TreeItem) item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user