Add drag-n-drop support for ISO files and ul.cfg. Last one opens new 'ul.cfg manager' window. Update few digits, version number.
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Dmitry Isaenko 2023-09-08 22:13:09 +03:00
parent b99357a361
commit ab47f1c960
10 changed files with 106 additions and 64 deletions

View file

@ -8,7 +8,7 @@
<name>Tihwin</name>
<artifactId>Tihwin</artifactId>
<version>2.3</version>
<version>2.4</version>
<url>https://github.com/developersu/${project.artifactId}/</url>
<description>
@ -160,8 +160,8 @@
</versionInfo>
<messages>
<startupErr>Startup error</startupErr>
<jreNotFoundErr>JDK not found</jreNotFoundErr>
<jreVersionErr>JDK Version mismatch</jreVersionErr>
<jreNotFoundErr>Please check your Java Runtime installation. JDK not found</jreNotFoundErr>
<jreVersionErr>Please check your Java Runtime installation. JDK Version mismatch</jreVersionErr>
<launcherErr>Launcher Error</launcherErr>
</messages>
</configuration>

View file

@ -20,6 +20,8 @@
*/
package tihwin;
import java.io.File;
public class AwesomeMediator {
private final static AwesomeMediator INSTANCE = new AwesomeMediator();
@ -33,4 +35,6 @@ public class AwesomeMediator {
public static void notifyAllConvertsEnded(){
INSTANCE.mainAppUi.notifySplitFinished();
}
public static void setDiskImage(File file){INSTANCE.mainAppUi.setDiskImageFile(file);}
}

View file

@ -33,8 +33,8 @@ import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.text.AbstractDocument;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.lang.reflect.Method;
import java.util.Locale;
@ -73,6 +73,7 @@ public class MainAppUi extends JFrame {
resourceBundle = ResourceBundle.getBundle("locale");
AwesomeMediator.setMainUi(this);
setLocationRelativeTo(null); // Set window on [kinda] center
new FilesDropListener(mainPanel);
setContentPane(mainPanel);
statusJPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.darkGray));
convertBtn.setEnabled(false);
@ -87,7 +88,15 @@ public class MainAppUi extends JFrame {
CDRadioButton.setSelected(true);
recentRomLocation = Settings.INSTANCE.getRomLocation();
destinationDirectoryLbl.setText(FilesHelper.getRealFolder(Settings.INSTANCE.getDestination()));
addWindowListener(getWindowListener());
addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent windowEvent) {
Settings.INSTANCE.setRomLocation(recentRomLocation);
Settings.INSTANCE.setDestination(destinationDirectoryLbl.getText());
Settings.INSTANCE.setDvdSelected(DVDRadioButton.isSelected());
Settings.INSTANCE.setLocale(((LocaleHolder) ulLangComboBox.getSelectedItem()).getLocaleCode());
}
});
Border fitMoreTextOnButtonBorder = BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(Color.gray),
@ -100,70 +109,32 @@ public class MainAppUi extends JFrame {
titleField.setBorder(new LineBorder(Color.lightGray));
}
private WindowListener getWindowListener() {
return new WindowListener() {
@Override
public void windowClosing(WindowEvent windowEvent) {
Settings.INSTANCE.setRomLocation(recentRomLocation);
Settings.INSTANCE.setDestination(destinationDirectoryLbl.getText());
Settings.INSTANCE.setDvdSelected(DVDRadioButton.isSelected());
Settings.INSTANCE.setLocale(
((LocaleHolder) ulLangComboBox.getSelectedItem()).getLocaleCode());
}
@Override
public void windowOpened(WindowEvent windowEvent) {
diskImageSelectBtn.grabFocus();
}
@Override
public void windowClosed(WindowEvent windowEvent) {
}
@Override
public void windowIconified(WindowEvent windowEvent) {
}
@Override
public void windowDeiconified(WindowEvent windowEvent) {
}
@Override
public void windowActivated(WindowEvent windowEvent) {
}
@Override
public void windowDeactivated(WindowEvent windowEvent) {
}
};
}
private void diskImageSelectEventHandler() {
try {
JFileChooser fileChooser = new JFileChooser(FilesHelper.getRealFolder(recentRomLocation));
fileChooser.setDialogTitle(resourceBundle.getString("SelectDiskImageText"));
fileChooser.setFileFilter(new IsoFileFilter());
if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
setDiskImageFile(fileChooser.getSelectedFile());
}
public void setDiskImageFile(File imageFile){
try {
recentRomLocation = imageFile.getParent();
ISO9660 iso9660 = new ISO9660(imageFile);
publisherTitle = iso9660.getTitle();
diskImageNameLbl.setText(imageFile.getName());
convertBtn.setEnabled(true);
statusLbl.setText(imageFile.getAbsolutePath());
diskImage = imageFile;
setProposedTitle();
} catch (Exception e) {
statusLbl.setText(e.getMessage());
e.printStackTrace();
}
}
private void setDiskImageFile(File imageFile) throws Exception {
recentRomLocation = imageFile.getParent();
ISO9660 iso9660 = new ISO9660(imageFile);
publisherTitle = iso9660.getTitle();
diskImageNameLbl.setText(imageFile.getName());
convertBtn.setEnabled(true);
statusLbl.setText(imageFile.getAbsolutePath());
diskImage = imageFile;
setProposedTitle();
}
private void setProposedTitle() {
String proposedName = diskImage.getName().replaceAll("(\\..*)|(\\[.*)", "").trim();
if (proposedName.length() > 31)
@ -177,7 +148,6 @@ public class MainAppUi extends JFrame {
JFileChooser fileChooser = new JFileChooser(FilesHelper.getRealFolder(destinationDirectoryLbl.getText()));
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setDialogTitle(resourceBundle.getString("SetDestinationDirectoryText"));
fileChooser.setFileFilter(new IsoFileFilter());
if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
setDestinationDir(fileChooser.getSelectedFile());
}

View file

@ -0,0 +1,68 @@
/*
Copyright 2023 Dmitry Isaenko
This file is part of Tihwin.
Tihwin 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.
Tihwin 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 Tihwin. If not, see <https://www.gnu.org/licenses/>.
*/
package tihwin.ui;
import tihwin.AwesomeMediator;
import tihwin.UpdateUlTableUi;
import javax.swing.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.*;
import java.io.File;
import java.util.List;
public class FilesDropListener extends DropTargetAdapter {
public FilesDropListener(JPanel panel){
new DropTarget(panel, DnDConstants.ACTION_COPY, this, true, null);
}
@Override
public void drop(DropTargetDropEvent event) {
if (! event.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
event.rejectDrop();
return;
}
event.acceptDrop(DnDConstants.ACTION_COPY);
Transferable transferable = event.getTransferable();
try {
List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
for (File file : files) {
if (file.isDirectory())
continue;
// Pick up first ISO file found and drop iteration
if (file.getName().toLowerCase().endsWith(".iso")) {
AwesomeMediator.setDiskImage(file);
break;
}
// If no ISO maybe there are ul.cfg than
if (file.isFile() && file.getName().equalsIgnoreCase("ul.cfg")){
new UpdateUlTableUi(file.getParentFile().getAbsolutePath());
break;
}
}
} catch (Exception e) {
e.printStackTrace();
event.rejectDrop();
}
event.dropComplete(true);
}
}

View file

@ -8,7 +8,7 @@ InterruptedAndFilesDeletedText=Task interrupted and file chunks deleted
InterruptedAndFilesNotDeletedText=Task interrupted and file chunks are NOT deleted
InterruptedText=Interrupted
isoFilesText=ISO files
WelcomeText=Welcome! It's Tihwin: ul-utility for your PS2! GPLv3+, 2022, Dmitry Isaenko
WelcomeText=Welcome! It's Tihwin: ul-utility for your PS2! GPLv3+, 2022-2023, Dmitry Isaenko
SelectBtn=Select
SelectDiskImageText=Select disk image
SetDestinationDirectoryText=Set destination directory

View file

@ -8,7 +8,7 @@ InterruptedAndFilesDeletedText=Tarea interrumpida y archivos fraccionados elimin
InterruptedAndFilesNotDeletedText=Tarea interrumpida y archivos fraccionados NO eliminados
InterruptedText=Interrumpido
isoFilesText=Archivos ISO
WelcomeText=Bienvenido! Soy Tihwin: una utilidad de formato ul para tu PS2! GPLv3+, 2022, Dmitry Isaenko
WelcomeText=Bienvenido! Soy Tihwin: una utilidad de formato ul para tu PS2! GPLv3+, 2022-2023, Dmitry Isaenko
SelectBtn=Seleccionar
SelectDiskImageText=Seleccionar imagen de disco
SetDestinationDirectoryText=Elegir directorio de destino

View file

@ -8,7 +8,7 @@ InterruptedAndFilesDeletedText=\u30BF\u30B9\u30AF\u304C\u4E2D\u65AD\u3055\u308C\
InterruptedAndFilesNotDeletedText=\u30BF\u30B9\u30AF\u306E\u4E2D\u65AD\u3068\u30D5\u30A1\u30A4\u30EB\u30C1\u30E3\u30F3\u30AF\u306E\u524A\u9664\u306F\u3055\u308C\u307E\u305B\u3093\u3002
InterruptedText=\u4E2D\u65AD
isoFilesText=ISO\u30D5\u30A1\u30A4\u30EB
WelcomeText=\u3088\u3046\u3053\u305D\uFF01 Tihwin: PS2\u306E\u305F\u3081\u306Eul-utility\u3067\u3059\uFF01 GPLv3+, 2022, Dmitry Isaenko
WelcomeText=\u3088\u3046\u3053\u305D\uFF01 Tihwin: PS2\u306E\u305F\u3081\u306Eul-utility\u3067\u3059\uFF01 GPLv3+, 2022-2023, Dmitry Isaenko
SelectBtn=\u9078\u629E
SelectDiskImageText=\u30C7\u30A3\u30B9\u30AF\u30A4\u30E1\u30FC\u30B8\u3092\u9078\u629E
SetDestinationDirectoryText=\u5B9B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u8A2D\u5B9A

View file

@ -8,7 +8,7 @@ InterruptedAndFilesDeletedText=\u30BF\u30B9\u30AF\u306C\u4E2D\u65AD\u3055\u308C\
InterruptedAndFilesNotDeletedText=\u30BF\u30B9\u30AF\u306C\u4E2D\u65AD\u3068\u3045\u30D5\u30A1\u30A4\u30EB\u30C1\u30E3\u30F3\u30AF\u306C\u524A\u9664\u30FC\u3055\u308A\u3084\u3073\u3089\u3093\u3002
InterruptedText=\u4E2D\u65AD
isoFilesText=ISO\u30D5\u30A1\u30A4\u30EB
WelcomeText=\u3081\u3093\u305D\u30FC\u308C\u30FC\uFF01 Tihwin: PS2\u306C\u305F\u307F\u306Cul-utility\u3084\u3044\u3073\u30FC\u3093\uFF01 GPLv3+, 2022, Dmitry Isaenko
WelcomeText=\u3081\u3093\u305D\u30FC\u308C\u30FC\uFF01 Tihwin: PS2\u306C\u305F\u307F\u306Cul-utility\u3084\u3044\u3073\u30FC\u3093\uFF01 GPLv3+, 2022-2023, Dmitry Isaenko
SelectBtn=\u9078\u629E
SelectDiskImageText=\u30C7\u30A3\u30B9\u30AF\u30A4\u30E1\u30FC\u30B8\u9078\u629E
SetDestinationDirectoryText=\u5B9B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306C\u8A2D\u5B9A

View file

@ -8,7 +8,7 @@ InterruptedAndFilesDeletedText=\uC791\uC5C5\uC774 \uC911\uB2E8\uB418\uACE0 \uD30
InterruptedAndFilesNotDeletedText=\uC791\uC5C5\uC774 \uC911\uB2E8\uB418\uACE0 \uD30C\uC77C \uCCAD\uD06C\uAC00 \uC0AD\uC81C\uB418\uC9C0 \uC54A\uC74C
InterruptedText=\uC911\uB2E8
isoFilesText=ISO \uD30C\uC77C
WelcomeText=\uD658\uC601\uD569\uB2C8\uB2E4! PS2\uC6A9 Tihwin: ul-\uC720\uD2F8\uB9AC\uD2F0\uC785\uB2C8\uB2E4! GPLv3+, 2022, \uB4DC\uBBF8\uD2B8\uB9AC \uC774\uC0AC\uC5D4\uCF54
WelcomeText=\uD658\uC601\uD569\uB2C8\uB2E4! PS2\uC6A9 Tihwin: ul-\uC720\uD2F8\uB9AC\uD2F0\uC785\uB2C8\uB2E4! GPLv3+, 2022-2023, \uB4DC\uBBF8\uD2B8\uB9AC \uC774\uC0AC\uC5D4\uCF54
SelectBtn=\uC120\uD0DD
SelectDiskImageText=\uB514\uC2A4\uD06C \uC774\uBBF8\uC9C0 \uC120\uD0DD
SetDestinationDirectoryText=\uB300\uC0C1 \uB514\uB809\uD1A0\uB9AC \uC124\uC815

View file

@ -8,7 +8,7 @@ InterruptedAndFilesDeletedText=\u0417\u0430\u0434\u0430\u0447\u0430 \u043F\u0440
InterruptedAndFilesNotDeletedText=\u0417\u0430\u0434\u0430\u0447\u0430 \u043F\u0440\u0435\u0440\u0432\u0430\u043D\u0430 \u0438 \u0444\u0440\u0430\u0433\u043C\u0435\u043D\u0442\u044B \u0444\u0430\u0439\u043B\u0430 \u041D\u0415 \u0443\u0434\u0430\u043B\u0435\u043D\u044B
InterruptedText=\u041F\u0440\u0435\u0440\u0432\u0430\u043D\u043E
isoFilesText=\u0424\u0430\u0439\u043B\u044B ISO
WelcomeText=\u041F\u0440\u0438\u0432\u0435\u0442! \u042D\u0442\u043E Tihwin \u2212 ul-\u0443\u0442\u0438\u043B\u0438\u0442\u0430 \u0434\u043B\u044F \u0432\u0430\u0448\u0435\u0439 PS2! GPLv3+, 2022, \u0414\u043C\u0438\u0442\u0440\u0438\u0439 \u0418\u0441\u0430\u0435\u043D\u043A\u043E
WelcomeText=\u041F\u0440\u0438\u0432\u0435\u0442! \u042D\u0442\u043E Tihwin \u2212 ul-\u0443\u0442\u0438\u043B\u0438\u0442\u0430 \u0434\u043B\u044F \u0432\u0430\u0448\u0435\u0439 PS2! GPLv3+, 2022-2023, \u0414\u043C\u0438\u0442\u0440\u0438\u0439 \u0418\u0441\u0430\u0435\u043D\u043A\u043E
SelectBtn=\u0412\u044B\u0431\u0440\u0430\u0442\u044C
SelectDiskImageText=\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043E\u0431\u0440\u0430\u0437 \u0434\u0438\u0441\u043A\u0430
SetDestinationDirectoryText=\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u043F\u0430\u043F\u043A\u0443 \u043D\u0430\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F