Added: Window icons for various dialogs including save/open/export/import

This commit is contained in:
Jindra Petřík
2024-08-05 11:17:25 +02:00
parent 58f207054d
commit 4410e4b95f
12 changed files with 66 additions and 40 deletions
@@ -108,7 +108,7 @@ public class AdvancedSettingsDialog extends AppDialog {
super(owner);
initComponents(selectedCategory);
View.centerScreen(this);
View.setWindowIcon(this);
View.setWindowIcon(this, "settings");
//configurationTable.setCellEditor(configurationTable.getDefaultEditor(null));
pack();
@@ -453,7 +453,7 @@ public class ExportDialog extends AppDialog {
cnt.add(buttonsPanel, BorderLayout.SOUTH);
pack();
View.centerScreen(this);
View.setWindowIcon(this);
View.setWindowIcon(this, "export");
getRootPane().setDefaultButton(okButton);
setModal(true);
String pct = "" + Configuration.lastSelectedExportZoom.get() * 100;
+5 -3
View File
@@ -1997,8 +1997,7 @@ public class Main {
}
public static boolean saveFileDialog(Openable openable, final SaveFileMode mode) {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
String ext = ".swf";
switch (mode) {
case SAVE:
@@ -2011,6 +2010,9 @@ public class Main {
ext = ".exe";
break;
}
JFileChooser fc = View.getFileChooserWithIcon(mode == SaveFileMode.EXE ? "saveasexe" : "saveas");
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
FileFilter swfFilter = new FileFilter() {
@Override
@@ -2175,7 +2177,7 @@ public class Main {
public static boolean openFileDialog() {
View.checkAccess();
JFileChooser fc = new JFileChooser();
JFileChooser fc = View.getFileChooserWithIcon("open");
if (Configuration.openMultipleFiles.get()) {
fc.setMultiSelectionEnabled(true);
}
@@ -3317,7 +3317,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
return;
}
JFileChooser fc = new JFileChooser();
JFileChooser fc = View.getFileChooserWithIcon("exportflashdevelop");
String selDir = Configuration.lastOpenDir.get();
fc.setCurrentDirectory(new File(selDir));
if (!selDir.endsWith(File.separator)) {
@@ -3426,10 +3426,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
return;
}
JFileChooser fc = new JFileChooser();
String selDir = Configuration.lastOpenDir.get();
fc.setCurrentDirectory(new File(selDir));
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("exportidea");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("export.project.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -3502,7 +3499,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (swf == null) {
return;
}
JFileChooser fc = new JFileChooser();
JFileChooser fc = View.getFileChooserWithIcon("exportfla");
String selDir = Configuration.lastOpenDir.get();
fc.setCurrentDirectory(new File(selDir));
if (!selDir.endsWith(File.separator)) {
@@ -3658,7 +3655,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public void importMovie(final SWF swf) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importMovies2"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportMovieInfo);
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("importmovie");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("import.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -3718,7 +3715,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public void importSound(final SWF swf) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importSounds2"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportSoundInfo);
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("importsound");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("import.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -3778,7 +3775,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public void importSprite(final SWF swf) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importSprites"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportSpriteInfo);
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("importsprite");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("import.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -3837,7 +3834,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public void importShape(final SWF swf, boolean noFill) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importShapes2"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportShapeInfo);
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("importshape");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("import.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -3897,7 +3894,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public void importImage(final SWF swf) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importImages2"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportImageInfo);
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("importimage");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("import.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -3955,7 +3952,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public void importText(final SWF swf) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importTexts2"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportTextInfo);
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("importtext");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("import.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -4055,7 +4052,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importScripts2"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportScriptsInfo);
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("importscript");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("import.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -4149,7 +4146,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
public void importSymbolClass(final SWF swf) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importSymbolClass").replace("%file%", SymbolClassExporter.SYMBOL_CLASS_EXPORT_FILENAME), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportSymbolClassInfo);
JFileChooser chooser = new JFileChooser();
JFileChooser chooser = View.getFileChooserWithIcon("importsymbolclass");
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("import.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -4165,8 +4162,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
}
private String selectExportDir() {
JFileChooser chooser = new JFileChooser();
private String selectExportDir(String icon) {
JFileChooser chooser = View.getFileChooserWithIcon(icon);
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
chooser.setDialogTitle(translate("export.select.directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -4191,7 +4188,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
final ExportDialog export = new ExportDialog(Main.getDefaultDialogsOwner(), sel);
if (export.showExportDialog() == AppDialog.OK_OPTION) {
final String selFile = selectExportDir();
final String selFile = selectExportDir("export");
if (selFile != null) {
final long timeBefore = System.currentTimeMillis();
@@ -4254,7 +4251,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
for (SWF item : swfs) {
SWF swf = (SWF) item;
final String selFile = selectExportDir();
final String selFile = selectExportDir("exportjava");
if (selFile != null) {
Main.startWork(translate("work.exporting") + "...", null);
@@ -4290,7 +4287,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
for (SWF swf : swfs) {
final String selFile = selectExportDir();
final String selFile = selectExportDir("exportxml");
if (selFile != null) {
Main.startWork(translate("work.exporting") + "...", null);
@@ -4332,7 +4329,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
for (SWF swf : swfs) {
File selectedFile = showImportFileChooser("filter.xml|*.xml", false);
File selectedFile = showImportFileChooser("filter.xml|*.xml", false, "importxml");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
try {
@@ -4848,25 +4845,25 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
TreeItem ti0 = items.get(0);
File file = null;
if (ti0 instanceof SoundTag) {
file = showImportFileChooser("filter.sounds|*.mp3;*.wav|filter.sounds.mp3|*.mp3|filter.sounds.wav|*.wav", false);
file = showImportFileChooser("filter.sounds|*.mp3;*.wav|filter.sounds.mp3|*.mp3|filter.sounds.wav|*.wav", false, "importsound");
}
if (ti0 instanceof ImageTag) {
file = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp", true);
file = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp", true, "importimage");
}
if (ti0 instanceof ShapeTag) {
file = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.svg", true);
file = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.svg", true, "importshape");
}
if (ti0 instanceof MorphShapeTag) {
return replaceMorphShape((MorphShapeTag) ti0, create, true);
}
if (ti0 instanceof DefineVideoStreamTag) {
file = showImportFileChooser("filter.movies|*.flv", false);
file = showImportFileChooser("filter.movies|*.flv", false, "importmovie");
}
if (ti0 instanceof DefineBinaryDataTag) {
file = showImportFileChooser("", false);
file = showImportFileChooser("", false, "importbinarydata");
}
if (ti0 instanceof UnknownTag) {
file = showImportFileChooser("", false);
file = showImportFileChooser("", false, "importother");
}
if (file == null) {
return false;
@@ -5018,7 +5015,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
if (item instanceof DefineSpriteTag) {
String filter = "filter.images|*.gif";
File selectedFile = showImportFileChooser(filter, false);
File selectedFile = showImportFileChooser(filter, false, "importsprite");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
DefineSpriteTag sprite = (DefineSpriteTag) item;
@@ -5060,7 +5057,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (item instanceof ShapeTag) {
ShapeTag st = (ShapeTag) item;
String filter = "filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.svg";
File selectedFile = showImportFileChooser(filter, true);
File selectedFile = showImportFileChooser(filter, true, "importshape");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = null;
@@ -5110,7 +5107,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (item instanceof DefineBitsJPEG3Tag || item instanceof DefineBitsJPEG4Tag) {
ImageTag it = (ImageTag) item;
if (it.importSupported()) {
File selectedFile = showImportFileChooser("", false);
File selectedFile = showImportFileChooser("", false, "replacealpha");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = Helper.readFile(selfile.getAbsolutePath());
@@ -5162,14 +5159,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
export(true, selected);
}
public File showImportFileChooser(String filter, boolean imagePreview) {
return showImportFileChooser(filter, imagePreview, null);
public File showImportFileChooser(String filter, boolean imagePreview, String icon) {
return showImportFileChooser(filter, imagePreview, null, icon);
}
public File showImportFileChooser(String filter, boolean imagePreview, String title) {
public File showImportFileChooser(String filter, boolean imagePreview, String title, String icon) {
String[] filterArray = filter.length() > 0 ? filter.split("\\|") : new String[0];
JFileChooser fc = new JFileChooser();
JFileChooser fc = View.getFileChooserWithIcon(icon);
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
if (imagePreview) {
fc.setAccessory(new FileChooserImagePreview(fc));
@@ -222,7 +222,7 @@ public class NewFileDialog extends AppDialog {
pack();
setResizable(false);
View.centerScreen(this);
View.setWindowIcon(this);
View.setWindowIcon(this, "newswf");
setModal(true);
widthEditor.setValue(550);
@@ -29,6 +29,7 @@ import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
@@ -67,6 +68,7 @@ import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
@@ -320,6 +322,17 @@ public class View {
}
}
/**
* Sets icon of the window.
* @param f
* @param icon Icon identifier. Icon must exist in 16 and 32 variant
*/
public static void setWindowIcon(Window f, String icon) {
List<Image> images = new ArrayList<>();
images.add(loadImage(icon + "16"));
images.add(loadImage(icon + "32"));
f.setIconImages(images);
}
/**
* Sets icon of specified frame to ASDec icon
*
@@ -932,4 +945,17 @@ public class View {
}
}
}
public static JFileChooser getFileChooserWithIcon(String iconName) {
return new JFileChooser() {
@Override
protected JDialog createDialog(Component parent) throws HeadlessException {
JDialog dialog = super.createDialog(parent);
setWindowIcon(dialog, iconName);
dialog.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
return dialog;
}
};
}
}
@@ -120,7 +120,7 @@ public class BinaryDataEditor extends JPanel implements GenericTagEditor {
}
private void replaceActionPerformed(ActionEvent evt) {
File selectedFile = mainPanel.showImportFileChooser("", false);
File selectedFile = mainPanel.showImportFileChooser("", false, "importbinarydata");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = Helper.readFile(selfile.getAbsolutePath());
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB