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

View File

@ -52,7 +52,7 @@ public class Rom implements Serializable {
// update progress
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 {
// if storageaddress has not been set (or is set to 0) omit table

View File

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