mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-07 09:48:20 +00:00
#1202 Check for modifications outside FFDec and ask user to reload
This commit is contained in:
130
src/com/jpexs/decompiler/flash/gui/FilesChangedDialog.java
Normal file
130
src/com/jpexs/decompiler/flash/gui/FilesChangedDialog.java
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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 static com.jpexs.decompiler.flash.gui.AppDialog.CANCEL_OPTION;
|
||||
import static com.jpexs.decompiler.flash.gui.AppDialog.ERROR_OPTION;
|
||||
import static com.jpexs.decompiler.flash.gui.AppDialog.OK_OPTION;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FilesChangedDialog extends AppDialog {
|
||||
private final JButton okButton = new JButton(translate("button.ok"));
|
||||
|
||||
private final JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
|
||||
private JList<String> filesList;
|
||||
|
||||
private DefaultListModel<String> listModel;
|
||||
|
||||
|
||||
public FilesChangedDialog() {
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
setTitle(translate("dialog.title"));
|
||||
|
||||
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
clearList();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
|
||||
listModel = new DefaultListModel<>();
|
||||
JLabel label = new JLabel(translate("fileschanged"));
|
||||
label.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
cnt.add(label, BorderLayout.NORTH);
|
||||
filesList = new JList<String>(listModel);
|
||||
filesList.setBackground(Color.white);
|
||||
cnt.add(new JScrollPane(filesList), BorderLayout.CENTER);
|
||||
|
||||
JPanel panButtons = new JPanel(new FlowLayout());
|
||||
okButton.addActionListener(this::okButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
panButtons.add(okButton);
|
||||
panButtons.add(cancelButton);
|
||||
|
||||
add(panButtons, BorderLayout.SOUTH);
|
||||
|
||||
setAlwaysOnTop(true);
|
||||
View.setWindowIcon(this);
|
||||
setResizable(true);
|
||||
pack();
|
||||
View.centerScreen(this);
|
||||
}
|
||||
|
||||
public void addItem(String item) {
|
||||
if (listModel.contains(item)) {
|
||||
return;
|
||||
}
|
||||
listModel.addElement(item);
|
||||
filesList.setModel(listModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
super.setVisible(b);
|
||||
}
|
||||
|
||||
private void okButtonActionPerformed(ActionEvent evt) {
|
||||
setVisible(false);
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < listModel.size(); i++) {
|
||||
String fileName = listModel.elementAt(i);
|
||||
Main.reloadFile(new File(fileName));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void clearList() {
|
||||
listModel.clear();
|
||||
filesList.setModel(listModel);
|
||||
}
|
||||
|
||||
private void cancelButtonActionPerformed(ActionEvent evt) {
|
||||
clearList();
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user