replace character dialog

This commit is contained in:
2015-05-01 17:13:33 +02:00
parent 6df9ea4e76
commit 0750a000c6
12 changed files with 282 additions and 56 deletions
@@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.configuration.Configuration;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
@@ -34,11 +33,7 @@ import javax.swing.JRadioButton;
*
* @author JPEXS
*/
public class RenameDialog extends AppDialog implements ActionListener {
private static final String ACTION_OK = "OK";
private static final String ACTION_CANCEL = "CANCEL";
public class RenameDialog extends AppDialog {
private final JRadioButton typeNumberRadioButton = new JRadioButton(translate("rename.type.typenumber"));
@@ -48,17 +43,7 @@ public class RenameDialog extends AppDialog implements ActionListener {
private final JButton cancelButton = new JButton(translate("button.cancel"));
private boolean confirmed = false;
public RenameType getRenameType() {
if (!isConfirmed()) {
return null;
}
if (typeNumberRadioButton.isSelected()) {
return RenameType.TYPENUMBER;
}
return RenameType.RANDOMWORD;
}
private int result = ERROR_OPTION;
public RenameDialog() {
setSize(300, 150);
@@ -76,14 +61,15 @@ public class RenameDialog extends AppDialog implements ActionListener {
setLayout(new BorderLayout());
add(new JLabel(translate("rename.type")), BorderLayout.NORTH);
add(pan, BorderLayout.CENTER);
JPanel panButtons = new JPanel(new FlowLayout());
okButton.addActionListener(this::okButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
panButtons.add(okButton);
okButton.setActionCommand(ACTION_OK);
okButton.addActionListener(this);
panButtons.add(cancelButton);
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this);
add(panButtons, BorderLayout.SOUTH);
setModalityType(ModalityType.APPLICATION_MODAL);
View.setWindowIcon(this);
setTitle(translate("dialog.title"));
@@ -95,32 +81,37 @@ public class RenameDialog extends AppDialog implements ActionListener {
@Override
public void setVisible(boolean b) {
if (b) {
confirmed = false;
result = ERROR_OPTION;
}
super.setVisible(b);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_OK:
confirmed = true;
Configuration.lastRenameType.set((Integer) (getRenameType() == RenameType.TYPENUMBER ? 1 : 2));
setVisible(false);
break;
case ACTION_CANCEL:
confirmed = false;
setVisible(false);
break;
private void okButtonActionPerformed(ActionEvent evt) {
result = OK_OPTION;
Configuration.lastRenameType.set((Integer) (getRenameType() == RenameType.TYPENUMBER ? 1 : 2));
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
result = CANCEL_OPTION;
setVisible(false);
}
public RenameType getRenameType() {
if (result == ERROR_OPTION) {
return null;
}
if (typeNumberRadioButton.isSelected()) {
return RenameType.TYPENUMBER;
}
return RenameType.RANDOMWORD;
}
public boolean isConfirmed() {
return confirmed;
}
public RenameType display() {
public int showRenameDialog() {
setVisible(true);
return getRenameType();
return result;
}
}