mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-24 20:01:29 +00:00
Added: #2328 Searching/replacing in texts now supports selection / all files scope
This commit is contained in:
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- [#2321] Commandline option to generate HTML docs for AS1/2 Actions
|
- [#2321] Commandline option to generate HTML docs for AS1/2 Actions
|
||||||
- Chinese translation update
|
- Chinese translation update
|
||||||
- [#2305] Saving recent colors in the color selection dialog
|
- [#2305] Saving recent colors in the color selection dialog
|
||||||
|
- [#2328] Searching/replacing in texts now supports selection / all files scope
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- [#2319] AS3 Compound assignments problems in some cases
|
- [#2319] AS3 Compound assignments problems in some cases
|
||||||
@@ -3590,6 +3591,7 @@ Major version of SWF to XML export changed to 2.
|
|||||||
[alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7
|
[alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7
|
||||||
[#2321]: https://www.free-decompiler.com/flash/issues/2321
|
[#2321]: https://www.free-decompiler.com/flash/issues/2321
|
||||||
[#2305]: https://www.free-decompiler.com/flash/issues/2305
|
[#2305]: https://www.free-decompiler.com/flash/issues/2305
|
||||||
|
[#2328]: https://www.free-decompiler.com/flash/issues/2328
|
||||||
[#2319]: https://www.free-decompiler.com/flash/issues/2319
|
[#2319]: https://www.free-decompiler.com/flash/issues/2319
|
||||||
[#2320]: https://www.free-decompiler.com/flash/issues/2320
|
[#2320]: https://www.free-decompiler.com/flash/issues/2320
|
||||||
[#2272]: https://www.free-decompiler.com/flash/issues/2272
|
[#2272]: https://www.free-decompiler.com/flash/issues/2272
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ import com.jpexs.decompiler.graph.DottedChain;
|
|||||||
import com.jpexs.helpers.ByteArrayRange;
|
import com.jpexs.helpers.ByteArrayRange;
|
||||||
import com.jpexs.helpers.CancellableWorker;
|
import com.jpexs.helpers.CancellableWorker;
|
||||||
import com.jpexs.helpers.Helper;
|
import com.jpexs.helpers.Helper;
|
||||||
|
import com.jpexs.helpers.LinkedIdentityHashSet;
|
||||||
import com.jpexs.helpers.Path;
|
import com.jpexs.helpers.Path;
|
||||||
import com.jpexs.helpers.ProgressListener;
|
import com.jpexs.helpers.ProgressListener;
|
||||||
import com.jpexs.helpers.Reference;
|
import com.jpexs.helpers.Reference;
|
||||||
@@ -2847,11 +2848,30 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
|||||||
Map<Openable, List<ScriptPack>> scopeAs3 = new LinkedHashMap<>();
|
Map<Openable, List<ScriptPack>> scopeAs3 = new LinkedHashMap<>();
|
||||||
Map<SWF, Map<String, ASMSource>> swfToAllASMSourceMap = new HashMap<>();
|
Map<SWF, Map<String, ASMSource>> swfToAllASMSourceMap = new HashMap<>();
|
||||||
Map<SWF, Map<String, ASMSource>> scopeAs12 = new LinkedHashMap<>();
|
Map<SWF, Map<String, ASMSource>> scopeAs12 = new LinkedHashMap<>();
|
||||||
|
Set<TextTag> scopeTextTags = new LinkedIdentityHashSet<>();
|
||||||
|
|
||||||
Set<Openable> openablesUsed = new LinkedHashSet<>();
|
Set<Openable> openablesUsed = new LinkedHashSet<>();
|
||||||
|
|
||||||
List<TreeItem> allItems = getAllSelected();
|
List<TreeItem> allItems = getAllSelected();
|
||||||
for (TreeItem t : allItems) {
|
for (TreeItem t : allItems) {
|
||||||
|
if (t instanceof SWF) {
|
||||||
|
for (Tag g : ((SWF) t).getTags()) {
|
||||||
|
if (g instanceof TextTag) {
|
||||||
|
scopeTextTags.add((TextTag) g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (t instanceof FolderItem) {
|
||||||
|
FolderItem f = (FolderItem) t;
|
||||||
|
for (TreeItem t2 : f.subItems) {
|
||||||
|
if (t2 instanceof TextTag) {
|
||||||
|
scopeTextTags.add((TextTag) t2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (t instanceof TextTag) {
|
||||||
|
scopeTextTags.add((TextTag) t);
|
||||||
|
}
|
||||||
if (t instanceof ScriptPack) {
|
if (t instanceof ScriptPack) {
|
||||||
ScriptPack sp = (ScriptPack) t;
|
ScriptPack sp = (ScriptPack) t;
|
||||||
Openable s = sp.getOpenable(); //Fixme for ABCs
|
Openable s = sp.getOpenable(); //Fixme for ABCs
|
||||||
@@ -2897,7 +2917,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
|||||||
List<TreeItem> items = getSelected();
|
List<TreeItem> items = getSelected();
|
||||||
String selected;
|
String selected;
|
||||||
|
|
||||||
if (scopeAs12.isEmpty() && scopeAs3.isEmpty()) {
|
if (scopeAs12.isEmpty() && scopeAs3.isEmpty() && scopeTextTags.isEmpty()) {
|
||||||
selected = null;
|
selected = null;
|
||||||
} else if (items.size() == 1) {
|
} else if (items.size() == 1) {
|
||||||
selected = items.get(0).toString();
|
selected = items.get(0).toString();
|
||||||
@@ -3037,7 +3057,25 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
|||||||
List<TextTag> textResult;
|
List<TextTag> textResult;
|
||||||
SearchPanel<TextTag> textSearchPanel = previewPanel.getTextPanel().getSearchPanel();
|
SearchPanel<TextTag> textSearchPanel = previewPanel.getTextPanel().getSearchPanel();
|
||||||
textSearchPanel.setOptions(ignoreCase, regexp);
|
textSearchPanel.setOptions(ignoreCase, regexp);
|
||||||
textResult = searchText(txt, ignoreCase, regexp, swf);
|
List<TextTag> scope = new ArrayList<>();
|
||||||
|
if (searchDialog.getCurrentScope() == SearchDialog.SCOPE_CURRENT_FILE) {
|
||||||
|
for (Tag t : swf.getTags()) {
|
||||||
|
if (t instanceof TextTag) {
|
||||||
|
scope.add((TextTag) t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (searchDialog.getCurrentScope() == SearchDialog.SCOPE_ALL_FILES) {
|
||||||
|
for (SWF s : getAllSwfs()) {
|
||||||
|
for (Tag t : s.getTags()) {
|
||||||
|
if (t instanceof TextTag) {
|
||||||
|
scope.add((TextTag) t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (searchDialog.getCurrentScope() == SearchDialog.SCOPE_SELECTION) {
|
||||||
|
scope.addAll(scopeTextTags);
|
||||||
|
}
|
||||||
|
textResult = searchText(txt, ignoreCase, regexp, scope);
|
||||||
|
|
||||||
List<TextTag> fTextResult = textResult;
|
List<TextTag> fTextResult = textResult;
|
||||||
View.execInEventDispatch(() -> {
|
View.execInEventDispatch(() -> {
|
||||||
@@ -3067,7 +3105,42 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void replaceText() {
|
public void replaceText() {
|
||||||
SearchDialog replaceDialog = new SearchDialog(getMainFrame().getWindow(), true, null, false, false);
|
Set<TextTag> scopeTextTags = new LinkedIdentityHashSet<>();
|
||||||
|
|
||||||
|
List<TreeItem> allItems = getAllSelected();
|
||||||
|
for (TreeItem t : allItems) {
|
||||||
|
if (t instanceof SWF) {
|
||||||
|
for (Tag g : ((SWF) t).getTags()) {
|
||||||
|
if (g instanceof TextTag) {
|
||||||
|
scopeTextTags.add((TextTag) g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (t instanceof FolderItem) {
|
||||||
|
FolderItem f = (FolderItem) t;
|
||||||
|
for (TreeItem t2 : f.subItems) {
|
||||||
|
if (t2 instanceof TextTag) {
|
||||||
|
scopeTextTags.add((TextTag) t2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (t instanceof TextTag) {
|
||||||
|
scopeTextTags.add((TextTag) t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<TreeItem> items = getSelected();
|
||||||
|
|
||||||
|
String selected;
|
||||||
|
if (scopeTextTags.isEmpty()) {
|
||||||
|
selected = null;
|
||||||
|
} else if (items.size() == 1) {
|
||||||
|
selected = items.get(0).toString();
|
||||||
|
} else if (items.isEmpty()) {
|
||||||
|
selected = null;
|
||||||
|
} else {
|
||||||
|
selected = AppDialog.translateForDialog("scope.selection.items", SearchDialog.class).replace("%count%", "" + items.size());
|
||||||
|
}
|
||||||
|
SearchDialog replaceDialog = new SearchDialog(getMainFrame().getWindow(), true, selected, false, false);
|
||||||
if (replaceDialog.showDialog() == AppDialog.OK_OPTION) {
|
if (replaceDialog.showDialog() == AppDialog.OK_OPTION) {
|
||||||
final String txt = replaceDialog.searchField.getText();
|
final String txt = replaceDialog.searchField.getText();
|
||||||
if (!txt.isEmpty()) {
|
if (!txt.isEmpty()) {
|
||||||
@@ -3089,13 +3162,26 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
|||||||
} else {
|
} else {
|
||||||
pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
|
pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
|
||||||
}
|
}
|
||||||
List<TextTag> textTags = new ArrayList<>();
|
|
||||||
for (Tag tag : swf.getTags()) {
|
List<TextTag> scope = new ArrayList<>();
|
||||||
if (tag instanceof TextTag) {
|
if (replaceDialog.getCurrentScope() == SearchDialog.SCOPE_CURRENT_FILE) {
|
||||||
textTags.add((TextTag) tag);
|
for (Tag t : swf.getTags()) {
|
||||||
|
if (t instanceof TextTag) {
|
||||||
|
scope.add((TextTag) t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (TextTag textTag : textTags) {
|
} else if (replaceDialog.getCurrentScope() == SearchDialog.SCOPE_ALL_FILES) {
|
||||||
|
for (SWF s : getAllSwfs()) {
|
||||||
|
for (Tag t : s.getTags()) {
|
||||||
|
if (t instanceof TextTag) {
|
||||||
|
scope.add((TextTag) t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (replaceDialog.getCurrentScope() == SearchDialog.SCOPE_SELECTION) {
|
||||||
|
scope.addAll(scopeTextTags);
|
||||||
|
}
|
||||||
|
for (TextTag textTag : scope) {
|
||||||
if (!replaceDialog.replaceInParametersCheckBox.isSelected()) {
|
if (!replaceDialog.replaceInParametersCheckBox.isSelected()) {
|
||||||
List<String> texts = textTag.getTexts();
|
List<String> texts = textTag.getTexts();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@@ -3132,7 +3218,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TextTag> searchText(String txt, boolean ignoreCase, boolean regexp, SWF swf) {
|
private List<TextTag> searchText(String txt, boolean ignoreCase, boolean regexp, List<TextTag> scope) {
|
||||||
if (txt != null && !txt.isEmpty()) {
|
if (txt != null && !txt.isEmpty()) {
|
||||||
List<TextTag> found = new ArrayList<>();
|
List<TextTag> found = new ArrayList<>();
|
||||||
Pattern pat;
|
Pattern pat;
|
||||||
@@ -3141,14 +3227,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
|||||||
} else {
|
} else {
|
||||||
pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
|
pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
|
||||||
}
|
}
|
||||||
for (Tag tag : swf.getTags()) {
|
for (TextTag textTag : scope) {
|
||||||
if (tag instanceof TextTag) {
|
|
||||||
TextTag textTag = (TextTag) tag;
|
|
||||||
if (pat.matcher(textTag.getFormattedText(true).text).find()) {
|
if (pat.matcher(textTag.getFormattedText(true).text).find()) {
|
||||||
found.add(textTag);
|
found.add(textTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,13 +120,6 @@ public class SearchDialog extends AppDialog {
|
|||||||
scopeComboBox.setSelectedIndex(1);
|
scopeComboBox.setSelectedIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replace) {
|
|
||||||
if (selection != null) {
|
|
||||||
scopeComboBox.setSelectedIndex(1);
|
|
||||||
}
|
|
||||||
scopeComboBox.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
cnt.add(panField);
|
cnt.add(panField);
|
||||||
|
|
||||||
JPanel checkPanel = new JPanel(new FlowLayout());
|
JPanel checkPanel = new JPanel(new FlowLayout());
|
||||||
@@ -152,10 +145,6 @@ public class SearchDialog extends AppDialog {
|
|||||||
rbPanel.add(searchInPCodeRadioButton);
|
rbPanel.add(searchInPCodeRadioButton);
|
||||||
rbPanel.add(searchInTextsRadioButton);
|
rbPanel.add(searchInTextsRadioButton);
|
||||||
cnt.add(rbPanel);
|
cnt.add(rbPanel);
|
||||||
|
|
||||||
searchInASRadioButton.addActionListener(this::searchTypeActionPerformed);
|
|
||||||
searchInPCodeRadioButton.addActionListener(this::searchTypeActionPerformed);
|
|
||||||
searchInTextsRadioButton.addActionListener(this::searchTypeActionPerformed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt.add(panButtons);
|
cnt.add(panButtons);
|
||||||
@@ -171,19 +160,6 @@ public class SearchDialog extends AppDialog {
|
|||||||
setIconImages(images);
|
setIconImages(images);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchTypeActionPerformed(ActionEvent e) {
|
|
||||||
if (searchInTextsRadioButton.isSelected()) {
|
|
||||||
if (scopeComboBox.getModel().getSize() == 3) {
|
|
||||||
scopeComboBox.setSelectedIndex(1);
|
|
||||||
} else {
|
|
||||||
scopeComboBox.setSelectedIndex(0);
|
|
||||||
}
|
|
||||||
scopeComboBox.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
scopeComboBox.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean b) {
|
public void setVisible(boolean b) {
|
||||||
if (b) {
|
if (b) {
|
||||||
|
|||||||
Reference in New Issue
Block a user