#825 hot keys (and maybe new buttons on new panel) to switch to next or previous DefineText

This commit is contained in:
honfika@gmail.com
2015-03-07 22:55:09 +01:00
parent 7b23b1670f
commit 18af792012
17 changed files with 245 additions and 105 deletions

View File

@@ -173,7 +173,7 @@ public class FontPanel extends javax.swing.JPanel {
if (tag instanceof TextTag) {
TextTag textTag = (TextTag) tag;
if (textTag.getFontIds().contains(fontId)) {
String text = textTag.getFormattedText();
String text = textTag.getFormattedText().text;
mainPanel.saveText(textTag, text, null);
}
}

View File

@@ -224,6 +224,14 @@ public abstract class MainFrameMenu {
mainFrame.getPanel().refreshDecompiled();
}
protected boolean previousTag() {
return mainFrame.getPanel().previousTag();
}
protected boolean nextTag() {
return mainFrame.getPanel().nextTag();
}
protected void checkResources() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(os);
@@ -323,7 +331,7 @@ public abstract class MainFrameMenu {
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
if (((JFrame) mainFrame).isActive()) {
if (((JFrame) mainFrame).isActive() && e.getID() == KeyEvent.KEY_RELEASED) {
int code = e.getKeyCode();
if (e.isControlDown() && e.isShiftDown()) {
switch (code) {
@@ -346,6 +354,13 @@ public abstract class MainFrameMenu {
case KeyEvent.VK_E:
return export(false);
}
} else if (e.isControlDown() && !e.isShiftDown()) {
switch (code) {
case KeyEvent.VK_UP:
return previousTag();
case KeyEvent.VK_DOWN:
return nextTag();
}
}
}

View File

@@ -1361,10 +1361,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
if (found) {
String[] textArray = texts.toArray(new String[texts.size()]);
textTag.setFormattedText(getMissingCharacterHandler(), textTag.getFormattedText(), textArray);
textTag.setFormattedText(getMissingCharacterHandler(), textTag.getFormattedText().text, textArray);
}
} else {
String text = textTag.getFormattedText();
String text = textTag.getFormattedText().text;
if (pat.matcher(text).find()) {
textTag.setFormattedText(getMissingCharacterHandler(), text.replaceAll(txt, replacement), null);
findCount++;
@@ -1397,7 +1397,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
for (Tag tag : swf.tags) {
if (tag instanceof TextTag) {
TextTag textTag = (TextTag) tag;
if (pat.matcher(textTag.getFormattedText()).find()) {
if (pat.matcher(textTag.getFormattedText().text).find()) {
found.add(textTag);
}
}
@@ -2075,6 +2075,34 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
return false;
}
public boolean previousTag() {
if (getCurrentView() == VIEW_RESOURCES) {
if (tagTree.getSelectionRows().length > 0) {
int row = tagTree.getSelectionRows()[0];
if (row > 0) {
tagTree.setSelectionRow(row - 1);
previewPanel.focusTextPanel();
}
}
return true;
}
return false;
}
public boolean nextTag() {
if (getCurrentView() == VIEW_RESOURCES) {
if (tagTree.getSelectionRows().length > 0) {
int row = tagTree.getSelectionRows()[0];
if (row < tagTree.getRowCount() - 1) {
tagTree.setSelectionRow(row + 1);
previewPanel.focusTextPanel();
}
}
return true;
}
return false;
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {

View File

@@ -458,6 +458,10 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
textPanel.setText(textTag);
}
public void focusTextPanel() {
textPanel.focusTextValue();
}
public void clear() {
imagePanel.clearAll();
if (media != null) {

View File

@@ -20,6 +20,9 @@ import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.gui.controls.JRepeatButton;
import com.jpexs.decompiler.flash.helpers.HighlightedText;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.flash.tags.DefineEditTextTag;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
@@ -61,6 +64,10 @@ public class TextPanel extends JPanel {
private final JButton textCancelButton;
private final JButton selectPrevousTagButton;
private final JButton selectNextTagButton;
private final JButton textAlignLeftButton;
private final JButton textAlignCenterButton;
@@ -114,6 +121,8 @@ public class TextPanel extends JPanel {
JPanel textButtonsPanel = new JPanel();
textButtonsPanel.setLayout(new FlowLayout(SwingConstants.WEST));
selectPrevousTagButton = createButton(null, "arrowup16", "selectPreviousTag", e -> mainPanel.previousTag());
selectNextTagButton = createButton(null, "arrowdown16", "selectNextTag", e -> mainPanel.nextTag());
textAlignLeftButton = createButton(null, "textalignleft16", "text.align.left", e -> textAlign(TextAlign.LEFT));
textAlignCenterButton = createButton(null, "textaligncenter16", "text.align.center", e -> textAlign(TextAlign.CENTER));
textAlignRightButton = createButton(null, "textalignright16", "text.align.right", e -> textAlign(TextAlign.RIGHT));
@@ -122,6 +131,8 @@ public class TextPanel extends JPanel {
increaseTranslateXButton = createButton(null, "textindent16", "text.align.translatex.increase", e -> translateX((int) SWF.unitDivisor, ((JRepeatButton) e.getSource()).getRepeatCount()), true);
undoChangesButton = createButton(null, "reload16", "text.undo", e -> undoChanges());
textButtonsPanel.add(selectPrevousTagButton);
textButtonsPanel.add(selectNextTagButton);
textButtonsPanel.add(textAlignLeftButton);
textButtonsPanel.add(textAlignCenterButton);
textButtonsPanel.add(textAlignRightButton);
@@ -167,12 +178,25 @@ public class TextPanel extends JPanel {
public void setText(TextTag textTag) {
this.textTag = textTag;
textValue.setText(textTag.getFormattedText());
textValue.setText(textTag.getFormattedText().text);
textValue.setCaretPosition(0);
modified = false;
setEditText(false);
}
public void focusTextValue() {
textValue.requestFocusInWindow();
if (!modified) {
HighlightedText text = textTag.getFormattedText();
for (Highlighting highlight : text.specialHilights) {
if (highlight.getProperties().subtype == HighlightSpecialType.TEXT) {
textValue.select(highlight.startPos, highlight.startPos + highlight.len);
break;
}
}
}
}
public void closeTag() {
if (modified && Configuration.autoSaveTagModifications.get()) {
saveText(false);

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

View File

@@ -572,3 +572,5 @@ menu.file.export.xml = Export SWF XML
#after version 4.1.1
text.align.translatex.decrease = Decrease TranslateX
text.align.translatex.increase = Increase TranslateX
selectPreviousTag = Select previous tag
selectNextTag = Select next tag

View File

@@ -16,3 +16,5 @@
button.open = Helyi f\u00e1jl megnyit\u00e1sa
button.proxy = Megnyit\u00e1s proxyn kereszt\u00fcl
button.exit = Kil\u00e9p\u00e9s az alkalmaz\u00e1sb\u00f3l
selectPreviousTag = El\u0151z\u0151 tag kiv\u00e1laszt\u00e1sa
selectNextTag = K\u00f6vetkez\u0151 tag kiv\u00e1laszt\u00e1sa