mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-01 19:04:38 +00:00
MainFrame construtor splitted, StatusPanel (with child controls) moved to a new component
This commit is contained in:
@@ -269,6 +269,15 @@ public class Configuration {
|
||||
}
|
||||
recentFiles.set(Helper.joinStrings(recentFilesArray, "::"));
|
||||
}
|
||||
|
||||
public static void removeRecentFile(String path) {
|
||||
List<String> recentFilesArray = new ArrayList<>(getRecentFiles());
|
||||
int idx = recentFilesArray.indexOf(path);
|
||||
if (idx != -1) {
|
||||
recentFilesArray.remove(idx);
|
||||
}
|
||||
recentFiles.set(Helper.joinStrings(recentFilesArray, "::"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves replacements to file for future use
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.ProgressListener;
|
||||
import com.jpexs.helpers.streams.SeekableInputStream;
|
||||
import com.jpexs.helpers.utf8.Utf8PrintWriter;
|
||||
import com.sun.jna.Platform;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -326,14 +325,14 @@ public class Main {
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return openFile(fileTitle, inputStream);
|
||||
return openFile(fileTitle, inputStream) == OpenFileResult.OK;
|
||||
} else if (inputStream instanceof BufferedInputStream) {
|
||||
try {
|
||||
((BufferedInputStream) inputStream).reset();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return openFile(fileTitle, inputStream);
|
||||
return openFile(fileTitle, inputStream) == OpenFileResult.OK;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -359,23 +358,26 @@ public class Main {
|
||||
reloadSWF();
|
||||
}
|
||||
|
||||
public static boolean openFile(String swfFile) {
|
||||
public static OpenFileResult openFile(String swfFile) {
|
||||
try {
|
||||
File file = new File(swfFile);
|
||||
swfFile = file.getCanonicalPath();
|
||||
Configuration.addRecentFile(swfFile);
|
||||
boolean ok = openFile(swfFile, new FileInputStream(swfFile));
|
||||
if (ok) {
|
||||
OpenFileResult openResult = openFile(swfFile, new FileInputStream(swfFile));
|
||||
if (openResult == OpenFileResult.OK) {
|
||||
readOnly = false;
|
||||
}
|
||||
return ok;
|
||||
return openResult;
|
||||
} catch (FileNotFoundException ex) {
|
||||
View.showMessageDialog(null, "File not found", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return OpenFileResult.NOT_FOUND;
|
||||
} catch (IOException ex) {
|
||||
View.showMessageDialog(null, "Cannot open file", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return OpenFileResult.ERROR;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean openFile(String fileTitle, InputStream is) {
|
||||
public static OpenFileResult openFile(String fileTitle, InputStream is) {
|
||||
Main.file = fileTitle;
|
||||
Main.inputStream = is;
|
||||
Main.fileTitle = fileTitle;
|
||||
@@ -400,7 +402,7 @@ public class Main {
|
||||
Main.loadingDialog.setVisible(true);
|
||||
OpenFileWorker wrk = new OpenFileWorker();
|
||||
wrk.execute();
|
||||
return true;
|
||||
return OpenFileResult.OK;
|
||||
}
|
||||
|
||||
public static boolean saveFileDialog() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 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 com.jpexs.helpers.CancellableWorker;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.BevelBorder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class MainFrameStatusPanel extends JPanel implements ActionListener {
|
||||
|
||||
static final String ACTION_SHOW_ERROR_LOG = "SHOWERRORLOG";
|
||||
|
||||
private MainFrame mainFrame;
|
||||
|
||||
private LoadingPanel loadingPanel = new LoadingPanel(20, 20);
|
||||
private JLabel statusLabel = new JLabel("");
|
||||
private JButton cancelButton = new JButton();
|
||||
private JButton errorNotificationButton;
|
||||
|
||||
private Timer blinkTimer;
|
||||
private int blinkPos;
|
||||
|
||||
private CancellableWorker currentWorker;
|
||||
|
||||
public MainFrameStatusPanel(MainFrame mainFrame) {
|
||||
this.mainFrame = mainFrame;
|
||||
createStatusPanel();
|
||||
}
|
||||
|
||||
private void createStatusPanel() {
|
||||
JPanel statusLeftPanel = new JPanel();
|
||||
statusLeftPanel.setLayout(new BoxLayout(statusLeftPanel, BoxLayout.X_AXIS));
|
||||
loadingPanel.setPreferredSize(new Dimension(30, 30));
|
||||
// todo: this button is a little bit ugly in the UI. Maybe it can be changed to an icon (as in NetBeans)
|
||||
cancelButton.setText(mainFrame.translate("button.cancel"));
|
||||
cancelButton.setPreferredSize(new Dimension(100, 30));
|
||||
cancelButton.setBorderPainted(false);
|
||||
cancelButton.setOpaque(false);
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (currentWorker != null) {
|
||||
currentWorker.cancel(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
statusLeftPanel.add(loadingPanel);
|
||||
statusLeftPanel.add(statusLabel);
|
||||
statusLeftPanel.add(cancelButton);
|
||||
setPreferredSize(new Dimension(1, 30));
|
||||
setBorder(new BevelBorder(BevelBorder.LOWERED));
|
||||
setLayout(new BorderLayout());
|
||||
add(statusLeftPanel, BorderLayout.WEST);
|
||||
|
||||
errorNotificationButton = new JButton("");
|
||||
errorNotificationButton.setIcon(View.getIcon("okay16"));
|
||||
errorNotificationButton.setBorderPainted(false);
|
||||
errorNotificationButton.setFocusPainted(false);
|
||||
errorNotificationButton.setContentAreaFilled(false);
|
||||
errorNotificationButton.setMargin(new Insets(2, 2, 2, 2));
|
||||
errorNotificationButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
errorNotificationButton.setActionCommand(ACTION_SHOW_ERROR_LOG);
|
||||
errorNotificationButton.addActionListener(this);
|
||||
errorNotificationButton.setToolTipText(mainFrame.translate("errors.none"));
|
||||
add(errorNotificationButton, BorderLayout.EAST);
|
||||
|
||||
loadingPanel.setVisible(false);
|
||||
cancelButton.setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_SHOW_ERROR_LOG:
|
||||
Main.displayErrorFrame();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void setStatus(String s) {
|
||||
statusLabel.setText(s);
|
||||
}
|
||||
|
||||
public void setWorkStatus(String s, CancellableWorker worker) {
|
||||
if (s.isEmpty()) {
|
||||
loadingPanel.setVisible(false);
|
||||
} else {
|
||||
loadingPanel.setVisible(true);
|
||||
}
|
||||
statusLabel.setText(s);
|
||||
currentWorker = worker;
|
||||
cancelButton.setVisible(worker != null);
|
||||
}
|
||||
|
||||
public void clearErrorState() {
|
||||
errorNotificationButton.setIcon(View.getIcon("okay16"));
|
||||
errorNotificationButton.setToolTipText(mainFrame.translate("errors.none"));
|
||||
}
|
||||
|
||||
public void setErrorState() {
|
||||
if (errorNotificationButton == null) {
|
||||
// todo: honfika
|
||||
// why null?
|
||||
return;
|
||||
}
|
||||
errorNotificationButton.setIcon(View.getIcon("error16"));
|
||||
errorNotificationButton.setToolTipText(mainFrame.translate("errors.present"));
|
||||
if (blinkTimer != null) {
|
||||
blinkTimer.cancel();
|
||||
}
|
||||
blinkTimer = new Timer();
|
||||
blinkTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
blinkPos++;
|
||||
if ((blinkPos % 2) == 0 || (blinkPos >= 4)) {
|
||||
errorNotificationButton.setIcon(View.getIcon("error16"));
|
||||
} else {
|
||||
errorNotificationButton.setIcon(null);
|
||||
errorNotificationButton.setSize(16, 16);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (blinkPos >= 4) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 500, 500);
|
||||
}
|
||||
|
||||
}
|
||||
28
trunk/src/com/jpexs/decompiler/flash/gui/OpenFileResult.java
Normal file
28
trunk/src/com/jpexs/decompiler/flash/gui/OpenFileResult.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum OpenFileResult {
|
||||
|
||||
OK,
|
||||
NOT_FOUND,
|
||||
ERROR
|
||||
}
|
||||
@@ -378,4 +378,4 @@ menu.recentFiles = Recent files
|
||||
|
||||
#after version 1.7.4
|
||||
work.restoringControlFlow.complete = Control flow restored
|
||||
|
||||
message.confirm.recentFileNotFound = File not found. Do you want to remove it from the recent file list?
|
||||
|
||||
@@ -378,3 +378,4 @@ menu.recentFiles = El\u0151zm\u00e9nyek
|
||||
|
||||
#after version 1.7.4
|
||||
work.restoringControlFlow.complete = Vez\u00e9rl\u00e9si-folyam helyre\u00e1ll\u00edt\u00e1s befejez\u0151d\u00f6tt
|
||||
message.confirm.recentFileNotFound = F\u00e1jl nem tal\u00e1lhat\u00f3. Szeretn\u00e9 elt\u00e1vol\u00edtani az el\u0151zm\u00e9nyek k\u00f6z\u00fcl?
|
||||
|
||||
Reference in New Issue
Block a user