Lines 20-25
Link Here
|
20 |
package org.netbeans.modules.welcome.content; |
20 |
package org.netbeans.modules.welcome.content; |
21 |
|
21 |
|
22 |
import java.awt.BorderLayout; |
22 |
import java.awt.BorderLayout; |
|
|
23 |
import java.awt.EventQueue; |
23 |
import java.awt.GridBagConstraints; |
24 |
import java.awt.GridBagConstraints; |
24 |
import java.awt.GridBagLayout; |
25 |
import java.awt.GridBagLayout; |
25 |
import java.awt.Insets; |
26 |
import java.awt.Insets; |
Lines 45-54
Link Here
|
45 |
* |
46 |
* |
46 |
* @author S. Aubrecht |
47 |
* @author S. Aubrecht |
47 |
*/ |
48 |
*/ |
48 |
public class RecentProjectsPanel extends JPanel implements Constants { |
49 |
public class RecentProjectsPanel extends JPanel implements Constants, Runnable, PropertyChangeListener { |
49 |
|
50 |
|
50 |
private static final int MAX_PROJECTS = 10; |
51 |
private static final int MAX_PROJECTS = 10; |
51 |
private PropertyChangeListener changeListener; |
|
|
52 |
|
52 |
|
53 |
/** Creates a new instance of RecentProjectsPanel */ |
53 |
/** Creates a new instance of RecentProjectsPanel */ |
54 |
public RecentProjectsPanel() { |
54 |
public RecentProjectsPanel() { |
Lines 61-91
Link Here
|
61 |
super.addNotify(); |
61 |
super.addNotify(); |
62 |
removeAll(); |
62 |
removeAll(); |
63 |
add( rebuildContent(), BorderLayout.CENTER ); |
63 |
add( rebuildContent(), BorderLayout.CENTER ); |
64 |
RecentProjects.getDefault().addPropertyChangeListener( getPropertyChangeListener() ); |
64 |
RecentProjects.getDefault().addPropertyChangeListener( this ); |
|
|
65 |
//With deferred project loading, need to listen on this as well |
66 |
OpenProjects.getDefault().addPropertyChangeListener( this ); |
65 |
} |
67 |
} |
66 |
|
68 |
|
67 |
@Override |
69 |
@Override |
68 |
public void removeNotify() { |
70 |
public void removeNotify() { |
69 |
super.removeNotify(); |
71 |
super.removeNotify(); |
70 |
RecentProjects.getDefault().removePropertyChangeListener( getPropertyChangeListener() ); |
72 |
RecentProjects.getDefault().removePropertyChangeListener( this ); |
71 |
} |
73 |
} |
72 |
|
74 |
|
73 |
private PropertyChangeListener getPropertyChangeListener() { |
|
|
74 |
if( null == changeListener ) { |
75 |
changeListener = new PropertyChangeListener() { |
76 |
public void propertyChange(PropertyChangeEvent e) { |
75 |
public void propertyChange(PropertyChangeEvent e) { |
77 |
if( RecentProjects.PROP_RECENT_PROJECT_INFO.equals( e.getPropertyName() ) ) { |
76 |
System.err.println("PROP CHANGE " + e.getPropertyName() + |
|
|
77 |
" from " + e.getSource()); |
78 |
if( RecentProjects.PROP_RECENT_PROJECT_INFO.equals( e.getPropertyName() ) || |
79 |
OpenProjects.PROPERTY_OPEN_PROJECTS.equals (e.getPropertyName() )) { |
80 |
EventQueue.invokeLater(this); |
81 |
} |
82 |
} |
83 |
|
84 |
public void run() { |
78 |
removeAll(); |
85 |
removeAll(); |
79 |
add( rebuildContent(), BorderLayout.CENTER ); |
86 |
add( rebuildContent(), BorderLayout.CENTER ); |
80 |
invalidate(); |
87 |
invalidate(); |
81 |
revalidate(); |
88 |
revalidate(); |
82 |
repaint(); |
89 |
repaint(); |
83 |
} |
90 |
} |
84 |
} |
|
|
85 |
}; |
86 |
} |
87 |
return changeListener; |
88 |
} |
89 |
|
91 |
|
90 |
private JPanel rebuildContent() { |
92 |
private JPanel rebuildContent() { |
91 |
JPanel panel = new JPanel( new GridBagLayout() ); |
93 |
JPanel panel = new JPanel( new GridBagLayout() ); |