11package com .jvms .i18neditor ;
22
33import java .awt .BorderLayout ;
4+ import java .awt .Component ;
45import java .awt .Container ;
6+ import java .awt .Desktop ;
57import java .awt .Dimension ;
8+ import java .awt .Font ;
69import java .awt .Image ;
710import java .awt .event .KeyAdapter ;
811import java .awt .event .KeyEvent ;
2124import javax .swing .Box ;
2225import javax .swing .BoxLayout ;
2326import javax .swing .ImageIcon ;
27+ import javax .swing .JEditorPane ;
2428import javax .swing .JFileChooser ;
2529import javax .swing .JFrame ;
2630import javax .swing .JLabel ;
3034import javax .swing .JSplitPane ;
3135import javax .swing .SwingUtilities ;
3236import javax .swing .UIManager ;
37+ import javax .swing .event .HyperlinkEvent ;
3338import javax .swing .event .TreeSelectionEvent ;
3439import javax .swing .event .TreeSelectionListener ;
3540
4146import com .jvms .i18neditor .swing .JFileDrop ;
4247import com .jvms .i18neditor .swing .JScrollablePanel ;
4348import com .jvms .i18neditor .util .ExtendedProperties ;
49+ import com .jvms .i18neditor .util .GithubRepoUtils ;
50+ import com .jvms .i18neditor .util .GithubRepoUtils .GithubReleaseData ;
4451import com .jvms .i18neditor .util .MessageBundle ;
4552import com .jvms .i18neditor .util .Resources ;
4653import com .jvms .i18neditor .util .TranslationKeys ;
@@ -57,6 +64,7 @@ public class Editor extends JFrame {
5764 public final static String TITLE = "i18n Editor" ;
5865 public final static String VERSION = "0.6.0" ;
5966 public final static String COPYRIGHT_YEAR = "2016" ;
67+ public final static String GITHUB_REPO = "jcbvm/ember-i18n-editor" ;
6068 public final static int DEFAULT_WIDTH = 1024 ;
6169 public final static int DEFAULT_HEIGHT = 768 ;
6270
@@ -223,10 +231,18 @@ public void showMessage(String title, String message) {
223231 showMessageDialog (title , message , JOptionPane .PLAIN_MESSAGE );
224232 }
225233
234+ public void showMessage (String title , Component component ) {
235+ showMessageDialog (title , component , JOptionPane .PLAIN_MESSAGE );
236+ }
237+
226238 public void showMessageDialog (String title , String message , int type ) {
227239 JOptionPane .showMessageDialog (this , message , title , type );
228240 }
229241
242+ public void showMessageDialog (String title , Component component , int type ) {
243+ JOptionPane .showMessageDialog (this , component , title , type );
244+ }
245+
230246 public void showImportDialog () {
231247 String path = null ;
232248 if (resourcesDir != null ) {
@@ -344,7 +360,7 @@ public void showFindTranslationDialog() {
344360
345361 public void showAboutDialog () {
346362 showMessage (MessageBundle .get ("dialogs.about.title" , TITLE ),
347- "<html><body style=\" text-align:center;width:200px;\" ><br> " +
363+ "<html><body style=\" text-align:center;width:200px;\" >" +
348364 "<span style=\" font-weight:bold;font-size:1.2em;\" >" + TITLE + "</span><br>" +
349365 "v" + VERSION + "<br><br>" +
350366 "(c) Copyright " + COPYRIGHT_YEAR + "<br>" +
@@ -353,6 +369,31 @@ public void showAboutDialog() {
353369 "</body></html>" );
354370 }
355371
372+ public void showVersionDialog () {
373+ GithubReleaseData data = GithubRepoUtils .getLatestRelease (GITHUB_REPO );
374+ String content = "" ;
375+ if (data != null && !VERSION .equals (data .getTagName ())) {
376+ content = MessageBundle .get ("dialogs.version.new" , data .getTagName ()) + "<br>" +
377+ "<a href=\" " + data .getHtmlUrl () + "\" >" + MessageBundle .get ("dialogs.version.link" ) + "</a>" ;
378+ } else {
379+ content = MessageBundle .get ("dialogs.version.uptodate" );
380+ }
381+ Font font = getFont ();
382+ JEditorPane pane = new JEditorPane ("text/html" , "<html><body style=\" font-family:" + font .getFamily () + ";font-size:" + font .getSize () + "pt;text-align:center;width:200px;\" >" + content + "</body></html>" );
383+ pane .addHyperlinkListener (e -> {
384+ if (e .getEventType ().equals (HyperlinkEvent .EventType .ACTIVATED )) {
385+ try {
386+ Desktop .getDesktop ().browse (e .getURL ().toURI ());
387+ } catch (Exception e1 ) {
388+ //
389+ }
390+ }
391+ });
392+ pane .setBackground (getBackground ());
393+ pane .setEditable (false );
394+ showMessage (MessageBundle .get ("dialogs.version.title" ), pane );
395+ }
396+
356397 public boolean closeCurrentSession () {
357398 if (isDirty ()) {
358399 int result = JOptionPane .showConfirmDialog (this ,
0 commit comments