diff --git a/resources/config/defaults.properties b/resources/config/defaults.properties index 9503188fd..c4995a250 100644 --- a/resources/config/defaults.properties +++ b/resources/config/defaults.properties @@ -50,6 +50,8 @@ impl.msghistory.IS_MESSAGE_HISTORY_ENABLED=true plugin.branding.ABOUT_LOGO_FONT_SIZE=14 plugin.branding.ABOUT_TEXT_INDENT=180 plugin.branding.SPLASH_SCREEN_TEXT_INDENT=190 +plugin.branding.LOADING_BUNDLE_PANEL_HEIGHT=40 +plugin.branding.LOADING_BUNDLE_PANEL_BORDER=10 plugin.branding.ABOUT_PARAGRAPH_GAP=10 # jabber accregwizz diff --git a/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java b/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java index 21b368359..527c6ac36 100644 --- a/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java +++ b/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java @@ -16,8 +16,19 @@ import net.java.sip.communicator.util.swing.*; +/** + * The WelcomeWindow is actually the splash screen shown while the + * application is loading. It displays the status of the loading process and + * some general information about the version, licenses and contact details. + * + * @author Yana Stamcheva + */ public class WelcomeWindow extends JDialog { + private static final int PREFERRED_WIDTH = 570; + + private static final int PREFERRED_HEIGHT = 330; + private static final String APPLICATION_NAME = BrandingActivator.getResources() .getSettingsString("service.gui.APPLICATION_NAME"); @@ -26,29 +37,31 @@ public class WelcomeWindow extends JDialog = BrandingActivator.getResources() .getSettingsInt("plugin.branding.SPLASH_SCREEN_TEXT_INDENT"); - private JLabel titleLabel = new JLabel(APPLICATION_NAME); + private final JLabel loadingLabel = new JLabel( + BrandingActivator.getResources() + .getI18NString("plugin.branding.LOADING") + ": "); - private JLabel versionLabel = new JLabel(" " - + System.getProperty("sip-communicator.version")); + private final JLabel bundleLabel = new JLabel(); - private JTextArea logoArea = new JTextArea( - BrandingActivator.getResources().getI18NString("plugin.branding.LOGO_MESSAGE")); + private final JPanel loadingPanel = new JPanel(new BorderLayout()); - private StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane(); + public WelcomeWindow() + { + JLabel titleLabel = new JLabel(APPLICATION_NAME); - private StyledHTMLEditorPane licenseArea = new StyledHTMLEditorPane(); + JLabel versionLabel = new JLabel(" " + + System.getProperty("sip-communicator.version")); - private JPanel textPanel = new JPanel(); + JTextArea logoArea = new JTextArea( + BrandingActivator.getResources() + .getI18NString("plugin.branding.LOGO_MESSAGE")); - private JPanel loadingPanel = new JPanel(new BorderLayout()); + StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane(); - private JLabel loadingLabel = new JLabel( - BrandingActivator.getResources().getI18NString("plugin.branding.LOADING") + ": "); + StyledHTMLEditorPane licenseArea = new StyledHTMLEditorPane(); - private JLabel bundleLabel = new JLabel(); + JPanel textPanel = new JPanel(); - public WelcomeWindow() - { Container mainPanel = new WindowBackground(); this.setTitle(APPLICATION_NAME); @@ -58,39 +71,106 @@ public WelcomeWindow() mainPanel.setLayout(new BorderLayout()); - this.textPanel.setPreferredSize(new Dimension(470, 280)); - this.textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS)); - this.textPanel + textPanel.setPreferredSize(new Dimension(470, 280)); + textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS)); + textPanel .setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15)); - this.textPanel.setOpaque(false); + textPanel.setOpaque(false); + + this.initTitleLabel(titleLabel); + + this.initVersionLabel(versionLabel); + + this.initLogoArea(logoArea); + + this.initRightsArea(rightsArea); + + this.initLicenseArea(licenseArea); + + this.initLoadingPanel(); + + textPanel.add(titleLabel); + textPanel.add(versionLabel); + textPanel.add(logoArea); + textPanel.add(rightsArea); + textPanel.add(licenseArea); + + mainPanel.add(textPanel, BorderLayout.CENTER); + mainPanel.add(loadingPanel, BorderLayout.SOUTH); - this.titleLabel.setFont( + this.getContentPane().add(mainPanel); + + this.setResizable(false); + + mainPanel.setPreferredSize( + new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT)); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + this.setLocation(screenSize.width / 2 - 527 / 2, + screenSize.height / 2 - 305 / 2); + + this.initCloseActions(); + } + + /** + * Initializes the title label. + * + * @param titleLabel the title label + */ + private void initTitleLabel(JLabel titleLabel) + { + titleLabel.setFont( titleLabel.getFont().deriveFont(Font.BOLD, 28)); - this.titleLabel.setForeground(Constants.TITLE_COLOR); - this.titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); + titleLabel.setForeground(Constants.TITLE_COLOR); + titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); + } - this.versionLabel.setFont( + /** + * Initializes the version label. + * + * @param versionLabel the version label + */ + private void initVersionLabel(JLabel versionLabel) + { + versionLabel.setFont( versionLabel.getFont().deriveFont(Font.BOLD, 18)); - this.versionLabel.setForeground(Constants.TITLE_COLOR); - this.versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); + versionLabel.setForeground(Constants.TITLE_COLOR); + versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); + } + /** + * Initializes the logo area. + * + * @param logoArea the logo area + */ + private void initLogoArea(JTextArea logoArea) + { int logoAreaFontSize = BrandingActivator.getResources(). getSettingsInt("plugin.branding.ABOUT_LOGO_FONT_SIZE"); - this.logoArea.setFont( + logoArea.setFont( logoArea.getFont().deriveFont(Font.BOLD, logoAreaFontSize)); - this.logoArea.setForeground(Constants.TITLE_COLOR); - this.logoArea.setOpaque(false); - this.logoArea.setLineWrap(true); - this.logoArea.setWrapStyleWord(true); - this.logoArea.setEditable(false); - this.logoArea.setPreferredSize(new Dimension(100, 20)); - this.logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT); - this.logoArea.setBorder(BorderFactory + logoArea.setForeground(Constants.TITLE_COLOR); + logoArea.setOpaque(false); + logoArea.setLineWrap(true); + logoArea.setWrapStyleWord(true); + logoArea.setEditable(false); + logoArea.setPreferredSize(new Dimension(100, 20)); + logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT); + logoArea.setBorder(BorderFactory .createEmptyBorder(20, DEFAULT_TEXT_INDENT, 0, 0)); + } - this.rightsArea.setContentType("text/html"); - this.rightsArea.appendToEnd(BrandingActivator.getResources().getI18NString( + /** + * Initializes the copyright area. + * + * @param rightsArea the copyright area. + */ + private void initRightsArea(StyledHTMLEditorPane rightsArea) + { + rightsArea.setContentType("text/html"); + rightsArea.appendToEnd( + BrandingActivator.getResources().getI18NString( "plugin.branding.WELCOME_MESSAGE", new String[]{ Constants.TEXT_COLOR, @@ -99,56 +179,69 @@ public WelcomeWindow() .getSettingsString("service.gui.APPLICATION_WEB_SITE") })); - this.rightsArea.setPreferredSize(new Dimension(50, 50)); - this.rightsArea + rightsArea.setPreferredSize(new Dimension(50, 50)); + rightsArea .setBorder(BorderFactory .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0)); - this.rightsArea.setOpaque(false); - this.rightsArea.setEditable(false); - this.rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT); + rightsArea.setOpaque(false); + rightsArea.setEditable(false); + rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT); + } - this.licenseArea.setContentType("text/html"); - this.licenseArea.appendToEnd(BrandingActivator.getResources().getI18NString( + /** + * Initializes the license area. + * + * @param licenseArea the license area. + */ + private void initLicenseArea(StyledHTMLEditorPane licenseArea) + { + licenseArea.setContentType("text/html"); + licenseArea.appendToEnd( + BrandingActivator.getResources().getI18NString( "plugin.branding.LICENSE", new String[] { Constants.TEXT_COLOR })); - this.licenseArea.setPreferredSize(new Dimension(50, 20)); - this.licenseArea.setBorder(BorderFactory + licenseArea.setPreferredSize(new Dimension(50, 20)); + licenseArea.setBorder(BorderFactory .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0)); - this.licenseArea.setOpaque(false); - this.licenseArea.setEditable(false); - this.licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT); + licenseArea.setOpaque(false); + licenseArea.setEditable(false); + licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT); + } + private void initLoadingPanel() + { this.bundleLabel.setFont(loadingLabel.getFont().deriveFont(Font.PLAIN)); this.loadingPanel.setOpaque(false); this.loadingPanel.add(loadingLabel, BorderLayout.WEST); this.loadingPanel.add(bundleLabel, BorderLayout.CENTER); - this.loadingPanel.setAlignmentX(Component.RIGHT_ALIGNMENT); - this.loadingPanel.setBorder( - BorderFactory.createEmptyBorder(10, 10, 10, 10)); - - this.textPanel.add(titleLabel); - this.textPanel.add(versionLabel); - this.textPanel.add(logoArea); - this.textPanel.add(rightsArea); - this.textPanel.add(licenseArea); - mainPanel.add(textPanel, BorderLayout.CENTER); - mainPanel.add(loadingPanel, BorderLayout.SOUTH); + int loadingPanelBorder + = BrandingActivator.getResources() + .getSettingsInt("plugin.branding.LOADING_BUNDLE_PANEL_BORDER"); - this.getContentPane().add(mainPanel); - - this.setResizable(false); + this.loadingPanel.setBorder( + BorderFactory.createEmptyBorder(loadingPanelBorder, + loadingPanelBorder, + loadingPanelBorder, + loadingPanelBorder)); - mainPanel.setPreferredSize(new Dimension(570, 330)); + int loadingPanelHeight + = BrandingActivator.getResources() + .getSettingsInt("plugin.branding.LOADING_BUNDLE_PANEL_HEIGHT"); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation(screenSize.width / 2 - 527 / 2, - screenSize.height / 2 - 305 / 2); + this.loadingPanel.setPreferredSize( + new Dimension(PREFERRED_WIDTH, loadingPanelHeight)); + } + /** + * Initializes close actions on mouse click and esc key. + */ + private void initCloseActions() + { // Close the splash screen on simple click or Esc. this.getGlassPane().addMouseListener(new MouseAdapter() { @@ -170,11 +263,19 @@ public void mouseClicked(MouseEvent e) imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close"); } + /** + * Disposes this window. + */ protected void close() { this.dispose(); } + /** + * Sets the name of the currently loading bundle. + * + * @param bundleName the name of the bundle to display + */ public void setBundle(String bundleName) { this.bundleLabel.setText(bundleName);