package org.openslx.dozmod.gui.activity; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.SwingUtilities; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.QLabel; import org.openslx.dozmod.gui.window.CheckUpdateWindow; import org.openslx.dozmod.util.DesktopEnvironment; import org.openslx.dozmod.util.DesktopEnvironment.Link; public class UpdatePanel extends ActivityPanel implements ActionListener { private static final long serialVersionUID = 1L; protected JPanel header; protected QLabel lblInfo; protected final JButton btnLink; protected final JButton btnDetails; protected final JButton btnClose; @Override public boolean wantConfirmQuit() { return false; } public UpdatePanel(final String newVersion) { super(); setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // Header: Neue Version verfügbar: [Button] header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS)); lblInfo = new QLabel("Neue Version verfügbar: " + newVersion, Gui.getScaledIconResource("/img/upload-icon.png", "!", 32, this), QLabel.LEFT); header.add(lblInfo); header.add(Box.createHorizontalGlue()); btnLink = new JButton("Im Browser öffnen", Gui.getScaledIconResource("/img/download-icon.png", "!", 24, this)); btnDetails = new JButton("Changelog", Gui.getScaledIconResource("/img/info-icon.png", "?", 24, this)); btnClose = new JButton("Schließen", Gui.getScaledIconResource("/img/delete-icon.png", "X", 24, this)); btnLink.addActionListener(this); btnClose.addActionListener(this); header.add(btnLink); header.add(btnDetails); header.add(btnClose); add(header); btnDetails.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CheckUpdateWindow.open(SwingUtilities.getWindowAncestor(UpdatePanel.this)); } }); } @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == btnLink) { DesktopEnvironment.openWebpage(Link.DOZMOD); close(); } if (e.getSource() == btnClose) { close(); } } }