diff --git a/build.xml b/build.xml index ef384b037..f35d18d7e 100644 --- a/build.xml +++ b/build.xml @@ -725,7 +725,7 @@ bundle-plugin-msnaccregwizz,bundle-plugin-sipaccregwizz, bundle-plugin-yahooaccregwizz, bundle-version,bundle-version-impl,bundle-shutdown, - bundle-growlnotification,bundle-audionotifier"/> + bundle-growlnotification,bundle-audionotifier,bundle-plugin-splashscreen"/> @@ -1259,4 +1259,14 @@ javax.swing.event, javax.swing.border"/> prefix="net/java/sip/communicator/plugin/exampleplugin"/> + + + + + + + + diff --git a/lib/felix.client.run.properties b/lib/felix.client.run.properties index c6027b2d0..a09228bdc 100644 --- a/lib/felix.client.run.properties +++ b/lib/felix.client.run.properties @@ -45,10 +45,12 @@ felix.auto.start.1= reference:file:lib/bundle/org.apache.felix.servicebinder-0.8 felix.auto.start.2= \ reference:file:sc-bundles/util.jar -felix.auto.start.3= \ + +felix.auto.start.4= \ reference:file:sc-bundles/configuration.jar \ reference:file:sc-bundles/version.jar \ reference:file:sc-bundles/version-impl.jar \ + reference:file:sc-bundles/splashscreen.jar \ reference:file:sc-bundles/fileaccess.jar \ reference:file:sc-bundles/protocol.jar \ reference:file:sc-bundles/contactlist.jar \ @@ -61,7 +63,7 @@ felix.auto.start.3= \ reference:file:sc-bundles/netaddr.jar \ reference:file:sc-bundles/meta-cl.jar -felix.auto.start.4= \ +felix.auto.start.5= \ reference:file:sc-bundles/history.jar \ reference:file:sc-bundles/msghistory.jar \ reference:file:sc-bundles/callhistory.jar \ diff --git a/src/net/java/sip/communicator/impl/gui/GuiActivator.java b/src/net/java/sip/communicator/impl/gui/GuiActivator.java index 12a445734..5e871d4f1 100644 --- a/src/net/java/sip/communicator/impl/gui/GuiActivator.java +++ b/src/net/java/sip/communicator/impl/gui/GuiActivator.java @@ -10,11 +10,8 @@ import javax.swing.*; -import org.osgi.framework.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.login.*; -import net.java.sip.communicator.launcher.*; -import net.java.sip.communicator.launcher.WelcomeWindow.*; import net.java.sip.communicator.service.audionotifier.*; import net.java.sip.communicator.service.callhistory.*; import net.java.sip.communicator.service.configuration.*; @@ -24,6 +21,8 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import org.osgi.framework.*; + /** * The GUI Activator class. * @@ -88,9 +87,6 @@ public void start(BundleContext bundleContext) throws Exception { logger.info("UI Service ...[REGISTERED]"); - //used by the splash screen to determine when the ui service is started - System.setProperty("uiService", "started"); - communicatorMain.showCommunicator(true); SwingUtilities.invokeLater(new RunLogin()); } diff --git a/src/net/java/sip/communicator/launcher/SIPCommunicator.java b/src/net/java/sip/communicator/launcher/SIPCommunicator.java index 6c92e8234..c07081fdd 100644 --- a/src/net/java/sip/communicator/launcher/SIPCommunicator.java +++ b/src/net/java/sip/communicator/launcher/SIPCommunicator.java @@ -22,12 +22,7 @@ public class SIPCommunicator */ public static void main(String[] args) throws Exception - { - WelcomeWindow welcomeWindow = new WelcomeWindow(); - - welcomeWindow.pack(); - welcomeWindow.setVisible(true); - + { Main.main(args); } } diff --git a/src/net/java/sip/communicator/launcher/aboutWindowBackground.png b/src/net/java/sip/communicator/launcher/aboutWindowBackground.png deleted file mode 100644 index 4a178171d..000000000 Binary files a/src/net/java/sip/communicator/launcher/aboutWindowBackground.png and /dev/null differ diff --git a/src/net/java/sip/communicator/plugin/splashscreen/SplashScreenActivator.java b/src/net/java/sip/communicator/plugin/splashscreen/SplashScreenActivator.java new file mode 100644 index 000000000..fb7c38b01 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/splashscreen/SplashScreenActivator.java @@ -0,0 +1,57 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.plugin.splashscreen; + +import net.java.sip.communicator.service.gui.*; + +import org.osgi.framework.*; + +public class SplashScreenActivator + implements BundleActivator, + ServiceListener, + BundleListener +{ + private WelcomeWindow welcomeWindow; + private BundleContext bundleContext; + + public void start(BundleContext bundleContext) throws Exception + { + this.bundleContext = bundleContext; + + welcomeWindow = new WelcomeWindow(); + + welcomeWindow.pack(); + welcomeWindow.setVisible(true); + + this.bundleContext.addServiceListener(this); + this.bundleContext.addBundleListener(this); + } + + public void stop(BundleContext arg0) throws Exception + { + + } + + public void serviceChanged(ServiceEvent evt) + { + ServiceReference serviceRef = evt.getServiceReference(); + + if(serviceRef.getBundle().getState() != Bundle.STARTING) + return; + + if (bundleContext.getServiceReference(UIService.class.getName()) + == serviceRef) + { + this.welcomeWindow.close(); + } + } + + public void bundleChanged(BundleEvent evt) + { + welcomeWindow.setBundle(evt.getBundle().getHeaders().get("Bundle-Name").toString()); + } +} diff --git a/src/net/java/sip/communicator/launcher/WelcomeWindow.java b/src/net/java/sip/communicator/plugin/splashscreen/WelcomeWindow.java similarity index 65% rename from src/net/java/sip/communicator/launcher/WelcomeWindow.java rename to src/net/java/sip/communicator/plugin/splashscreen/WelcomeWindow.java index 252e6a45b..d6dcb6dab 100644 --- a/src/net/java/sip/communicator/launcher/WelcomeWindow.java +++ b/src/net/java/sip/communicator/plugin/splashscreen/WelcomeWindow.java @@ -1,15 +1,11 @@ -package net.java.sip.communicator.launcher; +package net.java.sip.communicator.plugin.splashscreen; import java.awt.*; -import java.awt.event.*; -import java.io.*; -import javax.imageio.*; import javax.swing.*; public class WelcomeWindow extends JDialog - implements ActionListener { private WindowBackground mainPanel = new WindowBackground(); @@ -17,8 +13,8 @@ public class WelcomeWindow private JLabel titleLabel = new JLabel( "SIP Communicator"); - //private JLabel versionLabel = new JLabel( - // " " + System.getProperty("sip-communicator.version")); + private JLabel versionLabel = new JLabel( + " " + System.getProperty("sip-communicator.version")); private JTextArea logoArea = new JTextArea("Open Source VoIP & Instant Messaging"); @@ -38,6 +34,12 @@ public class WelcomeWindow private static final Font FONT = new Font(FONT_NAME, Font.PLAIN, new Integer(FONT_SIZE).intValue()); + private JPanel loadingPanel = new JPanel(new BorderLayout()); + + private JLabel loadingLabel = new JLabel("Loading: "); + + private JLabel bundleLabel = new JLabel(); + public WelcomeWindow() { this.setTitle("SIP Communicator"); @@ -48,16 +50,16 @@ public WelcomeWindow() this.textPanel.setPreferredSize(new Dimension(470, 240)); this.textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS)); - this.textPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); + this.textPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15)); this.textPanel.setOpaque(false); this.titleLabel.setFont(FONT.deriveFont(Font.BOLD, 28)); this.titleLabel.setForeground(DARK_BLUE); this.titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); - //this.versionLabel.setFont(FONT.deriveFont(Font.BOLD, 18)); - //this.versionLabel.setForeground(Color.GRAY); - //this.versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); + this.versionLabel.setFont(FONT.deriveFont(Font.BOLD, 18)); + this.versionLabel.setForeground(Color.GRAY); + this.versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); this.logoArea.setFont(FONT.deriveFont(Font.BOLD, 12)); this.logoArea.setForeground(DARK_BLUE); @@ -67,7 +69,7 @@ public WelcomeWindow() this.logoArea.setEditable(false); this.logoArea.setPreferredSize(new Dimension(100, 20)); this.logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT); - this.logoArea.setBorder(BorderFactory.createEmptyBorder(20, 200, 0, 0)); + this.logoArea.setBorder(BorderFactory.createEmptyBorder(20, 180, 0, 0)); this.rightsArea.setContentType("text/html"); this.rightsArea.setText( @@ -96,84 +98,45 @@ public WelcomeWindow() this.licenseArea.setEditable(false); this.licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT); + 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.textPanel.add(titleLabel); - //this.textPanel.add(versionLabel); + this.textPanel.add(versionLabel); this.textPanel.add(logoArea); this.textPanel.add(rightsArea); this.textPanel.add(licenseArea); - + this.mainPanel.add(textPanel, BorderLayout.CENTER); - + this.mainPanel.add(loadingPanel, BorderLayout.SOUTH); + this.getContentPane().add(mainPanel); this.setResizable(false); - this.mainPanel.setPreferredSize(new Dimension(527, 305)); + this.mainPanel.setPreferredSize(new Dimension(570, 330)); this.setLocation( Toolkit.getDefaultToolkit().getScreenSize().width/2 - 527/2, Toolkit.getDefaultToolkit().getScreenSize().height/2 - 305/2 - ); - - - Timer timer = new Timer(200, this); - - timer.setRepeats(true); - timer.start(); + ); } - protected void close(boolean isEscaped) + protected void close() { this.dispose(); } - - /** - * Constructs the window background in order to have a background image. - */ - private class WindowBackground extends JPanel { - - private Image bgImage; - - public WindowBackground() { - try - { - bgImage = ImageIO.read( - WelcomeWindow.class.getResource("aboutWindowBackground.png")); - } - catch (IOException e) - { - e.printStackTrace(); - } - - this.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); - } - - protected void paintComponent(Graphics g) { - super.paintComponent(g); - - Graphics2D g2d = (Graphics2D) g; - - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - Graphics2D g2 = (Graphics2D) g; - - g2.drawImage(bgImage, 0, 0, null); - - g2.setColor(new Color(255, 255, 255, 100)); - - g2.fillRect(0, 0, getWidth(), getHeight()); - } - } - - public void actionPerformed(ActionEvent e) + + public void setBundle(String bundleName) { - if(System.getProperty("uiService") != null - && System.getProperty("uiService").equals("started")) - { - this.dispose(); - } + this.bundleLabel.setText(bundleName); + + this.loadingPanel.revalidate(); + this.loadingPanel.repaint(); } } diff --git a/src/net/java/sip/communicator/plugin/splashscreen/WindowBackground.java b/src/net/java/sip/communicator/plugin/splashscreen/WindowBackground.java new file mode 100644 index 000000000..014a0b514 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/splashscreen/WindowBackground.java @@ -0,0 +1,55 @@ +package net.java.sip.communicator.plugin.splashscreen; + +import java.awt.*; +import java.io.*; + +import javax.imageio.*; +import javax.swing.*; + +/** + * Constructs the window background in order to have a background image. + */ +public class WindowBackground + extends JPanel +{ + + private Image bgImage; + + public WindowBackground() + { + this.setOpaque(true); + + try + { + bgImage = ImageIO.read(WindowBackground.class + .getResource("aboutWindowBackground.png")); + } + catch (IOException e) + { + e.printStackTrace(); + } + + this.setPreferredSize(new Dimension(bgImage.getWidth(this), bgImage + .getHeight(this))); + } + + protected void paintComponent(Graphics g) + { + super.paintComponent(g); + + Graphics2D g2 = (Graphics2D) g; + + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + g2.drawImage(bgImage, 0, 0, null); + + g2.setColor(new Color(255, 255, 255, 170)); + + g2.fillRect(0, 0, getWidth(), getHeight()); + + g2.setColor(new Color(150, 150, 150)); + + g2.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5); + } +} diff --git a/src/net/java/sip/communicator/plugin/splashscreen/WindowTransparentBackground.java b/src/net/java/sip/communicator/plugin/splashscreen/WindowTransparentBackground.java new file mode 100644 index 000000000..1b824cf3c --- /dev/null +++ b/src/net/java/sip/communicator/plugin/splashscreen/WindowTransparentBackground.java @@ -0,0 +1,171 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package net.java.sip.communicator.plugin.splashscreen; + +import java.awt.*; +import java.awt.event.*; +import java.awt.image.*; +import java.io.*; + +import javax.imageio.*; +import javax.swing.*; + +/** + * The WindowBackground is a JComponent, which is + * added to a Window in order to make it transparent. + *

+ * How to use the WindowBackground? + * The WindowBackground is created and added to the content pane + * of the Window that should be made transparent. All other components + * then are added to the WindowBackground component and not + * directly to the window content pane. + *

+ * How it works? + * The WindowBackground is a JComponent which is not + * really transparent, but only looks like. It overrides the + * paintComponent method of JComponent to paint its + * own background image, which is an exact image of the screen at the position + * where the window will apear and with the same size. The + * java.awt.Robot class is used to make the screen capture. + *

+ * Note that the effect of transparence is gone when behind there is an + * application which shows dynamic images or something the moves, like + * a movie for example. + * + * @author Yana Stamcheva + */ + +public class WindowTransparentBackground + extends JPanel + implements ActionListener +{ + private BufferedImage bg1; + + private BufferedImage bg2; + + private BufferedImage bg3; + + private BufferedImage bg4; + + private Robot robot; + + private Image bgImage; + + private Timer refreshBgTimer; + + private int bgX; + + private int bgY; + + private int bgWidth; + + private int bgHeight; + + /** + * Creates an instance of WindowBackground by specifying + * the parent Window - this is the window that should be made + * transparent. + * + * @param window The parent Window + */ + public WindowTransparentBackground() { + + try { + robot = new Robot(); + + bgImage = ImageIO.read( + WindowBackground.class.getResource("aboutWindowBackground.png")); + + bgWidth = bgImage.getWidth(null); + + bgHeight = bgImage.getHeight(null); + + bgX = Toolkit.getDefaultToolkit().getScreenSize().width/2 + - bgWidth/2; + + bgY = Toolkit.getDefaultToolkit().getScreenSize().width/2 + - bgHeight/2; + + } catch (AWTException e) { + + e.printStackTrace(); + + return; + } + catch (IOException e) + { + e.printStackTrace(); + + return; + } + + this.updateBackground(bgX, bgY, bgWidth, bgHeight); + + refreshBgTimer = new Timer(4000, this); + + refreshBgTimer.setRepeats(true); + refreshBgTimer.start(); + } + + /** + * Updates the background. Makes a new screen capture at the given + * coordiantes. + * + * @param x The x coordinate. + * @param y The y coordinate. + */ + public void updateBackground(int x, int y, int w, int h) { + + this.bg1 = robot.createScreenCapture(new Rectangle(x, y, 30, 30)); + + this.bg2 = robot.createScreenCapture(new Rectangle(w - 30, y, 30, 30)); + + this.bg3 = robot.createScreenCapture(new Rectangle(x, h - 30, 30, 30)); + + this.bg4 = robot.createScreenCapture(new Rectangle(w - 30, y - 30, 30, 30)); + } + + public void stopRefresh() + { + refreshBgTimer.stop(); + this.robot = null; + } + + + /** + * Overrides the paintComponent method in JComponent + * to paint the screen capture image as a background of this component. + */ + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + Graphics2D g2 = (Graphics2D) g; + + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + g2.drawImage(this.bg1, 0, 0, null); + g2.drawImage(this.bg2, bgWidth - 30, 0, null); + g2.drawImage(this.bg3, 0, bgHeight - 30, null); + g2.drawImage(this.bg4, bgWidth - 30, bgHeight - 30, null); + + g2.drawImage(bgImage, 1, 1, null); + + g2.setColor(new Color(255, 255, 255, 130)); + + g2.fillRoundRect(0, 0, bgWidth, bgHeight, 40, 40); + } + + public void actionPerformed(ActionEvent e) + { + this.updateBackground(bgX, bgY, bgWidth, bgHeight); + + this.revalidate(); + this.repaint(); + } +} \ No newline at end of file diff --git a/src/net/java/sip/communicator/plugin/splashscreen/aboutWindowBackground.png b/src/net/java/sip/communicator/plugin/splashscreen/aboutWindowBackground.png new file mode 100644 index 000000000..134e28bc8 Binary files /dev/null and b/src/net/java/sip/communicator/plugin/splashscreen/aboutWindowBackground.png differ diff --git a/src/net/java/sip/communicator/plugin/splashscreen/splashscreen.manifest.mf b/src/net/java/sip/communicator/plugin/splashscreen/splashscreen.manifest.mf new file mode 100755 index 000000000..0ac55f24c --- /dev/null +++ b/src/net/java/sip/communicator/plugin/splashscreen/splashscreen.manifest.mf @@ -0,0 +1,11 @@ +Bundle-Activator: net.java.sip.communicator.plugin.splashscreen.SplashScreenActivator +Bundle-Name: Splash Screen plugin +Bundle-Description: Splash Screen plugin. +Bundle-Vendor: sip-communicator.org +Bundle-Version: 0.0.1 +Import-Package: org.osgi.framework, + net.java.sip.communicator.service.gui, + net.java.sip.communicator.service.gui.event, + javax.swing, + javax.swing.event, + javax.imageio