Index: core/src/META-INF/services/org.netbeans.core.StatusLineElementProvider =================================================================== RCS file: core/src/META-INF/services/org.netbeans.core.StatusLineElementProvider diff -N core/src/META-INF/services/org.netbeans.core.StatusLineElementProvider --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ core/src/META-INF/services/org.netbeans.core.StatusLineElementProvider 2 Mar 2005 09:51:07 -0000 1.1.2.2 @@ -0,0 +1,2 @@ +org.netbeans.core.ExceptionVisualizerProvider +#position=666 Index: core/src/org/netbeans/core/ExceptionVisualizerProvider.java =================================================================== RCS file: core/src/org/netbeans/core/ExceptionVisualizerProvider.java diff -N core/src/org/netbeans/core/ExceptionVisualizerProvider.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ core/src/org/netbeans/core/ExceptionVisualizerProvider.java 1 Mar 2005 16:47:25 -0000 1.1.2.2 @@ -0,0 +1,27 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.core; + +import java.awt.Component; +import org.netbeans.core.StatusLineElementProvider; + +/** + * + * @author Jiri Rechtacek + */ +public final class ExceptionVisualizerProvider implements StatusLineElementProvider { + public Component getStatusLineElement () { + return NotifyException.getNotificationVisualizer (); + } +} Index: core/src/org/netbeans/core/StatusLineElementProvider.java =================================================================== RCS file: core/src/org/netbeans/core/StatusLineElementProvider.java diff -N core/src/org/netbeans/core/StatusLineElementProvider.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ core/src/org/netbeans/core/StatusLineElementProvider.java 3 Mar 2005 09:17:40 -0000 1.1.2.2 @@ -0,0 +1,30 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.core; + +import java.awt.Component; + + +/** + * Provides a component which will be added at east side of the status line. + * The providers can be declared in module's MET-INF/services. + * + * @author Jiri Rechtacek + */ +public interface StatusLineElementProvider { + + /** Returns a component displayable in the status line. */ + public Component getStatusLineElement (); + +} Index: core/windows/src/org/netbeans/core/windows/view/ui/MainWindow.java =================================================================== RCS file: /cvs/core/windows/src/org/netbeans/core/windows/view/ui/MainWindow.java,v retrieving revision 1.44 retrieving revision 1.44.6.5 diff -u -r1.44 -r1.44.6.5 --- core/windows/src/org/netbeans/core/windows/view/ui/MainWindow.java 3 Feb 2005 15:59:12 -0000 1.44 +++ core/windows/src/org/netbeans/core/windows/view/ui/MainWindow.java 2 Mar 2005 14:06:21 -0000 1.44.6.5 @@ -19,7 +19,7 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; -import java.awt.Frame; +import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.Image; import java.awt.Rectangle; @@ -27,9 +27,12 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; +import java.lang.reflect.Method; import java.text.Format; import java.text.MessageFormat; import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; @@ -39,13 +42,14 @@ import javax.swing.JSeparator; import javax.swing.MenuElement; import javax.swing.MenuSelectionManager; +import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import org.netbeans.core.NotifyException; +import org.netbeans.core.StatusLineElementProvider; import org.netbeans.core.windows.Constants; import org.netbeans.core.windows.WindowManagerImpl; import org.openide.ErrorManager; @@ -57,6 +61,9 @@ import org.openide.filesystems.Repository; import org.openide.loaders.DataObject; import org.openide.util.HelpCtx; +import org.openide.util.Lookup; +import org.openide.util.LookupEvent; +import org.openide.util.LookupListener; import org.openide.util.NbBundle; import org.openide.util.Utilities; @@ -77,6 +84,8 @@ /** Inner panel which contains desktop component */ private JPanel desktopPanel; + private static JPanel innerIconsPanel; + /** Flag indicating main window is initialized. */ private boolean inited; @@ -147,14 +156,13 @@ status.setText(" "); // NOI18N status.setPreferredSize(new Dimension(0, status.getPreferredSize().height)); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(new JSeparator(), BorderLayout.NORTH); - panel.add(status, BorderLayout.CENTER); - Component exceptionStatus = NotifyException.getNotificationVisualizer(); - if( null != exceptionStatus ) - panel.add( exceptionStatus, BorderLayout.EAST ); - panel.setName("statusLine"); //NOI18N - getContentPane().add(panel, BorderLayout.SOUTH); + JPanel statusLinePanel = new JPanel(new BorderLayout()); + statusLinePanel.add(new JSeparator(), BorderLayout.NORTH); + statusLinePanel.add(status, BorderLayout.CENTER); + + decoratePanel (statusLinePanel); + statusLinePanel.setName("statusLine"); //NOI18N + getContentPane().add (statusLinePanel, BorderLayout.SOUTH); } else { // custom status line provided JComponent status = getCustomStatusLine(); if (status != null) { @@ -192,6 +200,56 @@ //#38810 end } + private static void decoratePanel (JPanel panel) { + assert SwingUtilities.isEventDispatchThread () : "Must run in AWT queue."; + if (innerIconsPanel != null) { + panel.remove (innerIconsPanel); + } + innerIconsPanel = getStatusLineElements (panel); + if (innerIconsPanel != null) { + panel.add (innerIconsPanel, BorderLayout.EAST); + } + } + + private static Lookup.Result result; + + // package-private because StatusLineElementProviderTest + static JPanel getStatusLineElements (JPanel panel) { + result = Lookup.getDefault ().lookup (new Lookup.Template (StatusLineElementProvider.class)); + result.addLookupListener (new StatusLineElementsListener (panel)); + Collection/**/ c = result.allInstances (); + if (c == null || c.isEmpty ()) { + return null; + } + Iterator it = c.iterator (); + JPanel icons = new JPanel (new FlowLayout ()); + boolean some = false; + while (it.hasNext ()) { + Object o = it.next (); + assert o instanceof StatusLineElementProvider; + Component comp = ((StatusLineElementProvider) o).getStatusLineElement (); + if (comp != null) { + some = true; + icons.add (comp); + } + } + return some ? icons : null; + } + + static private class StatusLineElementsListener implements LookupListener { + private JPanel decoratingPanel; + StatusLineElementsListener (JPanel decoratingPanel) { + this.decoratingPanel = decoratingPanel; + } + public void resultChanged (LookupEvent ev) { + SwingUtilities.invokeLater (new Runnable () { + public void run () { + decoratePanel (decoratingPanel); + } + }); + } + } + /** Creates and returns border for desktop which is visually aligned * with currently active LF */ private static Border getDesktopBorder () { @@ -238,18 +296,17 @@ if(Constants.SWITCH_STATUSLINE_IN_MENUBAR) { if (Constants.CUSTOM_STATUS_LINE_PATH == null) { JLabel status = new StatusLine(); - JPanel panel = new JPanel(new BorderLayout()); JSeparator sep = new JSeparator(JSeparator.VERTICAL); Dimension d = sep.getPreferredSize(); d.width += 6; // need a bit more padding... sep.setPreferredSize(d); - panel.add(sep, BorderLayout.WEST); - panel.add(status, BorderLayout.CENTER); - Component exceptionStatus = NotifyException.getNotificationVisualizer(); - if( null != exceptionStatus ) - panel.add( exceptionStatus, BorderLayout.EAST ); - panel.setName("statusLine"); //NOI18N - menu.add(panel); + JPanel statusLinePanel = new JPanel(new BorderLayout()); + statusLinePanel.add(sep, BorderLayout.WEST); + statusLinePanel.add(status, BorderLayout.CENTER); + + decoratePanel (statusLinePanel); + statusLinePanel.setName("statusLine"); //NOI18N + menu.add(statusLinePanel); } else { JComponent status = getCustomStatusLine(); if (status != null) { Index: core/windows/test/unit/src/org/netbeans/core/windows/view/ui/StatusLineElementProviderTest.java =================================================================== RCS file: core/windows/test/unit/src/org/netbeans/core/windows/view/ui/StatusLineElementProviderTest.java diff -N core/windows/test/unit/src/org/netbeans/core/windows/view/ui/StatusLineElementProviderTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ core/windows/test/unit/src/org/netbeans/core/windows/view/ui/StatusLineElementProviderTest.java 2 Mar 2005 14:06:22 -0000 1.1.2.1 @@ -0,0 +1,118 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.core.windows.view.ui; + +import java.awt.Component; +import java.util.Arrays; +import java.util.Collection; +import javax.swing.JLabel; +import javax.swing.JPanel; +import junit.textui.TestRunner; +import java.net.*; +import org.openide.util.Lookup; +import org.openide.util.lookup.AbstractLookup; +import org.openide.util.lookup.InstanceContent; +import org.openide.util.lookup.Lookups; + +import org.netbeans.junit.*; +import org.netbeans.core.*; + + +/** Test what MainWindow returns the Status Line Elements and + * a listener on lookup.result changes. + * @author Jiri Rechtacek + */ +public class StatusLineElementProviderTest extends NbTestCase { + + static { + System.setProperty ("org.openide.util.Lookup", "org.netbeans.core.windows.view.ui.StatusLineElementProviderTest$Lkp"); + } + + static private InstanceContent ic = null; + static private Impl impl1, impl2; + static private JPanel statusLine; + + public StatusLineElementProviderTest(String name) { + super(name); + } + + public static void main(String[] args) { + TestRunner.run(new NbTestSuite(StatusLineElementProviderTest.class)); + } + + protected boolean runInEQ () { + return true; + } + + protected void setUp() { + impl1 = new Impl ("First"); + impl2 = new Impl ("Second"); + statusLine = new JPanel (); + Lookup.getDefault (); + } + + public void testGetStatusLineElements () { + // initialy contains comp1 + JPanel panel = MainWindow.getStatusLineElements (statusLine); + assertNotNull ("getStatusLineElements() returns a panel.", panel); + assertEquals ("Panel contains only one component.", 1, panel.getComponentCount ()); + assertTrue ("Panel contains the component Comp1.", Arrays.asList (panel.getComponents ()).contains (impl1.myComponent)); + + // remove impl1 from lookup + ic.remove (impl1); + panel = MainWindow.getStatusLineElements (statusLine); + assertNull ("getStatusLineElements() returns null, panel: " + panel, panel); + + // add impl1 back + ic.add (impl1); + panel = MainWindow.getStatusLineElements (statusLine); + assertNotNull ("getStatusLineElements() returns a panel.", panel); + assertEquals ("Panel contains only one component.", 1, panel.getComponentCount ()); + assertTrue ("Panel contains the component Comp1.", Arrays.asList (panel.getComponents ()).contains (impl1.myComponent)); + + // add impl2 + ic.add (impl2); + panel = MainWindow.getStatusLineElements (statusLine); + assertNotNull ("getStatusLineElements() returns a panel.", panel); + assertEquals ("Panel contains two components.", 2, panel.getComponentCount ()); + assertTrue ("Panel contains the component from impl1.", Arrays.asList (panel.getComponents ()).contains (impl1.myComponent)); + assertTrue ("Panel contains the component from impl2.", Arrays.asList (panel.getComponents ()).contains (impl2.myComponent)); + } + + + public static final class Lkp extends AbstractLookup { + public Lkp () { + this (new InstanceContent ()); + } + + private Lkp (InstanceContent instanceContent) { + super (instanceContent); + ic = instanceContent; + ic.add (impl1); + } + } + + private static class Impl implements StatusLineElementProvider { + public Component myComponent; + private String myId; + public Impl (String id) { + myId = id; + } + public Component getStatusLineElement() { + myComponent = new JLabel (myId); + return myComponent; + } + } + +} \ No newline at end of file Index: autoupdate/libsrc/org/netbeans/updater/FlashingIcon.java =================================================================== RCS file: autoupdate/libsrc/org/netbeans/updater/FlashingIcon.java diff -N autoupdate/libsrc/org/netbeans/updater/FlashingIcon.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autoupdate/libsrc/org/netbeans/updater/FlashingIcon.java 1 Mar 2005 16:15:44 -0000 1.1.2.3 @@ -0,0 +1,201 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.updater; + +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JToolTip; +import org.openide.util.RequestProcessor; +import org.openide.util.RequestProcessor.Task; + +// XXX Copied from org.netbeans.core.FlashingIcon +/** + * + * A flashing icon to provide visual feedback for the user when something + * not very important happens in the system. + * The icon is flashed for a few seconds and then remains visible for a while longer. + * + * @author saubrecht + */ +abstract class FlashingIcon extends JComponent implements MouseListener { + + private static final long STOP_FLASHING_DELAY = 10 * 1000; + private static final long DISAPPEAR_DELAY_MILLIS = STOP_FLASHING_DELAY + 50 * 1000; + + private Icon icon; + + private boolean keepRunning = false; + private boolean isIconVisible = false; + private boolean keepFlashing = true; + private long startTime = 0; + private Task timerTask; + + /** + * Creates a new instance of FlashingIcon + * + * @param icon The icon that will be flashing (blinking) + */ + protected FlashingIcon( Icon icon ) { + this.icon = icon; + Dimension d = new Dimension( icon.getIconWidth(), icon.getIconHeight() ); + setMinimumSize( d ); + setMaximumSize( d ); + setPreferredSize( d ); + + addMouseListener( this ); + } + + /** + * Start flashing of the icon. If the icon is already flashing, the timer + * is reset. + * If the icon is visible but not flashing, it starts flashing again + * and the disappear timer is reset. + */ + public void startFlashing() { + synchronized( this ) { + startTime = System.currentTimeMillis(); + isIconVisible = !isIconVisible; + keepRunning = true; + keepFlashing = true; + if( null == timerTask ) { + timerTask = RequestProcessor.getDefault ().post (new Timer ()); + } else { + timerTask.run (); + } + } + repaint(); + } + + /** + * Stop the flashing and hide the icon. + */ + public void disappear() { + synchronized( this ) { + keepRunning = false; + isIconVisible = false; + keepFlashing = false; + if( null != timerTask ) + timerTask.cancel(); + timerTask = null; + setToolTipText( null ); + } + repaint(); + } + + /** + * Stop flashing of the icon. The icon remains visible and active (listens + * for mouse clicks and displays tooltip) until the disappear timer expires. + */ + public void stopFlashing() { + synchronized( this ) { + if( keepRunning && !isIconVisible ) { + isIconVisible = true; + repaint(); + } + } + keepFlashing = false; + } + + /** + * Switch the current image and repaint + */ + protected void flashIcon() { + isIconVisible = !isIconVisible; + + repaint(); + } + + public void paint(java.awt.Graphics g) { + if( isIconVisible ) { + icon.paintIcon( this, g, 0, 0 ); + } + } + + public void mouseReleased(MouseEvent e) {} + + public void mousePressed(MouseEvent e) { + stopFlashing(); + } + + public void mouseExited(MouseEvent e) { + stopFlashing(); + } + + public void mouseEntered(MouseEvent e) { + stopFlashing(); + } + + public void mouseClicked(MouseEvent e) { + if( isIconVisible ) { + disappear(); + onMouseClick(); + } + } + + /** + * Invoked when the user clicks the icon. + */ + protected abstract void onMouseClick(); + + /** + * Invoked when the disappear timer expired. + */ + protected abstract void timeout(); + + public Cursor getCursor() { + + if( isIconVisible ) { + return Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ); + } + return Cursor.getDefaultCursor(); + } + + public Point getToolTipLocation( MouseEvent event ) { + + JToolTip tip = createToolTip(); + tip.setTipText( getToolTipText() ); + Dimension d = tip.getPreferredSize(); + + + Point retValue = new Point( getWidth()-d.width, -d.height ); + return retValue; + } + + private class Timer implements Runnable { + public void run() { + synchronized( FlashingIcon.this ) { + long currentTime = System.currentTimeMillis(); + if( keepFlashing ) { + if( currentTime - startTime < STOP_FLASHING_DELAY ) { + flashIcon(); + } else { + stopFlashing(); + } + } + if( currentTime - startTime >= DISAPPEAR_DELAY_MILLIS ) { + disappear(); + timeout(); + } else { + if( null != timerTask ) + timerTask.schedule( 500 ); + } + } + } + } +} Index: autoupdate/libsrc/org/netbeans/updater/UpdaterFrame.java =================================================================== RCS file: /cvs/autoupdate/libsrc/org/netbeans/updater/UpdaterFrame.java,v retrieving revision 1.27 retrieving revision 1.27.6.2 diff -u -r1.27 -r1.27.6.2 Index: autoupdate/libsrc/org/netbeans/updater/resources/newUpdates.gif =================================================================== RCS file: autoupdate/libsrc/org/netbeans/updater/resources/newUpdates.gif diff -N autoupdate/libsrc/org/netbeans/updater/resources/newUpdates.gif Binary files /dev/null and /tmp/cvsTIayoe differ Index: autoupdate/src/org/netbeans/modules/autoupdate/AutoChecker.java =================================================================== RCS file: /cvs/autoupdate/src/org/netbeans/modules/autoupdate/AutoChecker.java,v retrieving revision 1.42 retrieving revision 1.42.8.4 diff -u -r1.42 -r1.42.8.4 --- autoupdate/src/org/netbeans/modules/autoupdate/AutoChecker.java 23 Jan 2005 16:27:49 -0000 1.42 +++ autoupdate/src/org/netbeans/modules/autoupdate/AutoChecker.java 2 Mar 2005 10:17:24 -0000 1.42.8.4 @@ -7,14 +7,15 @@ * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original - * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.autoupdate; +import java.awt.Component; import java.util.*; -import java.text.SimpleDateFormat; +import org.netbeans.updater.UpdaterFrame; import org.openide.util.NbBundle; import javax.swing.SwingUtilities; @@ -22,14 +23,18 @@ import org.openide.filesystems.*; import java.io.*; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import org.openide.util.RequestProcessor; +import org.openide.util.Utilities; +import org.netbeans.core.StatusLineElementProvider; /** This class checks for updates in given period * - * @author Petr Hrebejk + * @author Petr Hrebejk, Jiri Rechtacek */ -class AutoChecker extends Object - implements Runnable, - Wizard.Validator { +public class AutoChecker extends Object + implements Runnable, Wizard.Validator { /** Settings of autoupdate module */ private Settings settings; @@ -122,7 +127,16 @@ return; } } - + + RequestProcessor.getDefault ().post (new Runnable () { + public void run () { + runInner (); + } + }); + } + + void runInner () { + Autoupdater.setRunning( true ); Wizard.resetErrorStore (); @@ -135,28 +149,23 @@ if (at.isEnabled()) { countOfServer++; updates = at.connectForUpdates(); - updates.checkUpdates( this, at ); + updates.checkUpdates( this, at, true ); int res = Wizard.checkConnect(updates, at); - if ( res == ConnectingDialog.OK && - (updates.getTimeStamp() == null || at.getLastTimeStamp() == null || - at.getLastTimeStamp().before(updates.getTimeStamp()))) { + if (updates.getTimeStamp () == null || at.getLastTimeStamp () == null || + at.getLastTimeStamp ().before(updates.getTimeStamp ())) { allUpdates.put(at, updates); countOfConnectedServer++; - } else if (res == ConnectingDialog.SKIP && Wizard.getStoredErrorType () == Updates.NO_AVAILABLE_MODULES) { + } else if (Wizard.getStoredErrorType () == Updates.NO_AVAILABLE_MODULES) { countOfConnectedServer++; - } else if ( res == ConnectingDialog.CANCEL ) { - Autoupdater.setRunning( false ); - StatusDisplayer.getDefault().setStatusText( "" ); - return; } } } if ( countOfConnectedServer == 0 ) { if (Wizard.isErrorStored () && Updates.NO_NETWORK == Wizard.getStoredErrorType ()) { - ConnectingErrorDialog.showDialog (Updates.NO_NETWORK, null); + notifyError (Updates.NO_NETWORK); } else if (countOfServer == 0) { - ConnectingErrorDialog.showDialog(Updates.NO_SERVER_ERROR, null); + notifyError (Updates.NO_SERVER_ERROR); } canceled = true; Autoupdater.setRunning( false ); @@ -164,18 +173,10 @@ return; } - // report results after checking - Runnable runnable = new Runnable ( ) { - public void run() { - reportResults(); - } - }; - - javax.swing.SwingUtilities.invokeLater( runnable ); - + reportResults (); } - void reportResults() { + void reportResults () { Autoupdater.setRunning( false ); StatusDisplayer.getDefault().setStatusText( "" ); @@ -187,42 +188,73 @@ if ( allUpdates.size() == 0 ) { // Report it if necessary if ( settings.isNegativeResults() ) { - AutoCheckInfo info = new AutoCheckInfo( - NbBundle.getMessage( AutoChecker.class, "MSG_AutoCheck_NotFound" ), - javax.swing.JOptionPane.INFORMATION_MESSAGE - ); - info.showDialog(false); + noUpdatesFound (); } return; } - if ( getAllModules() != null && - getAllModules().size() > 0 ) { - - // Some modules found - - // by the task #39533, user has to be informed about modules found - // Check was fully automatic inform the user about found modules - // and ask him whether to proceed to the wizard. - AutoCheckInfo info = new AutoCheckInfo( - NbBundle.getMessage( AutoChecker.class, "MSG_AutoCheck_Found" ), - javax.swing.JOptionPane.INFORMATION_MESSAGE - ); - - if (info.showDialog(true)) { - Wizard.go( allUpdates ); - Autoupdater.setRunning (false); - } + if (getAllModules () != null && getAllModules ().size () > 0) { + notifyUpdates (); } else if ( settings.isNegativeResults() ) { // No modules found and we have to report negative results - AutoCheckInfo info = new AutoCheckInfo( - NbBundle.getMessage( AutoChecker.class, "MSG_AutoCheck_NotFound" ), - javax.swing.JOptionPane.INFORMATION_MESSAGE - ); - info.showDialog(false); + noUpdatesFound (); } + + } + + private void notifyUpdates () { + // Some modules found + Runnable onMouseClick = new Runnable () { + public void run () { + Wizard.go( allUpdates ); + } + }; + AvailableUpdateVisualizerProvider.UpdatesFlasher flasher = AvailableUpdateVisualizerProvider.getFlasher (onMouseClick); + assert flasher != null : "Updates Flasher cannot be null."; + flasher.setToolTipText (NbBundle.getMessage (AutoChecker.class, "MSG_AutoCheck_Found")); + flasher.startFlashing(); + } + + private void notifyError (final int errorType) { + if (settings.isNegativeResults ()) { + ConnectingErrorDialog.showDialog (errorType, null); + } else { + // Some modules found + Runnable onMouseClick = new Runnable () { + public void run () { + ConnectingErrorDialog.showDialog (errorType, null); + } + }; + ProblemsVisualizerProvider.UpdatesFlasher flasher = ProblemsVisualizerProvider.getFlasher (onMouseClick); + assert flasher != null : "Updates Flasher cannot be null."; + flasher.setToolTipText (errorType == Updates.NO_NETWORK ? + NbBundle.getMessage (AutoChecker.class, "CTL_NoNetwork_titleLabel") : + NbBundle.getMessage (AutoChecker.class, "CTL_NoServer_titleLabel")); + flasher.startFlashing(); + } + } + + private void updatesFound () { + // by the task #39533, user has to be informed about modules found + // Check was fully automatic inform the user about found modules + // and ask him whether to proceed to the wizard. + AutoCheckInfo info = new AutoCheckInfo( + NbBundle.getMessage( AutoChecker.class, "MSG_AutoCheck_Found" ), + javax.swing.JOptionPane.INFORMATION_MESSAGE + ); + if (info.showDialog(true)) { + Wizard.go( allUpdates ); + } + } + + private void noUpdatesFound () { + AutoCheckInfo info = new AutoCheckInfo( + NbBundle.getMessage( AutoChecker.class, "MSG_AutoCheck_NotFound" ), + javax.swing.JOptionPane.INFORMATION_MESSAGE + ); + info.showDialog(false); } private Collection getAllModules() { @@ -290,4 +322,5 @@ } } + } Index: autoupdate/src/org/netbeans/modules/autoupdate/AvailableUpdateVisualizerProvider.java =================================================================== RCS file: autoupdate/src/org/netbeans/modules/autoupdate/AvailableUpdateVisualizerProvider.java diff -N autoupdate/src/org/netbeans/modules/autoupdate/AvailableUpdateVisualizerProvider.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autoupdate/src/org/netbeans/modules/autoupdate/AvailableUpdateVisualizerProvider.java 1 Mar 2005 16:47:27 -0000 1.1.2.2 @@ -0,0 +1,80 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.modules.autoupdate; + +import java.awt.Component; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import org.netbeans.core.StatusLineElementProvider; +import org.openide.util.Utilities; + +/** + * + * @author Jiri Rechtacek + */ +public final class AvailableUpdateVisualizerProvider implements StatusLineElementProvider { + + public Component getStatusLineElement () { + return getUpdatesVisualizer (); + } + + private static UpdatesFlasher flasher = null; + + private static Runnable onMouseClick = null; + + /** + * Return an icon that is flashing when a new internal exception occurs. + * Clicking the icon opens the regular exception dialog box. The icon + * disappears (is hidden) after a short period of time and the exception + * list is cleared. + * + * @return A flashing icon component or null if console logging is switched on. + */ + private static Component getUpdatesVisualizer () { + if (null == flasher) { + ImageIcon img1 = new ImageIcon (Utilities.loadImage ("org/netbeans/modules/autoupdate/resources/newUpdates.gif", false)); + assert img1 != null : "Icon cannot be null."; + flasher = new UpdatesFlasher (img1); + } + return flasher; + } + + static UpdatesFlasher getFlasher (Runnable whatRunOnMouseClick) { + onMouseClick = whatRunOnMouseClick; + return flasher; + } + + static class UpdatesFlasher extends FlashingIcon { + public UpdatesFlasher (Icon img1) { + super (img1); + } + + /** + * User clicked the flashing icon, display the exception window. + */ + protected void onMouseClick () { + if (onMouseClick != null) { + onMouseClick.run (); + disappear (); + } + } + + /** + * The flashing icon disappeared (timed-out), clear the current + * exception list. + */ + protected void timeout () {} + } + +} Index: autoupdate/src/org/netbeans/modules/autoupdate/Bundle.properties =================================================================== RCS file: /cvs/autoupdate/src/org/netbeans/modules/autoupdate/Bundle.properties,v retrieving revision 1.144 retrieving revision 1.144.12.1 diff -u -r1.144 -r1.144.12.1 --- autoupdate/src/org/netbeans/modules/autoupdate/Bundle.properties 17 Dec 2004 15:51:56 -0000 1.144 +++ autoupdate/src/org/netbeans/modules/autoupdate/Bundle.properties 2 Mar 2005 10:22:47 -0000 1.144.12.1 @@ -389,7 +389,7 @@ # CTL_NoAvailableModules_textLabel=No available updates found on {0}. CTL_NoAvailableModules_textLabel=No available updates found on selected Update Servers. CTL_DefaultServer=Update Server -CTL_NoServer_textLabel=To check the web for available updates and new modules you should go to Project -> Settings -> AutoupdateType, add the appropriate update center service and enable it. +CTL_NoServer_textLabel=To check the web for available updates and new modules you should go to Tools -> Options -> IDE Configuration -> System -> Autoupdate Types, add the appropriate update center service and enable it. MSG_NoInfoXml=The NBM package {0} does not contain an Info/info.xml file. Index: autoupdate/src/org/netbeans/modules/autoupdate/Downloader.java =================================================================== RCS file: /cvs/autoupdate/src/org/netbeans/modules/autoupdate/Downloader.java,v retrieving revision 1.38 retrieving revision 1.38.14.1 diff -u -r1.38 -r1.38.14.1 --- autoupdate/src/org/netbeans/modules/autoupdate/Downloader.java 11 Dec 2004 20:18:28 -0000 1.38 +++ autoupdate/src/org/netbeans/modules/autoupdate/Downloader.java 23 Feb 2005 09:41:47 -0000 1.38.14.1 @@ -7,7 +7,7 @@ * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original - * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -15,10 +15,7 @@ import java.io.*; import java.net.URLConnection; -import java.net.UnknownHostException; import java.text.MessageFormat; -import java.util.Properties; -import java.util.jar.*; import java.util.Iterator; import java.util.List; import org.netbeans.updater.UpdateTracking; @@ -27,6 +24,7 @@ import org.openide.util.NbBundle; import org.openide.NotifyDescriptor; +import org.openide.util.RequestProcessor; /** This class downloads modules and verifies the digital signatures * this class also copyies the downloaded modules. @@ -86,7 +84,7 @@ } }; - Wizard.getRequestProcessor().post( task ); + RequestProcessor.getDefault ().post( task ); } /** Total size of download in KBytes */ Index: autoupdate/src/org/netbeans/modules/autoupdate/FlashingIcon.java =================================================================== RCS file: autoupdate/src/org/netbeans/modules/autoupdate/FlashingIcon.java diff -N autoupdate/src/org/netbeans/modules/autoupdate/FlashingIcon.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autoupdate/src/org/netbeans/modules/autoupdate/FlashingIcon.java 2 Mar 2005 16:25:26 -0000 1.1.2.3 @@ -0,0 +1,204 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.modules.autoupdate; + +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JToolTip; +import org.openide.util.RequestProcessor; +import org.openide.util.RequestProcessor.Task; + +// Copied from org.netbeans.core.FlashingIcon +/** + * + * A flashing icon to provide visual feedback for the user when something + * not very important happens in the system. + * The icon is flashed for a few seconds and then remains visible for a while longer. + * + * @author saubrecht + */ +abstract class FlashingIcon extends JComponent implements MouseListener { + + protected final int STOP_FLASHING_DELAY = 10 * 1000; + protected final int DISAPPEAR_DELAY_MILLIS = STOP_FLASHING_DELAY + 50 * 1000; + protected final int FLASHING_FREQUENCY = 500; + + private Icon icon; + + private boolean keepRunning = false; + private boolean isIconVisible = false; + private boolean keepFlashing = true; + private long startTime = 0; + private Task timerTask; + + /** + * Creates a new instance of FlashingIcon + * + * @param icon The icon that will be flashing (blinking) + */ + protected FlashingIcon( Icon icon ) { + this.icon = icon; + Dimension d = new Dimension( icon.getIconWidth(), icon.getIconHeight() ); + setMinimumSize( d ); + setMaximumSize( d ); + setPreferredSize( d ); + + addMouseListener( this ); + } + + /** + * Start flashing of the icon. If the icon is already flashing, the timer + * is reset. + * If the icon is visible but not flashing, it starts flashing again + * and the disappear timer is reset. + */ + public void startFlashing() { + System.out.println("DISAPPEAR_DELAY_MILLIS: " + DISAPPEAR_DELAY_MILLIS); + System.out.println("FLASHING_FREQUENCY: " + FLASHING_FREQUENCY); + synchronized( this ) { + startTime = System.currentTimeMillis(); + isIconVisible = !isIconVisible; + keepRunning = true; + keepFlashing = true; + if( null == timerTask ) { + timerTask = RequestProcessor.getDefault ().post (new Timer ()); + } else { + timerTask.run (); + } + } + repaint(); + } + + /** + * Stop the flashing and hide the icon. + */ + public void disappear() { + synchronized( this ) { + keepRunning = false; + isIconVisible = false; + keepFlashing = false; + if( null != timerTask ) + timerTask.cancel(); + timerTask = null; + setToolTipText( null ); + } + repaint(); + } + + /** + * Stop flashing of the icon. The icon remains visible and active (listens + * for mouse clicks and displays tooltip) until the disappear timer expires. + */ + public void stopFlashing() { + synchronized( this ) { + if( keepRunning && !isIconVisible ) { + isIconVisible = true; + repaint(); + } + } + keepFlashing = false; + } + + /** + * Switch the current image and repaint + */ + protected void flashIcon() { + isIconVisible = !isIconVisible; + + repaint(); + } + + public void paint(java.awt.Graphics g) { + if( isIconVisible ) { + icon.paintIcon( this, g, 0, 0 ); + } + } + + public void mouseReleased(MouseEvent e) {} + + public void mousePressed(MouseEvent e) { + stopFlashing(); + } + + public void mouseExited(MouseEvent e) { + stopFlashing(); + } + + public void mouseEntered(MouseEvent e) { + stopFlashing(); + } + + public void mouseClicked(MouseEvent e) { + if( isIconVisible ) { + disappear(); + onMouseClick(); + } + } + + /** + * Invoked when the user clicks the icon. + */ + protected abstract void onMouseClick(); + + /** + * Invoked when the disappear timer expired. + */ + protected abstract void timeout(); + + public Cursor getCursor() { + + if( isIconVisible ) { + return Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ); + } + return Cursor.getDefaultCursor(); + } + + public Point getToolTipLocation( MouseEvent event ) { + + JToolTip tip = createToolTip(); + tip.setTipText( getToolTipText() ); + Dimension d = tip.getPreferredSize(); + + + Point retValue = new Point( getWidth()-d.width, -d.height ); + return retValue; + } + + private class Timer implements Runnable { + public void run() { + synchronized( FlashingIcon.this ) { + long currentTime = System.currentTimeMillis(); + if( keepFlashing ) { + if( currentTime - startTime < STOP_FLASHING_DELAY ) { + flashIcon(); + } else { + stopFlashing(); + } + } + if( currentTime - startTime >= DISAPPEAR_DELAY_MILLIS ) { + disappear(); + timeout(); + } else { + if( null != timerTask ) + timerTask.schedule( FLASHING_FREQUENCY ); + } + } + } + } +} Index: autoupdate/src/org/netbeans/modules/autoupdate/ProblemsVisualizerProvider.java =================================================================== RCS file: autoupdate/src/org/netbeans/modules/autoupdate/ProblemsVisualizerProvider.java diff -N autoupdate/src/org/netbeans/modules/autoupdate/ProblemsVisualizerProvider.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ autoupdate/src/org/netbeans/modules/autoupdate/ProblemsVisualizerProvider.java 2 Mar 2005 16:25:26 -0000 1.1.2.3 @@ -0,0 +1,84 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.modules.autoupdate; + +import java.awt.Component; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import org.netbeans.core.StatusLineElementProvider; +import org.openide.util.Utilities; + +/** + * + * @author Jiri Rechtacek + */ +public final class ProblemsVisualizerProvider implements StatusLineElementProvider { + + public Component getStatusLineElement () { + return getProblemsVisualizer (); + } + + private static UpdatesFlasher flasher = null; + + private static Runnable onMouseClick = null; + + /** + * Return an icon that is flashing when a new internal exception occurs. + * Clicking the icon opens the regular exception dialog box. The icon + * disappears (is hidden) after a short period of time and the exception + * list is cleared. + * + * @return A flashing icon component or null if console logging is switched on. + */ + private static Component getProblemsVisualizer () { + if (null == flasher) { + ImageIcon img1 = new ImageIcon (Utilities.loadImage ("org/netbeans/modules/autoupdate/resources/problems.gif", false)); + assert img1 != null : "Icon cannot be null."; + flasher = new UpdatesFlasher (img1); + } + return flasher; + } + + static UpdatesFlasher getFlasher (Runnable whatRunOnMouseClick) { + onMouseClick = whatRunOnMouseClick; + return flasher; + } + + static class UpdatesFlasher extends FlashingIcon { + protected final int STOP_FLASHING_DELAY = 10 * 1000; + protected final int DISAPPEAR_DELAY_MILLIS = STOP_FLASHING_DELAY + 10 * 1000; + protected final int FLASHING_FREQUENCY = 250; + + public UpdatesFlasher (Icon img1) { + super (img1); + } + + /** + * User clicked the flashing icon, display the exception window. + */ + protected void onMouseClick () { + if (onMouseClick != null) { + onMouseClick.run (); + disappear (); + } + } + + /** + * The flashing icon disappeared (timed-out), clear the current + * exception list. + */ + protected void timeout () {} + } + +} Index: autoupdate/src/org/netbeans/modules/autoupdate/SignVerifier.java =================================================================== RCS file: /cvs/autoupdate/src/org/netbeans/modules/autoupdate/SignVerifier.java,v retrieving revision 1.27 retrieving revision 1.27.32.1 diff -u -r1.27 -r1.27.32.1 --- autoupdate/src/org/netbeans/modules/autoupdate/SignVerifier.java 2 Jul 2004 09:31:51 -0000 1.27 +++ autoupdate/src/org/netbeans/modules/autoupdate/SignVerifier.java 23 Feb 2005 09:41:48 -0000 1.27.32.1 @@ -7,7 +7,7 @@ * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original - * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -19,10 +19,10 @@ import java.security.cert.Certificate; import java.util.*; import java.util.jar.*; -import java.util.zip.*; import java.text.MessageFormat; import org.openide.util.NbBundle; +import org.openide.util.RequestProcessor; /** Class for verifying signs in NBM Files. @@ -100,7 +100,7 @@ } }; - Wizard.getRequestProcessor().post( task ); + RequestProcessor.getDefault ().post( task ); } Index: autoupdate/src/org/netbeans/modules/autoupdate/Updates.java =================================================================== RCS file: /cvs/autoupdate/src/org/netbeans/modules/autoupdate/Updates.java,v retrieving revision 1.33 retrieving revision 1.33.46.1 diff -u -r1.33 -r1.33.46.1 --- autoupdate/src/org/netbeans/modules/autoupdate/Updates.java 16 Apr 2004 17:39:05 -0000 1.33 +++ autoupdate/src/org/netbeans/modules/autoupdate/Updates.java 22 Feb 2005 19:47:02 -0000 1.33.46.1 @@ -53,6 +53,10 @@ /** Checks for updates in separate thread. Displays progress in a dialog */ public abstract void checkUpdates( final Wizard.Validator validator, AutoupdateType at ); + + protected void checkUpdates (final Wizard.Validator validator, AutoupdateType at, boolean background) { + checkUpdates (validator, at); + } public void cancelCheck() { checkCanceled = true; Index: autoupdate/src/org/netbeans/modules/autoupdate/Wizard.java =================================================================== RCS file: /cvs/autoupdate/src/org/netbeans/modules/autoupdate/Wizard.java,v retrieving revision 1.71 retrieving revision 1.71.20.1 diff -u -r1.71 -r1.71.20.1 --- autoupdate/src/org/netbeans/modules/autoupdate/Wizard.java 5 Oct 2004 15:07:33 -0000 1.71 +++ autoupdate/src/org/netbeans/modules/autoupdate/Wizard.java 23 Feb 2005 09:41:48 -0000 1.71.20.1 @@ -382,12 +382,6 @@ return ret; } - static RequestProcessor getRequestProcessor() { - if ( processor == null ) - processor = new RequestProcessor(); - return processor; - } - private static String getBundle( String key ) { return NbBundle.getMessage( Wizard.class, key ); } Index: autoupdate/src/org/netbeans/modules/autoupdate/XMLUpdates.java =================================================================== RCS file: /cvs/autoupdate/src/org/netbeans/modules/autoupdate/XMLUpdates.java,v retrieving revision 1.27 retrieving revision 1.27.14.1 diff -u -r1.27 -r1.27.14.1 --- autoupdate/src/org/netbeans/modules/autoupdate/XMLUpdates.java 11 Dec 2004 20:18:29 -0000 1.27 +++ autoupdate/src/org/netbeans/modules/autoupdate/XMLUpdates.java 22 Feb 2005 19:47:02 -0000 1.27.14.1 @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.Map; import org.openide.ErrorManager; +import org.openide.util.RequestProcessor; import org.w3c.dom.*; import org.xml.sax.*; @@ -169,17 +170,21 @@ public void checkUpdates( final Wizard.Validator validator, String ucname ) { checkUpdates( validator, AutoupdateType.find( ucname ) ); } + + public void checkUpdates( final Wizard.Validator validator, final AutoupdateType at ) { + checkUpdates (validator, at, false); + } /** Checks for updates in separate thread. Displays progress in a dialog */ - public void checkUpdates( final Wizard.Validator validator, final AutoupdateType at ) { + public void checkUpdates (final Wizard.Validator validator, final AutoupdateType at, boolean hidden) { currentAT = at; pError = NO_ERROR; checkCanceled = false; final java.awt.Dialog connDialog = ConnectingDialog.getDialog( at != null ? at.getName() : null ); - Runnable task = new Runnable () { + Runnable runConnect = new Runnable () { public void run() { try { parseDocument(); @@ -209,10 +214,14 @@ } } }; - Wizard.getRequestProcessor().post( task ); - connDialog.show(); - if (ConnectingDialog.isCanceled()) { - cancelCheck(); + RequestProcessor.Task task = RequestProcessor.getDefault ().post (runConnect); + if (!hidden) { + connDialog.setVisible (true); + if (ConnectingDialog.isCanceled()) { + cancelCheck(); + } + } else { + task.waitFinished (); } } @@ -500,5 +509,5 @@ } } //end of inner class ErrorPrinter - + } Index: autoupdate/src/org/netbeans/modules/autoupdate/resources/newUpdates.gif =================================================================== RCS file: autoupdate/src/org/netbeans/modules/autoupdate/resources/newUpdates.gif diff -N autoupdate/src/org/netbeans/modules/autoupdate/resources/newUpdates.gif Binary files /dev/null and /tmp/cvs_Iayoe differ Index: autoupdate/src/org/netbeans/modules/autoupdate/resources/problems.gif =================================================================== RCS file: autoupdate/src/org/netbeans/modules/autoupdate/resources/problems.gif diff -N autoupdate/src/org/netbeans/modules/autoupdate/resources/problems.gif Binary files /dev/null and /tmp/cvsaJayoe differ