mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 07:20:46 +00:00
replace text
This commit is contained in:
@@ -49,7 +49,6 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -200,7 +199,7 @@ public class ErrorLogFrame extends AppFrame {
|
||||
|
||||
private void log(final Level level, final String msg, final String detail) {
|
||||
if (logItemCount.getAndIncrement() < MAX_LOG_ITEM_COUNT) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notifyMainFrame(level);
|
||||
|
||||
@@ -174,7 +174,6 @@ import javax.swing.JSplitPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
@@ -766,7 +765,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
|
||||
final MainPanel t = this;
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
splitPane1.setDividerLocation(Configuration.guiSplitPane1DividerLocation.get(getWidth() / 3));
|
||||
@@ -1173,20 +1172,40 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
if (replaceDialog.result) {
|
||||
final String txt = replaceDialog.searchField.getText();
|
||||
if (!txt.isEmpty()) {
|
||||
final String replacement = replaceDialog.replaceField.getText();
|
||||
final SWF swf = getCurrentSwf();
|
||||
|
||||
new CancellableWorker() {
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
boolean found = false;
|
||||
if (searchText(txt, replaceDialog.ignoreCaseCheckBox.isSelected(), replaceDialog.regexpCheckBox.isSelected(), swf)) {
|
||||
found = true;
|
||||
int findCount = 0;
|
||||
Pattern pat = Pattern.compile(Pattern.quote(txt), replaceDialog.ignoreCaseCheckBox.isSelected() ? Pattern.CASE_INSENSITIVE : 0);
|
||||
List<TextTag> textTags = new ArrayList<>();
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof TextTag) {
|
||||
textTags.add((TextTag) tag);
|
||||
}
|
||||
}
|
||||
for (TextTag textTag : textTags) {
|
||||
List<String> texts = textTag.getTexts();
|
||||
boolean found = false;
|
||||
for (int i = 0; i < texts.size(); i++) {
|
||||
String text = texts.get(i);
|
||||
if (pat.matcher(text).find()) {
|
||||
texts.set(i, text.replaceAll(txt, replacement));
|
||||
found = true;
|
||||
findCount++;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
String[] textArray = texts.toArray(new String[texts.size()]);
|
||||
textTag.setFormattedText(getMissingCharacterHandler(), textTag.getFormattedText(), textArray);
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
View.showMessageDialog(null, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE);
|
||||
if (findCount > 0) {
|
||||
refreshTree();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
@@ -1195,7 +1214,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
|
||||
private boolean searchText(String txt, boolean ignoreCase, boolean regexp, SWF swf) {
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
if (txt != null && !txt.isEmpty()) {
|
||||
SearchPanel<TextTag> textSearchPanel = previewPanel.getTextPanel().getSearchPanel();
|
||||
textSearchPanel.setOptions(ignoreCase, regexp);
|
||||
List<TextTag> found = new ArrayList<>();
|
||||
@@ -1430,7 +1449,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private String getTextTagInfo(TextTag textTag) {
|
||||
String ret = "";
|
||||
if (textTag != null) {
|
||||
ret += " TextId: " + textTag.getCharacterId() + " (" + textTag.getText(", ") + ")";
|
||||
ret += " TextId: " + textTag.getCharacterId() + " (" + String.join(", ", textTag.getTexts()) + ")";
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1770,12 +1789,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(TextTag textTag, FontTag font, char character) {
|
||||
public boolean handle(TextTag textTag, final FontTag font, final char character) {
|
||||
String fontName = font.getSwf().sourceFontNamesMap.get(font.getFontId());
|
||||
if (fontName == null) {
|
||||
fontName = font.getFontName();
|
||||
}
|
||||
Font f = FontTag.installedFontsByName.get(fontName);
|
||||
final Font f = FontTag.installedFontsByName.get(fontName);
|
||||
if (f == null || !f.canDisplay(character)) {
|
||||
String msg = translate("error.font.nocharacter").replace("%char%", "" + character);
|
||||
logger.log(Level.SEVERE, msg + " FontId: " + font.getCharacterId() + " TextId: " + textTag.getCharacterId());
|
||||
@@ -1785,7 +1804,14 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
ignoreMissingCharacters ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION) == JOptionPane.OK_OPTION;
|
||||
return false;
|
||||
}
|
||||
font.addCharacter(character, f);
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
font.addCharacter(character, f);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Image;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ReplaceDialog extends AppDialog implements ActionListener {
|
||||
|
||||
private static final String ACTION_OK = "OK";
|
||||
private static final String ACTION_CANCEL = "CANCEL";
|
||||
|
||||
public JTextField searchField = new MyTextField();
|
||||
public JCheckBox ignoreCaseCheckBox = new JCheckBox(translate("checkbox.ignorecase"));
|
||||
//public JCheckBox regexpCheckBox = new JCheckBox(translate("checkbox.regexp"));
|
||||
public boolean result = false;
|
||||
|
||||
public ReplaceDialog(Window owner) {
|
||||
super(owner);
|
||||
setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
||||
ignoreCaseCheckBox.setSelected(true);
|
||||
Container cnt = getContentPane();
|
||||
setSize(400, 150);
|
||||
cnt.setLayout(new BoxLayout(cnt, BoxLayout.PAGE_AXIS));
|
||||
JPanel panButtons = new JPanel(new FlowLayout());
|
||||
JButton okButton = new JButton(translate("button.ok"));
|
||||
okButton.setActionCommand(ACTION_OK);
|
||||
okButton.addActionListener(this);
|
||||
JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
cancelButton.setActionCommand(ACTION_CANCEL);
|
||||
cancelButton.addActionListener(this);
|
||||
panButtons.add(okButton);
|
||||
panButtons.add(cancelButton);
|
||||
JPanel panField = new JPanel(new FlowLayout());
|
||||
searchField.setPreferredSize(new Dimension(250, searchField.getPreferredSize().height));
|
||||
panField.add(new JLabel(translate("label.searchtext")));
|
||||
panField.add(searchField);
|
||||
cnt.add(panField);
|
||||
|
||||
JPanel checkPanel = new JPanel(new FlowLayout());
|
||||
checkPanel.add(ignoreCaseCheckBox);
|
||||
//checkPanel.add(regexpCheckBox);
|
||||
cnt.add(checkPanel);
|
||||
|
||||
cnt.add(panButtons);
|
||||
getRootPane().setDefaultButton(okButton);
|
||||
View.centerScreen(this);
|
||||
//View.setWindowIcon(this);
|
||||
setIconImage(View.loadImage("search16"));
|
||||
setTitle(translate("dialog.title"));
|
||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||
pack();
|
||||
List<Image> images = new ArrayList<>();
|
||||
images.add(View.loadImage("search16"));
|
||||
images.add(View.loadImage("search32"));
|
||||
setIconImages(images);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
if (b) {
|
||||
result = false;
|
||||
searchField.requestFocusInWindow();
|
||||
}
|
||||
super.setVisible(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals(ACTION_OK)) {
|
||||
/*if (regexpCheckBox.isSelected()) {
|
||||
try {
|
||||
Pattern pat = Pattern.compile(searchField.getText());
|
||||
} catch (PatternSyntaxException ex) {
|
||||
View.showMessageDialog(null, translate("error.invalidregexp"), translate("error"), JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
result = true;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,10 @@ public class SearchDialog extends AppDialog implements ActionListener {
|
||||
|
||||
JPanel checkPanel = new JPanel(new FlowLayout());
|
||||
checkPanel.add(ignoreCaseCheckBox);
|
||||
checkPanel.add(regexpCheckBox);
|
||||
if (!replace) {
|
||||
checkPanel.add(regexpCheckBox);
|
||||
}
|
||||
|
||||
cnt.add(checkPanel);
|
||||
|
||||
if (!replace) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import jsyntaxpane.actions.DocumentSearchData;
|
||||
|
||||
@@ -117,7 +116,7 @@ public class SearchPanel<E> extends JPanel implements ActionListener {
|
||||
}
|
||||
|
||||
private void doUpdate() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchPos.setText((foundPos + 1) + "/" + found.size());
|
||||
|
||||
@@ -31,7 +31,6 @@ import javax.swing.JButton;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -109,7 +108,7 @@ public class SearchResultsDialog<E> extends AppDialog implements ActionListener
|
||||
|
||||
private void gotoElement() {
|
||||
if (resultsList.getSelectedIndex() != -1) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -102,7 +102,6 @@ import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.text.Highlighter;
|
||||
@@ -686,7 +685,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
public void hilightScript(ScriptPack pack) {
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
final TreePath tp = ttm.getTagPath(pack);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mainPanel.tagTree.setSelectionPath(tp);
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.jpexs.decompiler.flash.gui.MainFrame;
|
||||
import com.jpexs.decompiler.flash.gui.ModeFrame;
|
||||
import com.jpexs.decompiler.flash.gui.NewVersionDialog;
|
||||
import com.jpexs.decompiler.flash.gui.RenameDialog;
|
||||
import com.jpexs.decompiler.flash.gui.ReplaceDialog;
|
||||
import com.jpexs.decompiler.flash.gui.SearchDialog;
|
||||
import com.jpexs.decompiler.flash.gui.SearchResultsDialog;
|
||||
import com.jpexs.decompiler.flash.gui.SelectLanguageDialog;
|
||||
@@ -71,7 +70,6 @@ public class CheckResources {
|
||||
NewVersionDialog.class,
|
||||
RenameDialog.class,
|
||||
SearchDialog.class,
|
||||
ReplaceDialog.class,
|
||||
SearchResultsDialog.class,
|
||||
SelectLanguageDialog.class,
|
||||
ProxyFrame.class,
|
||||
|
||||
@@ -56,7 +56,6 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.AncestorEvent;
|
||||
import javax.swing.event.AncestorListener;
|
||||
|
||||
@@ -429,7 +428,7 @@ public class PlayerControls extends JPanel implements ActionListener {
|
||||
@Override
|
||||
public void ancestorAdded(AncestorEvent event) {
|
||||
final AncestorListener al = this;
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user