-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into convertDubplicate…
…tojavafx * upstream/master: Fix not on FX thread exception Force javafx to run thread (#4604) Convert new version dialog to JavaFX (#4602)
- Loading branch information
Showing
4 changed files
with
47 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 36 additions & 77 deletions
113
src/main/java/org/jabref/gui/help/NewVersionDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,51 @@ | ||
package org.jabref.gui.help; | ||
|
||
import java.awt.Cursor; | ||
import java.awt.GridBagConstraints; | ||
import java.awt.GridBagLayout; | ||
import java.awt.Insets; | ||
import java.awt.event.MouseEvent; | ||
|
||
import javax.swing.JButton; | ||
import javax.swing.JLabel; | ||
import javax.swing.JPanel; | ||
import javax.swing.event.MouseInputAdapter; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.ButtonBar; | ||
import javafx.scene.control.ButtonType; | ||
import javafx.scene.control.Hyperlink; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.VBox; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.gui.JabRefDialog; | ||
import org.jabref.gui.desktop.JabRefDesktop; | ||
import org.jabref.gui.util.BaseDialog; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.util.Version; | ||
import org.jabref.preferences.VersionPreferences; | ||
|
||
public class NewVersionDialog extends JabRefDialog { | ||
public class NewVersionDialog extends BaseDialog<Void> { | ||
|
||
public NewVersionDialog(Version currentVersion, Version latestVersion) { | ||
super(NewVersionDialog.class); | ||
setTitle(Localization.lang("New version available")); | ||
|
||
JLabel lblTitle = new JLabel(Localization.lang("A new version of JabRef has been released.")); | ||
JLabel lblCurrentVersion = new JLabel(Localization.lang("Installed version") + ": " + currentVersion.getFullVersion()); | ||
JLabel lblLatestVersion = new JLabel(Localization.lang("Latest version") + ": " + latestVersion.getFullVersion()); | ||
|
||
String localization = Localization.lang("To see what is new view the changelog."); | ||
JLabel lblMoreInformation = new JLabel("<HTML><a href=" + latestVersion.getChangelogUrl() + "'>" + localization + "</a></HTML>"); | ||
lblMoreInformation.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); | ||
lblMoreInformation.addMouseListener(new MouseInputAdapter() { | ||
@Override | ||
public void mouseClicked(MouseEvent e) { | ||
JabRefDesktop.openBrowserShowPopup(latestVersion.getChangelogUrl()); | ||
this.setTitle(Localization.lang("New version available")); | ||
|
||
ButtonType btnIgnoreUpdate = new ButtonType(Localization.lang("Ignore this update"), ButtonBar.ButtonData.CANCEL_CLOSE); | ||
ButtonType btnDownloadUpdate = new ButtonType(Localization.lang("Download update"), ButtonBar.ButtonData.APPLY); | ||
ButtonType btnRemindMeLater = new ButtonType(Localization.lang("Remind me later"), ButtonBar.ButtonData.CANCEL_CLOSE); | ||
this.getDialogPane().getButtonTypes().addAll(btnIgnoreUpdate, btnDownloadUpdate, btnRemindMeLater); | ||
this.setResultConverter(button -> { | ||
if (button == btnIgnoreUpdate) { | ||
Globals.prefs.storeVersionPreferences(new VersionPreferences(latestVersion)); | ||
} else if (button == btnDownloadUpdate) { | ||
JabRefDesktop.openBrowserShowPopup(Version.JABREF_DOWNLOAD_URL); | ||
} | ||
return null; | ||
}); | ||
|
||
JButton btnIgnoreUpdate = new JButton(Localization.lang("Ignore this update")); | ||
btnIgnoreUpdate.addActionListener(e -> { | ||
Globals.prefs.storeVersionPreferences(new VersionPreferences(latestVersion)); | ||
dispose(); | ||
}); | ||
|
||
JButton btnDownloadUpdate = new JButton(Localization.lang("Download update")); | ||
btnDownloadUpdate.addActionListener(e -> { | ||
JabRefDesktop.openBrowserShowPopup(Version.JABREF_DOWNLOAD_URL); | ||
dispose(); | ||
}); | ||
|
||
JButton btnRemindMeLater = new JButton(Localization.lang("Remind me later")); | ||
btnRemindMeLater.addActionListener(e -> dispose()); | ||
|
||
JPanel panel = new JPanel(); | ||
panel.setLayout(new GridBagLayout()); | ||
GridBagConstraints c = new GridBagConstraints(); | ||
c.gridheight = 1; | ||
c.fill = GridBagConstraints.BOTH; | ||
c.insets = new Insets(2, 5, 5, 2); | ||
|
||
c.gridx = c.gridy = 0; | ||
c.gridwidth = 3; | ||
panel.add(lblTitle, c); | ||
|
||
c.gridy = 1; | ||
panel.add(lblCurrentVersion, c); | ||
|
||
c.gridy = 2; | ||
panel.add(lblLatestVersion, c); | ||
|
||
c.gridy = 3; | ||
panel.add(lblMoreInformation, c); | ||
|
||
c.gridy = 4; | ||
c.gridx = 0; | ||
c.gridwidth = 1; | ||
panel.add(btnDownloadUpdate, c); | ||
|
||
c.gridx = 1; | ||
panel.add(btnIgnoreUpdate, c); | ||
|
||
c.gridx = 2; | ||
panel.add(btnRemindMeLater, c); | ||
|
||
add(panel); | ||
pack(); | ||
setVisible(true); | ||
Button defaultButton = (Button) this.getDialogPane().lookupButton(btnDownloadUpdate); | ||
defaultButton.setDefaultButton(true); | ||
|
||
Hyperlink lblMoreInformation = new Hyperlink(Localization.lang("To see what is new view the changelog.")); | ||
lblMoreInformation.setOnAction(event -> | ||
JabRefDesktop.openBrowserShowPopup(latestVersion.getChangelogUrl()) | ||
); | ||
|
||
VBox container = new VBox( | ||
new Label(Localization.lang("A new version of JabRef has been released.")), | ||
new Label(Localization.lang("Installed version") + ": " + currentVersion.getFullVersion()), | ||
new Label(Localization.lang("Latest version") + ": " + latestVersion.getFullVersion()), | ||
lblMoreInformation | ||
); | ||
getDialogPane().setContent(container); | ||
getDialogPane().setPrefWidth(450); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters