|
@@ -23,7 +23,8 @@
|
23
|
23
|
package com.dmdirc.ui.swing.components.expandingsettings;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.config.Identity;
|
26
|
|
-import com.dmdirc.ui.swing.components.TextLabel;
|
|
26
|
+import com.dmdirc.ui.swing.JWrappingLabel;
|
|
27
|
+import java.awt.Dimension;
|
27
|
28
|
import static com.dmdirc.ui.swing.UIUtilities.SMALL_BORDER;
|
28
|
29
|
|
29
|
30
|
import java.awt.GridBagConstraints;
|
|
@@ -69,7 +70,7 @@ public final class SettingsPanel extends JPanel {
|
69
|
70
|
private Map<String, OptionType> types;
|
70
|
71
|
|
71
|
72
|
/** Info label. */
|
72
|
|
- private TextLabel infoLabel;
|
|
73
|
+ private JWrappingLabel infoLabel;
|
73
|
74
|
|
74
|
75
|
/** Current options panel. */
|
75
|
76
|
private CurrentOptionsPanel currentOptionsPanel;
|
|
@@ -83,14 +84,16 @@ public final class SettingsPanel extends JPanel {
|
83
|
84
|
*
|
84
|
85
|
* @param config Config to use
|
85
|
86
|
* @param infoText Info blurb.
|
|
87
|
+ * @param size Maximum width of the layout
|
86
|
88
|
*/
|
87
|
|
- public SettingsPanel(final Identity config, final String infoText) {
|
|
89
|
+ public SettingsPanel(final Identity config, final String infoText,
|
|
90
|
+ final int size) {
|
88
|
91
|
super();
|
89
|
92
|
|
90
|
93
|
this.config = config;
|
91
|
94
|
|
92
|
95
|
initComponents(infoText);
|
93
|
|
- layoutComponents();
|
|
96
|
+ layoutComponents(size);
|
94
|
97
|
}
|
95
|
98
|
|
96
|
99
|
/**
|
|
@@ -102,7 +105,7 @@ public final class SettingsPanel extends JPanel {
|
102
|
105
|
names = new LinkedHashMap<String, String>();
|
103
|
106
|
types = new LinkedHashMap<String, OptionType>();
|
104
|
107
|
|
105
|
|
- infoLabel = new TextLabel(infoText);
|
|
108
|
+ infoLabel = new JWrappingLabel(infoText);
|
106
|
109
|
|
107
|
110
|
addOptionPanel =
|
108
|
111
|
new AddOptionPanel(this);
|
|
@@ -121,8 +124,12 @@ public final class SettingsPanel extends JPanel {
|
121
|
124
|
SMALL_BORDER, SMALL_BORDER)));
|
122
|
125
|
}
|
123
|
126
|
|
124
|
|
- /** Lays out the components. */
|
125
|
|
- private void layoutComponents() {
|
|
127
|
+ /**
|
|
128
|
+ * Lays out the components.
|
|
129
|
+ *
|
|
130
|
+ * @param size Maximum width of the layout
|
|
131
|
+ */
|
|
132
|
+ private void layoutComponents(final int size) {
|
126
|
133
|
final GridBagConstraints constraints = new GridBagConstraints();
|
127
|
134
|
|
128
|
135
|
setLayout(new GridBagLayout());
|
|
@@ -132,6 +139,7 @@ public final class SettingsPanel extends JPanel {
|
132
|
139
|
constraints.weightx = 1.0;
|
133
|
140
|
constraints.weighty = 0.0;
|
134
|
141
|
constraints.fill = GridBagConstraints.HORIZONTAL;
|
|
142
|
+ infoLabel.setMaximumSize(new Dimension(size, 0));
|
135
|
143
|
add(infoLabel, constraints);
|
136
|
144
|
|
137
|
145
|
constraints.gridy = 1;
|
|
@@ -246,7 +254,7 @@ public final class SettingsPanel extends JPanel {
|
246
|
254
|
*
|
247
|
255
|
* @return Display name for a specified option
|
248
|
256
|
*/
|
249
|
|
- protected String getOptionName(final String optionName) {
|
|
257
|
+ public String getOptionName(final String optionName) {
|
250
|
258
|
return names.get(optionName);
|
251
|
259
|
}
|
252
|
260
|
|
|
@@ -257,7 +265,7 @@ public final class SettingsPanel extends JPanel {
|
257
|
265
|
*
|
258
|
266
|
* @return Option type for a specified option
|
259
|
267
|
*/
|
260
|
|
- protected OptionType getOptionType(final String optionName) {
|
|
268
|
+ public OptionType getOptionType(final String optionName) {
|
261
|
269
|
return types.get(optionName);
|
262
|
270
|
}
|
263
|
271
|
}
|