| 2 |
|
|
| 3 |
|
import java.awt.BorderLayout; |
| 4 |
|
import java.awt.Desktop; |
| 5 |
+ |
import java.awt.GridLayout; |
| 6 |
|
import java.awt.event.ActionEvent; |
| 7 |
|
import java.awt.event.ItemEvent; |
| 8 |
|
import java.awt.event.ItemListener; |
| 203 |
|
TreeSet<Mod> tools = ModManager.getInstance() |
| 204 |
|
.getUpdatableTools(); |
| 205 |
|
int size = 0; |
| 206 |
< |
String strMods = ""; |
| 207 |
< |
for (Mod m : mods) { |
| 206 |
> |
JPanel panPackages = new JPanel(new GridLayout(0, 1)); |
| 207 |
> |
execUpdates = new TreeSet<Mod>(); |
| 208 |
> |
execUpdates.addAll(mods); |
| 209 |
> |
execUpdates.addAll(tools); |
| 210 |
> |
for (final Mod m : mods) { |
| 211 |
|
size += m.getZipSize(); |
| 212 |
< |
if (strMods.length() > 0) |
| 213 |
< |
strMods += "<br>"; |
| 214 |
< |
strMods += " - " + m.getName(); |
| 212 |
> |
JCheckBox check = new JCheckBox("Mod: " + m.getName()); |
| 213 |
> |
check.setSelected(true); |
| 214 |
> |
check.addItemListener(new ItemListener() { |
| 215 |
> |
@Override |
| 216 |
> |
public void itemStateChanged(ItemEvent e) { |
| 217 |
> |
if (e.getStateChange() == ItemEvent.SELECTED) |
| 218 |
> |
execUpdates.add(m); |
| 219 |
> |
else |
| 220 |
> |
execUpdates.remove(m); |
| 221 |
> |
} |
| 222 |
> |
}); |
| 223 |
> |
panPackages.add(check); |
| 224 |
|
} |
| 225 |
< |
String strTools = ""; |
| 213 |
< |
for (Mod m : tools) { |
| 225 |
> |
for (final Mod m : tools) { |
| 226 |
|
size += m.getZipSize(); |
| 227 |
< |
if (strTools.length() > 0) |
| 228 |
< |
strTools += "<br>"; |
| 229 |
< |
strTools += " - " + m.getName(); |
| 227 |
> |
JCheckBox check = new JCheckBox("Tool: " + m.getName()); |
| 228 |
> |
check.setSelected(true); |
| 229 |
> |
panPackages.add(check); |
| 230 |
|
} |
| 231 |
|
if (size > 0) { |
| 232 |
|
// Build info dialog content |
| 233 |
< |
String message = "<html>"; |
| 234 |
< |
message += String.format( |
| 235 |
< |
bundle.getString("updatesAvailable.text"), strMods, |
| 236 |
< |
strTools, SizeFormatter.format(size, 3)); |
| 237 |
< |
message += "</html>"; |
| 238 |
< |
|
| 239 |
< |
JPanel pan = new JPanel(); |
| 240 |
< |
pan.setLayout(new BorderLayout(0, 20)); |
| 241 |
< |
JLabel lab = new JLabel(message); |
| 242 |
< |
pan.add(lab, BorderLayout.CENTER); |
| 233 |
> |
JPanel packages = new JPanel(new BorderLayout(0, 7)); |
| 234 |
> |
JLabel lblIntro = new JLabel("<html>" |
| 235 |
> |
+ bundle.getString("updatesAvailable.text") |
| 236 |
> |
+ "</html>"); |
| 237 |
> |
JLabel lblSize = new JLabel("<html>" |
| 238 |
> |
+ String.format(bundle |
| 239 |
> |
.getString("updatesAvailableSize.text"), |
| 240 |
> |
SizeFormatter.format(size, 3)) + "</html>"); |
| 241 |
> |
packages.add(lblIntro, BorderLayout.NORTH); |
| 242 |
> |
packages.add(panPackages, BorderLayout.CENTER); |
| 243 |
> |
packages.add(lblSize, BorderLayout.SOUTH); |
| 244 |
> |
|
| 245 |
> |
JPanel pan = new JPanel(new BorderLayout(0, 25)); |
| 246 |
> |
pan.add(packages, BorderLayout.CENTER); |
| 247 |
|
JCheckBox checkFutureUpdates = new JCheckBox( |
| 248 |
|
bundle.getString("checkOnStartup.text")); |
| 249 |
|
checkFutureUpdates.setSelected(Settings.getInstance().get( |
| 262 |
|
bundle.getString("updatesAvailable.title"), |
| 263 |
|
JOptionPane.YES_NO_OPTION, |
| 264 |
|
JOptionPane.QUESTION_MESSAGE); |
| 265 |
< |
if (res == JOptionPane.YES_OPTION) { |
| 266 |
< |
execUpdates = new TreeSet<Mod>(); |
| 251 |
< |
execUpdates.addAll(mods); |
| 252 |
< |
execUpdates.addAll(tools); |
| 265 |
> |
if (res == JOptionPane.NO_OPTION) { |
| 266 |
> |
execUpdates = null; |
| 267 |
|
} |
| 268 |
|
} |
| 269 |
|
} |
| 272 |
|
|
| 273 |
|
@SuppressWarnings("unused") |
| 274 |
|
private void doUpdate() { |
| 275 |
< |
if (execUpdates != null) { |
| 275 |
> |
if (execUpdates != null && execUpdates.size() > 0) { |
| 276 |
|
Downloader dl = new Downloader(execUpdates); |
| 277 |
|
try { |
| 278 |
|
dl.setVisible(true); |