• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

evolvedbinary / elemental / 982

29 Apr 2025 08:34PM UTC coverage: 56.409% (+0.007%) from 56.402%
982

push

circleci

adamretter
[feature] Improve README.md badges

28451 of 55847 branches covered (50.94%)

Branch coverage included in aggregate %.

77468 of 131924 relevant lines covered (58.72%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/exist-core/src/main/java/org/exist/launcher/SplashScreen.java
1
/*
2
 * Elemental
3
 * Copyright (C) 2024, Evolved Binary Ltd
4
 *
5
 * admin@evolvedbinary.com
6
 * https://www.evolvedbinary.com | https://www.elemental.xyz
7
 *
8
 * Use of this software is governed by the Business Source License 1.1
9
 * included in the LICENSE file and at www.mariadb.com/bsl11.
10
 *
11
 * Change Date: 2028-04-27
12
 *
13
 * On the date above, in accordance with the Business Source License, use
14
 * of this software will be governed by the Apache License, Version 2.0.
15
 *
16
 * Additional Use Grant: Production use of the Licensed Work for a permitted
17
 * purpose. A Permitted Purpose is any purpose other than a Competing Use.
18
 * A Competing Use means making the Software available to others in a commercial
19
 * product or service that: substitutes for the Software; substitutes for any
20
 * other product or service we offer using the Software that exists as of the
21
 * date we make the Software available; or offers the same or substantially
22
 * similar functionality as the Software.
23
 *
24
 * NOTE: Parts of this file contain code from 'The eXist-db Authors'.
25
 *       The original license header is included below.
26
 *
27
 * =====================================================================
28
 *
29
 * eXist-db Open Source Native XML Database
30
 * Copyright (C) 2001 The eXist-db Authors
31
 *
32
 * info@exist-db.org
33
 * http://www.exist-db.org
34
 *
35
 * This library is free software; you can redistribute it and/or
36
 * modify it under the terms of the GNU Lesser General Public
37
 * License as published by the Free Software Foundation; either
38
 * version 2.1 of the License, or (at your option) any later version.
39
 *
40
 * This library is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
43
 * Lesser General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU Lesser General Public
46
 * License along with this library; if not, write to the Free Software
47
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
48
 */
49
package org.exist.launcher;
50

51
import org.exist.jetty.JettyStart;
52
import org.exist.storage.BrokerPool;
53

54
import javax.swing.*;
55
import javax.swing.border.EmptyBorder;
56
import java.awt.*;
57
import java.net.URL;
58
import java.util.Observable;
59
import java.util.Observer;
60

61
import org.exist.SystemProperties;
62

63
/**
64
 * Display a splash screen showing the logo and a status line.
65
 *
66
 * @author Wolfgang Meier
67
 */
68
public class SplashScreen extends JFrame implements Observer, Comparable {
69

70
    private static final long serialVersionUID = -8449133653386075548L;
71

72
    private JLabel statusLabel;
73
    private JLabel versionLabel;
74
    private Launcher launcher;
75

76
    public SplashScreen(Launcher launcher) {
×
77
        this.launcher = launcher;
×
78
        setUndecorated(true);
×
79
        setBackground(new Color(255, 255, 255, 255));
×
80

81
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
×
82

83
        getContentPane().setBackground(new Color(255, 255, 255, 255));
×
84

85
        final URL imageURL = SplashScreen.class.getResource("logo.png");
×
86
        final ImageIcon icon = new ImageIcon(imageURL, "Elemental Logo");
×
87
        getContentPane().setLayout(new BorderLayout());
×
88

89
        // add the image label
90
        final JLabel imageLabel = new JLabel();
×
91
        imageLabel.setIcon(icon);
×
92
        final EmptyBorder border = new EmptyBorder(20, 20, 10, 20);
×
93
        imageLabel.setBorder(border);
×
94
        getContentPane().add(imageLabel, BorderLayout.NORTH);
×
95

96
        // version label
97
        final SystemProperties sysProps = SystemProperties.getInstance();
×
98
        final StringBuilder builder = new StringBuilder();
×
99
            builder.append("Version ");
×
100
        builder.append(sysProps.getSystemProperty("product-version", "unknown"));
×
101
        final String gitCommit = sysProps.getSystemProperty("git-commit");
×
102
        if (gitCommit != null && !gitCommit.isEmpty()) {
×
103
            builder.append(" (");
×
104
            builder.append(gitCommit, 0, Math.min(7, gitCommit.length()));
×
105
            builder.append(")");
×
106
        }
107
        versionLabel = new JLabel(builder.toString(), SwingConstants.CENTER);
×
108
        versionLabel.setFont(new Font(versionLabel.getFont().getName(), Font.BOLD, 10));
×
109
        versionLabel.setForeground(Color.black);
×
110
        versionLabel.setBorder(new EmptyBorder(10, 10, 10, 10));
×
111
        versionLabel.setSize(new Dimension(icon.getIconWidth(), 60));
×
112

113
        getContentPane().add(versionLabel, BorderLayout.CENTER);
×
114

115
        // message label
116
        statusLabel = new JLabel("Launching ...", SwingConstants.CENTER);
×
117
        statusLabel.setFont(new Font(statusLabel.getFont().getName(), Font.PLAIN, 16));
×
118
        statusLabel.setForeground(Color.black);
×
119
        statusLabel.setBorder(new EmptyBorder(10, 10, 10, 10));
×
120
        statusLabel.setSize(new Dimension(icon.getIconWidth(), 60));
×
121

122
        getContentPane().add(statusLabel, BorderLayout.SOUTH);
×
123
        // show it
124
        setSize(new Dimension(icon.getIconWidth() + 40, icon.getIconHeight() + 50));
×
125
        pack();
×
126
        this.setLocationRelativeTo(null);
×
127
        setVisible(true);
×
128

129
        // bring to front
130
        SwingUtilities.invokeLater(() -> {
×
131
            toFront();
×
132
            repaint();
×
133
        });
×
134
    }
×
135

136
    public void setStatus(final String status) {
137
        SwingUtilities.invokeLater(() -> statusLabel.setText(status));
×
138
    }
×
139

140
    public void update(Observable o, Object arg) {
141
        if (JettyStart.SIGNAL_STARTED.equals(arg)) {
×
142
            setStatus("Server started!");
×
143
            setVisible(false);
×
144
            launcher.signalStarted();
×
145
        } else if (BrokerPool.SIGNAL_STARTUP.equals(arg)) {
×
146
            setStatus("Starting Elemental ...");
×
147
        } else if (BrokerPool.SIGNAL_ABORTED.equals(arg)) {
×
148
            setVisible(false);
×
149
            launcher.showMessageAndExit("Startup aborted",
×
150
                "Elemental detected an error during recovery. This may not be fatal, " +
×
151
                "but to avoid possible damage, the db will now stop. Please consider " +
152
                "running a consistency check via the export tool and create " +
153
                "a backup if problems are reported. The db should come up again if you restart " +
154
                "it.", true);
×
155
        } else if (BrokerPool.SIGNAL_WRITABLE.equals(arg)) {
×
156
            setStatus("Elemental is up. Waiting for web server ...");
×
157
        } else if (JettyStart.SIGNAL_ERROR.equals(arg)) {
×
158
            setVisible(false);
×
159
            launcher.showMessageAndExit("Error Occurred",
×
160
                    "An error occurred during startup. Please check the logs.", true);
×
161
        } else if (BrokerPool.SIGNAL_SHUTDOWN.equals(arg)) {
×
162
            launcher.signalShutdown();
×
163
        } else {
×
164
            setStatus(arg.toString());
×
165
        }
166
    }
×
167

168
    @Override
169
    public int compareTo(Object other) {
170
        return other == this ? 0 : -1;
×
171
    }
172
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc