diff --git a/src/com/jpexs/decompiler/flash/gui/locales/action/AddScriptDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/action/AddScriptDialog.properties index e78a24af3..e4ceb75ae 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/action/AddScriptDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/action/AddScriptDialog.properties @@ -10,3 +10,5 @@ type.button.event = Button event (BUTTONCONDACTION) type.instance.event = Instance event (CLIPACTIONRECORD) type.class = AS2 Class classname = Fully qualified class name: + +message.classexists = Class with this name already exists. Please select another name. diff --git a/src/com/jpexs/decompiler/flash/gui/locales/action/AddScriptDialog_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/action/AddScriptDialog_cs.properties index 3a83240be..b56baefe3 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/action/AddScriptDialog_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/action/AddScriptDialog_cs.properties @@ -10,3 +10,4 @@ type.instance.event = Ud\u00e1lost instance (CLIPACTIONRECORD) type.class=AS2 T\u0159\u00edda classname=Pln\u011b kvalifikovan\u00fd n\u00e1zev t\u0159\u00eddy type.sprite.init=Inicializa\u010dn\u00ed skript Spritu (DoInitAction) +message.classexists=T\u0159\u00edda tohoto n\u00e1zvu ji\u017e existuje. Pros\u00edm zvolte jin\u00fd n\u00e1zev. diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index 3594fe528..04e2091b3 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -232,7 +232,6 @@ public class TagTreeContextMenu extends JPopupMenu { addAs3ClassMenuItem.addActionListener(this::addAs3ClassActionPerformed); add(addAs3ClassMenuItem); - tagTree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -752,12 +751,29 @@ public class TagTreeContextMenu extends JPopupMenu { List sel = tagTree.getSelected(); if (!sel.isEmpty()) { if (sel.get(0) instanceof ClassesListTreeModel) { - String className = View.showInputDialog(AppDialog.translateForDialog("classname", AddScriptDialog.class), ""); - if (className == null || className.isEmpty()) { - return; - } ClassesListTreeModel cl = (ClassesListTreeModel) sel.get(0); SWF swf = cl.getSwf(); + String className = ""; + String parts[]; + loopinput: + while (true) { + className = View.showInputDialog(AppDialog.translateForDialog("classname", AddScriptDialog.class), className); + if (className == null || className.isEmpty()) { + return; + } + + + parts = className.contains(".") ? className.split("\\.") : new String[]{className}; + DottedChain classNameDc = new DottedChain(parts, ""); + for (ABCContainerTag ct : swf.getAbcList()) { + if (ct.getABC().findClassByName(classNameDc) > -1) { + View.showMessageDialog(mainPanel, AppDialog.translateForDialog("message.classexists", AddScriptDialog.class), mainPanel.translate("error"), JOptionPane.ERROR_MESSAGE); + continue loopinput; + } + } + break; + } + DoABC2Tag doAbc = new DoABC2Tag(swf); doAbc.name = className; @@ -810,7 +826,6 @@ public class TagTreeContextMenu extends JPopupMenu { Object item = mainPanel.tagTree.getModel().getScriptsNode(swf); - String parts[] = className.contains(".") ? className.split("\\.") : new String[]{className}; TreePath selection = mainPanel.tagTree.getSelectionPath(); TreePath swfPath = selection.getParentPath(); TreePath scriptsPath = swfPath.pathByAddingChild(item);