27
27
import cc .arduino .contributions .ui .InstallerTableCell ;
28
28
import processing .app .Base ;
29
29
30
- public class ContributedLibraryTableCell {
30
+ public class ContributedLibraryTableCell extends JPanel {
31
31
32
- protected final JPanel panel ;
33
32
protected final JButton installButton ;
34
33
protected final Component installButtonPlaceholder ;
35
34
protected final JComboBox downgradeChooser ;
@@ -40,6 +39,9 @@ public class ContributedLibraryTableCell {
40
39
protected final JLabel statusLabel ;
41
40
42
41
public ContributedLibraryTableCell () {
42
+ super ();
43
+ setLayout (new BoxLayout (this , BoxLayout .Y_AXIS ));
44
+
43
45
installButton = new JButton (tr ("Install" ));
44
46
int width = installButton .getPreferredSize ().width ;
45
47
installButtonPlaceholder = Box .createRigidArea (new Dimension (width , 1 ));
@@ -60,10 +62,7 @@ public ContributedLibraryTableCell() {
60
62
versionToInstallChooser
61
63
.setMaximumSize (versionToInstallChooser .getPreferredSize ());
62
64
63
- panel = new JPanel ();
64
- panel .setLayout (new BoxLayout (panel , BoxLayout .Y_AXIS ));
65
-
66
- makeNewDescription (panel );
65
+ makeNewDescription ();
67
66
68
67
buttonsPanel = new JPanel ();
69
68
buttonsPanel .setLayout (new BoxLayout (buttonsPanel , BoxLayout .X_AXIS ));
@@ -82,7 +81,7 @@ public ContributedLibraryTableCell() {
82
81
buttonsPanel .add (Box .createHorizontalStrut (5 ));
83
82
buttonsPanel .add (Box .createHorizontalStrut (15 ));
84
83
85
- panel . add (buttonsPanel );
84
+ add (buttonsPanel );
86
85
87
86
inactiveButtonsPanel = new JPanel ();
88
87
inactiveButtonsPanel
@@ -97,16 +96,16 @@ public ContributedLibraryTableCell() {
97
96
inactiveButtonsPanel .add (statusLabel );
98
97
inactiveButtonsPanel .add (Box .createHorizontalStrut (15 ));
99
98
100
- panel . add (inactiveButtonsPanel );
99
+ add (inactiveButtonsPanel );
101
100
102
- panel . add (Box .createVerticalStrut (15 ));
101
+ add (Box .createVerticalStrut (15 ));
103
102
}
104
103
105
- void update (JTable parentTable , Object value , boolean isSelected ,
106
- int row , boolean hasBuiltInRelease ) {
104
+ void update (JTable parentTable , Object value , boolean isSelected , int row ,
105
+ boolean hasBuiltInRelease ) {
107
106
ContributedLibraryReleases releases = (ContributedLibraryReleases ) value ;
108
107
109
- JTextPane description = makeNewDescription (panel );
108
+ JTextPane description = makeNewDescription ();
110
109
111
110
// FIXME: happens on macosx, don't know why
112
111
if (releases == null )
@@ -196,20 +195,21 @@ void update(JTable parentTable, Object value, boolean isSelected,
196
195
// See:
197
196
// http://stackoverflow.com/questions/3081210/how-to-set-jtextarea-to-have-height-that-matches-the-size-of-a-text-it-contains
198
197
int width = parentTable .getBounds ().width ;
199
- InstallerTableCell .setJTextPaneDimensionToFitContainedText (description , width );
198
+ InstallerTableCell .setJTextPaneDimensionToFitContainedText (description ,
199
+ width );
200
200
201
201
if (isSelected ) {
202
- panel . setBackground (parentTable .getSelectionBackground ());
203
- panel . setForeground (parentTable .getSelectionForeground ());
202
+ setBackground (parentTable .getSelectionBackground ());
203
+ setForeground (parentTable .getSelectionForeground ());
204
204
} else {
205
- panel . setBackground (parentTable .getBackground ());
206
- panel . setForeground (parentTable .getForeground ());
205
+ setBackground (parentTable .getBackground ());
206
+ setForeground (parentTable .getForeground ());
207
207
}
208
208
}
209
209
210
- private static JTextPane makeNewDescription (JPanel panel ) {
211
- if (panel . getComponentCount () > 0 ) {
212
- panel . remove (0 );
210
+ private JTextPane makeNewDescription () {
211
+ if (getComponentCount () > 0 ) {
212
+ remove (0 );
213
213
}
214
214
JTextPane description = new JTextPane ();
215
215
description .setInheritsPopupMenu (true );
@@ -235,7 +235,7 @@ private static JTextPane makeNewDescription(JPanel panel) {
235
235
}
236
236
});
237
237
// description.addKeyListener(new DelegatingKeyListener(parentTable));
238
- panel . add (description , 0 );
238
+ add (description , 0 );
239
239
return description ;
240
240
}
241
241
0 commit comments