Add class to default package, correct prefilled class name

This commit is contained in:
Jindra Petřík
2022-11-19 23:33:13 +01:00
parent 351c86206b
commit 7f20d6bd70
3 changed files with 18 additions and 4 deletions

View File

@@ -45,14 +45,23 @@ public class AS3Package extends AS3ClassTreeItem {
private List<ScriptPack> sortedScripts;
private boolean flat;
private boolean defaultPackage;
public AS3Package(String packageName, SWF swf, boolean flat) {
public AS3Package(String packageName, SWF swf, boolean flat, boolean defaultPackage) {
super(packageName, "", null);
this.flat = flat;
this.swf = swf;
this.packageName = packageName;
this.defaultPackage = defaultPackage;
}
public boolean isDefaultPackage() {
return defaultPackage;
}
@Override
public SWF getSwf() {
return swf;

View File

@@ -57,7 +57,7 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel
public ClassesListTreeModel(SWF swf, boolean flat) {
super(null, null, null);
this.flat = flat;
root = new AS3Package(null, swf, flat);
root = new AS3Package(null, swf, flat, false);
this.swf = swf;
this.list = swf.getAS3Packs();
setFilter(null);
@@ -117,12 +117,14 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel
private AS3Package ensurePackage(DottedChain packageStr) {
if (flat) {
String fullName = packageStr.toPrintableString(true);
boolean defaultPackage = false;
if (fullName.length() == 0) {
fullName = AppResources.translate("package.default");
defaultPackage = true;
}
AS3Package pkg = root.getSubPackage(fullName);
if (pkg == null) {
pkg = new AS3Package(fullName, swf, true);
pkg = new AS3Package(fullName, swf, true, defaultPackage);
root.addSubPackage(pkg);
}
return pkg;
@@ -132,7 +134,7 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel
String pathElement = packageStr.get(i);
AS3Package pkg = parent.getSubPackage(pathElement);
if (pkg == null) {
pkg = new AS3Package(pathElement, swf, false);
pkg = new AS3Package(pathElement, swf, false, false);
parent.addSubPackage(pkg);
}

View File

@@ -1551,6 +1551,9 @@ public class TagTreeContextMenu extends JPopupMenu {
if (path[p] instanceof ClassesListTreeModel) {
break;
}
if (((AS3Package) path[p]).isDefaultPackage()) {
break;
}
preselected = ((AS3Package) path[p]).packageName + "." + preselected;
}
}