forked from Qortal/qortal
Show bootstrap statuses on splash frame.
This commit is contained in:
parent
35718f6215
commit
7e5dd62a92
@ -16,6 +16,7 @@ public class SplashFrame {
|
|||||||
|
|
||||||
private static SplashFrame instance;
|
private static SplashFrame instance;
|
||||||
private JFrame splashDialog;
|
private JFrame splashDialog;
|
||||||
|
private SplashPanel splashPanel;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class SplashPanel extends JPanel {
|
public static class SplashPanel extends JPanel {
|
||||||
@ -23,22 +24,39 @@ public class SplashFrame {
|
|||||||
|
|
||||||
private String defaultSplash = "Qlogo_512.png";
|
private String defaultSplash = "Qlogo_512.png";
|
||||||
|
|
||||||
|
private JLabel statusLabel;
|
||||||
|
|
||||||
public SplashPanel() {
|
public SplashPanel() {
|
||||||
image = Gui.loadImage(defaultSplash);
|
image = Gui.loadImage(defaultSplash);
|
||||||
|
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||||
}
|
setBorder(null);
|
||||||
|
|
||||||
@Override
|
// Add logo
|
||||||
protected void paintComponent(Graphics g) {
|
JLabel imageLabel = new JLabel(new ImageIcon(image));
|
||||||
super.paintComponent(g);
|
imageLabel.setSize(new Dimension(300, 300));
|
||||||
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
|
add(imageLabel);
|
||||||
|
|
||||||
|
// Add status label
|
||||||
|
statusLabel = new JLabel("Starting Qortal Core...", JLabel.CENTER);
|
||||||
|
statusLabel.setMaximumSize(new Dimension(500, 50));
|
||||||
|
statusLabel.setFont(new Font("Verdana", Font.PLAIN, 22));
|
||||||
|
statusLabel.setBackground(new Color(255, 255, 255));
|
||||||
|
statusLabel.setOpaque(true);
|
||||||
|
statusLabel.setBorder(null);
|
||||||
|
add(statusLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize() {
|
public Dimension getPreferredSize() {
|
||||||
return new Dimension(500, 500);
|
return new Dimension(500, 550);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateStatus(String text) {
|
||||||
|
if (statusLabel != null) {
|
||||||
|
statusLabel.setText(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +73,8 @@ public class SplashFrame {
|
|||||||
icons.add(Gui.loadImage("icons/Qlogo_128.png"));
|
icons.add(Gui.loadImage("icons/Qlogo_128.png"));
|
||||||
this.splashDialog.setIconImages(icons);
|
this.splashDialog.setIconImages(icons);
|
||||||
|
|
||||||
this.splashDialog.getContentPane().add(new SplashPanel());
|
this.splashPanel = new SplashPanel();
|
||||||
|
this.splashDialog.getContentPane().add(this.splashPanel);
|
||||||
this.splashDialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
this.splashDialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
this.splashDialog.setUndecorated(true);
|
this.splashDialog.setUndecorated(true);
|
||||||
this.splashDialog.pack();
|
this.splashDialog.pack();
|
||||||
@ -79,4 +98,8 @@ public class SplashFrame {
|
|||||||
this.splashDialog.dispose();
|
this.splashDialog.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateStatus(String text) {
|
||||||
|
this.splashPanel.updateStatus(text);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.qortal.controller.Controller;
|
|||||||
import org.qortal.data.account.MintingAccountData;
|
import org.qortal.data.account.MintingAccountData;
|
||||||
import org.qortal.data.block.BlockData;
|
import org.qortal.data.block.BlockData;
|
||||||
import org.qortal.data.crosschain.TradeBotData;
|
import org.qortal.data.crosschain.TradeBotData;
|
||||||
|
import org.qortal.gui.SplashFrame;
|
||||||
import org.qortal.repository.hsqldb.HSQLDBImportExport;
|
import org.qortal.repository.hsqldb.HSQLDBImportExport;
|
||||||
import org.qortal.repository.hsqldb.HSQLDBRepositoryFactory;
|
import org.qortal.repository.hsqldb.HSQLDBRepositoryFactory;
|
||||||
import org.qortal.settings.Settings;
|
import org.qortal.settings.Settings;
|
||||||
@ -302,14 +303,14 @@ public class Bootstrap {
|
|||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
|
|
||||||
LOGGER.info("Starting import of bootstrap...");
|
this.updateStatus("Starting import of bootstrap...");
|
||||||
|
|
||||||
this.doImport();
|
this.doImport();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
LOGGER.info("Bootstrap import failed: {}", e.getMessage());
|
LOGGER.info("Bootstrap import failed: {}", e.getMessage());
|
||||||
LOGGER.info("Retrying in 5 minutes");
|
this.updateStatus("Bootstrapping failed. Retrying in 5 minutes");
|
||||||
Thread.sleep(5 * 60 * 1000L);
|
Thread.sleep(5 * 60 * 1000L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,7 +364,7 @@ public class Bootstrap {
|
|||||||
String bootstrapFilename = this.getFilename();
|
String bootstrapFilename = this.getFilename();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Downloading bootstrap...");
|
this.updateStatus("Downloading bootstrap...");
|
||||||
String bootstrapUrl = String.format("%s/%s", bootstrapHost, bootstrapFilename);
|
String bootstrapUrl = String.format("%s/%s", bootstrapHost, bootstrapFilename);
|
||||||
InputStream in = new URL(bootstrapUrl).openStream();
|
InputStream in = new URL(bootstrapUrl).openStream();
|
||||||
Files.copy(in, path, REPLACE_EXISTING);
|
Files.copy(in, path, REPLACE_EXISTING);
|
||||||
@ -379,12 +380,12 @@ public class Bootstrap {
|
|||||||
blockchainLock.lockInterruptibly();
|
blockchainLock.lockInterruptibly();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Extracting bootstrap...");
|
this.updateStatus("Extracting bootstrap...");
|
||||||
Path input = path.toAbsolutePath();
|
Path input = path.toAbsolutePath();
|
||||||
Path output = path.toAbsolutePath().getParent().toAbsolutePath();
|
Path output = path.toAbsolutePath().getParent().toAbsolutePath();
|
||||||
SevenZ.decompress(input.toString(), output.toFile());
|
SevenZ.decompress(input.toString(), output.toFile());
|
||||||
|
|
||||||
LOGGER.info("Stopping repository...");
|
this.updateStatus("Stopping repository...");
|
||||||
// Close the repository while we are still able to
|
// Close the repository while we are still able to
|
||||||
// Otherwise, the caller will run into difficulties when it tries to close it
|
// Otherwise, the caller will run into difficulties when it tries to close it
|
||||||
repository.discardChanges();
|
repository.discardChanges();
|
||||||
@ -399,11 +400,11 @@ public class Bootstrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move the "bootstrap" folder in place of the "db" folder
|
// Move the "bootstrap" folder in place of the "db" folder
|
||||||
LOGGER.info("Moving files to output directory...");
|
this.updateStatus("Moving files to output directory...");
|
||||||
FileUtils.deleteDirectory(outputPath.toFile());
|
FileUtils.deleteDirectory(outputPath.toFile());
|
||||||
Files.move(inputPath, outputPath);
|
Files.move(inputPath, outputPath);
|
||||||
|
|
||||||
LOGGER.info("Starting repository from bootstrap...");
|
this.updateStatus("Starting repository from bootstrap...");
|
||||||
RepositoryFactory repositoryFactory = new HSQLDBRepositoryFactory(Controller.getRepositoryUrl());
|
RepositoryFactory repositoryFactory = new HSQLDBRepositoryFactory(Controller.getRepositoryUrl());
|
||||||
RepositoryManager.setRepositoryFactory(repositoryFactory);
|
RepositoryManager.setRepositoryFactory(repositoryFactory);
|
||||||
|
|
||||||
@ -413,4 +414,9 @@ public class Bootstrap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateStatus(String text) {
|
||||||
|
LOGGER.info(text);
|
||||||
|
SplashFrame.getInstance().updateStatus(text);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user