Moved progress indicator to status bar

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@220 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
Jared Gould 2006-08-12 17:52:20 +00:00
parent 980195e04f
commit 065b673d59
3 changed files with 40 additions and 41 deletions

View File

@ -55,6 +55,7 @@ public class ECUEditor extends JFrame implements WindowListener, PropertyChangeL
private JSplitPane splitPane = new JSplitPane(); private JSplitPane splitPane = new JSplitPane();
private ECUEditorToolBar toolBar; private ECUEditorToolBar toolBar;
private ECUEditorMenuBar menuBar; private ECUEditorMenuBar menuBar;
private JProgressPane statusPanel = new JProgressPane();
public ECUEditor() { public ECUEditor() {
@ -144,6 +145,7 @@ public class ECUEditor extends JFrame implements WindowListener, PropertyChangeL
this.setJMenuBar(menuBar); this.setJMenuBar(menuBar);
toolBar = new ECUEditorToolBar(this); toolBar = new ECUEditorToolBar(this);
this.add(toolBar, BorderLayout.NORTH); this.add(toolBar, BorderLayout.NORTH);
this.add(statusPanel, BorderLayout.SOUTH);
//set remaining window properties //set remaining window properties
setIconImage(new ImageIcon("./graphics/enginuity-ico.gif").getImage()); setIconImage(new ImageIcon("./graphics/enginuity-ico.gif").getImage());
@ -166,9 +168,13 @@ public class ECUEditor extends JFrame implements WindowListener, PropertyChangeL
DOMSettingsBuilder builder = new DOMSettingsBuilder(); DOMSettingsBuilder builder = new DOMSettingsBuilder();
try { try {
JProgressPane progress = new JProgressPane(this, "Saving settings...", "Saving settings..."); //JProgressPane progress = new JProgressPane(this, "Saving settings...", "Saving settings...");
builder.buildSettings(settings, new File("./settings.xml"), progress, version); builder.buildSettings(settings, new File("./settings.xml"), statusPanel, version);
} catch (IOException ex) { } } catch (IOException ex) {
} finally {
statusPanel.update("Ready...", 0);
repaint();
}
} }
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
@ -317,11 +323,6 @@ public class ECUEditor extends JFrame implements WindowListener, PropertyChangeL
} }
} }
public void repaintPanel() {
rightPanel.repaint();
rightPanel.update(rightPanel.getGraphics());
}
public void setUserLevel(int userLevel) { public void setUserLevel(int userLevel) {
settings.setUserLevel(userLevel); settings.setUserLevel(userLevel);
imageRoot.setUserLevel(userLevel, settings.isDisplayHighTables()); imageRoot.setUserLevel(userLevel, settings.isDisplayHighTables());
@ -343,15 +344,17 @@ public class ECUEditor extends JFrame implements WindowListener, PropertyChangeL
} }
public void openImage(File inputFile) throws XMLParseException, Exception { public void openImage(File inputFile) throws XMLParseException, Exception {
JProgressPane progress = new JProgressPane(this, "Opening file...", "Parsing ECU definitions...");
try { try {
repaintPanel(); update(getGraphics());
progress.update("Parsing ECU definitions...", 0); statusPanel.update("Parsing ECU definitions...", 0);
repaint();
byte[] input = readFile(inputFile); byte[] input = readFile(inputFile);
DOMRomUnmarshaller domUms = new DOMRomUnmarshaller(settings, this); DOMRomUnmarshaller domUms = new DOMRomUnmarshaller(settings, this);
DOMParser parser = new DOMParser(); DOMParser parser = new DOMParser();
progress.update("Finding ECU definition...", 10); statusPanel.update("Finding ECU definition...", 10);
repaint();
Rom rom; Rom rom;
// parse ecu definition files until result found // parse ecu definition files until result found
@ -362,12 +365,14 @@ public class ECUEditor extends JFrame implements WindowListener, PropertyChangeL
Document doc = parser.getDocument(); Document doc = parser.getDocument();
try { try {
rom = domUms.unmarshallXMLDefinition(doc.getDocumentElement(), input, progress); rom = domUms.unmarshallXMLDefinition(doc.getDocumentElement(), input, statusPanel);
progress.update("Populating tables...", 50); statusPanel.update("Populating tables...", 50);
rom.populateTables(input, progress); repaint();
rom.populateTables(input, statusPanel);
rom.setFileName(inputFile.getName()); rom.setFileName(inputFile.getName());
progress.update("Finalizing...", 90); statusPanel.update("Finalizing...", 90);
repaint();
addRom(rom); addRom(rom);
rom.setFullFileName(inputFile); rom.setFullFileName(inputFile);
return; return;
@ -386,7 +391,8 @@ public class ECUEditor extends JFrame implements WindowListener, PropertyChangeL
} finally { } finally {
// remove progress bar // remove progress bar
progress.dispose(); //progress.dispose();
statusPanel.update("Ready...", 0);
} }
} }

View File

@ -52,7 +52,7 @@ public class Rom implements Serializable {
// update progress // update progress
int currProgress = (int)((double)i / (double)getTables().size() * 40); int currProgress = (int)((double)i / (double)getTables().size() * 40);
progress.update("Populating " + tables.get(i).getName() + " table...", 40 + currProgress); progress.update("Populating tables...", 40 + currProgress);
try { try {
// if storageaddress has not been set (or is set to 0) omit table // if storageaddress has not been set (or is set to 0) omit table

View File

@ -1,43 +1,36 @@
package enginuity.swing; package enginuity.swing;
import java.awt.Component; import java.awt.BorderLayout;
import java.awt.GridLayout; import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JProgressBar; import javax.swing.JProgressBar;
import javax.swing.border.LineBorder;
public class JProgressPane extends JFrame { public class JProgressPane extends JPanel {
JLabel label = new JLabel(); JLabel label = new JLabel();
JProgressBar progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100); JProgressBar progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
public JProgressPane(Component component, String title, String status) { public JProgressPane() {
JPanel panel = new JPanel(); this.setPreferredSize(new Dimension(500, 18));
panel.setLayout(new GridLayout(2, 1)); this.setLayout(new BorderLayout(1, 2));
label.setHorizontalAlignment(JLabel.CENTER); label.setHorizontalAlignment(JLabel.CENTER);
label.setText(status); label.setText(" Ready...");
panel.add(label); label.setFont(new Font("Tahoma", Font.PLAIN, 11));
panel.add(progressBar); label.setHorizontalAlignment(JLabel.LEFT);
panel.setBorder(new LineBorder(getBackground(), 12)); progressBar.setMinimumSize(new Dimension(200, 50));
setSize(400,60); this.add(progressBar, BorderLayout.WEST);
setLocationRelativeTo(component); this.add(label, BorderLayout.CENTER);
setTitle(title);
setUndecorated(true);
getContentPane().add(panel);
setVisible(true);
requestFocus();
} }
public void update(String status, int percent) { public void update(String status, int percent) {
label.setText(status); label.setText(" " + status);
progressBar.setValue(percent); progressBar.setValue(percent);
//update(getGraphics()); repaint();
//requestFocus(); this.update(this.getGraphics());
} }
} }