@ -96,8 +96,6 @@ public class UpdateMainDialog extends UIDialog {
private LoadingLabel loadingLabel ;
//更新按钮
private UIButton updateButton ;
//有新版本提示标签
private UILabel updateLabel ;
//jar包版本信息面板,包括当前版本和最新版本
private JPanel jarVersionInfoPane ;
@ -160,13 +158,8 @@ public class UpdateMainDialog extends UIDialog {
progressBar . setStringPainted ( true ) ;
progressBar . setPreferredSize ( PROGRESSBAR ) ;
updateLabel = new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_New_Version_Available" ) ) ;
updateLabel . setHorizontalAlignment ( SwingConstants . RIGHT ) ;
updateLabel . setVisible ( false ) ;
progressBarPane . add ( GUICoreUtils . createBorderLayoutPane (
progressBar , BorderLayout . CENTER ,
updateLabel , BorderLayout . EAST
progressBar , BorderLayout . CENTER
) , BorderLayout . CENTER ) ;
updateActionPane = TableLayoutHelper . createCommonTableLayoutPane ( new Component [ ] [ ] {
@ -186,7 +179,7 @@ public class UpdateMainDialog extends UIDialog {
double [ ] rowUpdatePaneSize = { UPDATE_PANE_ROW_SIZE , TableLayout . PREFERRED , TableLayout . PREFERRED } ;
double [ ] columnUpdatePaneSize = { TableLayout . PREFERRED , TableLayout . FILL , TableLayout . PREFERRED } ;
double [ ] rowUpdateContentPaneSize = { TableLayout . PREFERRED } ;
double [ ] columnUpdateContentPaneSize = { TableLayout . PREFERRED , TableLayout . FILL , TableLayout . PREFERRED } ;
double [ ] columnUpdateContentPaneSize = { TableLayout . PREFERRED , TableLayout . FILL } ;
double [ ] rowUpdateSubContentPaneSize = { UPDATE_CONTENT_PANE_ROW_SIZE , TableLayout . PREFERRED , TableLayout . PREFERRED , TableLayout . PREFERRED , UPDATE_CONTENT_PANE_ROW_SIZE } ;
double [ ] columnUpdateSubContentPaneSize = { UPDATE_CONTENT_PANE_COLUMN_SIZE , TableLayout . PREFERRED , TableLayout . PREFERRED } ;
double [ ] columnUpdateSubContentPaneLabelSize = { UPDATE_CONTENT_PANE_LABEL_COLUMN_SIZE , TableLayout . PREFERRED } ;
@ -198,7 +191,7 @@ public class UpdateMainDialog extends UIDialog {
JPanel jarUpdateContentPane2 = TableLayoutHelper . createCommonTableLayoutPane ( new Component [ ] [ ] {
new Component [ ] { new UILabel ( ) , new UILabel ( ) , new UILabel ( ) } ,
new Component [ ] { new UILabel ( ) , updateVersionReminderPane , new UILabel ( ) } ,
new Component [ ] { new UILabel ( ) , initPaneContent ( Color . WHITE , rowUpdateContentPaneSize , columnUpdateSubContentPaneLabelSize , new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_JAR_Version" ) ) , jarCurrentLabel ) , new UILabel ( ) } ,
new Component [ ] { new UILabel ( ) , initPaneContent ( Color . WHITE , rowUpdateContentPaneSize , columnUpdateSubContentPaneLabelSize , new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_JAR_Version" ) ) , jarCurrentLabel ) , jarRestoreLabel } ,
new Component [ ] { new UILabel ( ) , initPaneContent ( Color . WHITE , rowUpdateContentPaneSize , columnUpdateSubContentPaneLabelSize , new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Latest_JAR" ) ) , loadingLabel ) ,
getNewFeatureActionLabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Latest_Feature_Detail" ) ) } ,
new Component [ ] { new UILabel ( ) , new UILabel ( ) , new UILabel ( ) }
@ -207,7 +200,7 @@ public class UpdateMainDialog extends UIDialog {
jarUpdateContentPane . add ( jarUpdateContentPane2 ) ;
jarVersionInfoPane = TableLayoutHelper . createCommonTableLayoutPane ( new Component [ ] [ ] {
new Component [ ] { new UILabel ( ) , new UILabel ( ) , new UILabel ( ) } ,
new Component [ ] { new UILabel ( ) , initPaneContent ( getBackground ( ) , rowUpdateContentPaneSize , columnUpdateContentPaneSize , new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_JarUpdate" ) ) , new UILabel ( ) , jarRestoreLabel ) , new UILabel ( ) } ,
new Component [ ] { new UILabel ( ) , initPaneContent ( getBackground ( ) , rowUpdateContentPaneSize , columnUpdateContentPaneSize , new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_JarUpdate" ) ) , new UILabel ( ) ) , new UILabel ( ) } ,
new Component [ ] { new UILabel ( ) , jarUpdateContentPane , new UILabel ( ) }
} , rowUpdatePaneSize , columnUpdatePaneSize , LayoutConstants . VGAP_LARGE ) ;
}
@ -225,7 +218,7 @@ public class UpdateMainDialog extends UIDialog {
new Component [ ] { new UILabel ( ) , new UILabel ( ) , new UILabel ( ) }
} , searchRow , searchColumn , LayoutConstants . VGAP_LARGE ) ;
String [ ] columnNames = { com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Date" ) , com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Content" ) , com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_SignHeader" ) } ;
String [ ] columnNames = { com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Date" ) , com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Version" ) , com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_ Content" ) , com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_SignHeader" ) } ;
initUpdateInfoTable ( columnNames ) ;
UIScrollPane uiScrollPane = new UIScrollPane ( updateInfoTable ) ;
@ -236,31 +229,32 @@ public class UpdateMainDialog extends UIDialog {
}
private void initUpdateInfoTable ( String [ ] columnNames ) {
int updateTimeColIndex = 0 ;
int updateTitleColIndex = 1 ;
int updateSignColIndex = 2 ;
updateInfoTable = new UpdateInfoTable ( columnNames ) ;
updateInfoTable . setShowGrid ( false ) ;
updateInfoTable . setCellSelectionEnabled ( false ) ;
TableRowSorter < UpdateInfoTableModel > sorter = new TableRowSorter < > ( updateInfoTable . getDataModel ( ) ) ;
sorter . setSortable ( updateTimeColIndex , true ) ;
sorter . setSortable ( updateTitleColIndex , false ) ;
sorter . setSortable ( updateSignColIndex , false ) ;
sorter . setSortable ( UpdateInfoTable . UPDATE_DATE_INDEX , true ) ;
sorter . setSortable ( UpdateInfoTable . UPDATE_VERSION_INDEX , true ) ;
sorter . setSortable ( UpdateInfoTable . UPDATE_TITLE_INDEX , false ) ;
sorter . setSortable ( UpdateInfoTable . SIGN_INDEX , false ) ;
updateInfoTable . setRowSorter ( sorter ) ;
List < RowSorter . SortKey > sortKeys = new ArrayList < > ( ) ;
sortKeys . add ( new RowSorter . SortKey ( updateTimeColIndex , SortOrder . DESCENDING ) ) ;
sortKeys . add ( new RowSorter . SortKey ( UpdateInfoTable . UPDATE_DATE_INDEX , SortOrder . DESCENDING ) ) ;
sortKeys . add ( new RowSorter . SortKey ( UpdateInfoTable . UPDATE_VERSION_INDEX , SortOrder . DESCENDING ) ) ;
sorter . setSortKeys ( sortKeys ) ;
updateInfoTable . getTableHeader ( ) . setReorderingAllowed ( false ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( updateTimeColIndex ) . setMaxWidth ( UPDATE_INFO_TABLE_HEADER_TIME_WIDTH ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( updateTimeColIndex ) . setMinWidth ( UPDATE_INFO_TABLE_HEADER_TIME_WIDTH ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( updateSignColIndex ) . setMaxWidth ( 0 ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( updateSignColIndex ) . setMinWidth ( 0 ) ;
updateInfoTable . getTableHeader ( ) . getColumnModel ( ) . getColumn ( updateSignColIndex ) . setMaxWidth ( 0 ) ;
updateInfoTable . getTableHeader ( ) . getColumnModel ( ) . getColumn ( updateSignColIndex ) . setMinWidth ( 0 ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( UpdateInfoTable . UPDATE_DATE_INDEX ) . setMaxWidth ( UPDATE_INFO_TABLE_HEADER_TIME_WIDTH ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( UpdateInfoTable . UPDATE_DATE_INDEX ) . setMinWidth ( UPDATE_INFO_TABLE_HEADER_TIME_WIDTH ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( UpdateInfoTable . UPDATE_VERSION_INDEX ) . setMaxWidth ( UPDATE_INFO_TABLE_HEADER_TIME_WIDTH ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( UpdateInfoTable . UPDATE_VERSION_INDEX ) . setMinWidth ( UPDATE_INFO_TABLE_HEADER_TIME_WIDTH ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( UpdateInfoTable . SIGN_INDEX ) . setMaxWidth ( 0 ) ;
updateInfoTable . getColumnModel ( ) . getColumn ( UpdateInfoTable . SIGN_INDEX ) . setMinWidth ( 0 ) ;
updateInfoTable . getTableHeader ( ) . getColumnModel ( ) . getColumn ( UpdateInfoTable . SIGN_INDEX ) . setMaxWidth ( 0 ) ;
updateInfoTable . getTableHeader ( ) . getColumnModel ( ) . getColumn ( UpdateInfoTable . SIGN_INDEX ) . setMinWidth ( 0 ) ;
updateInfoTable . getColumn ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Date" ) ) . setCellRenderer ( new UpdateInfoTableCellRender ( ) ) ;
updateInfoTable . getColumn ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Version" ) ) . setCellRenderer ( new UpdateInfoTableCellRender ( ) ) ;
updateInfoTable . getColumn ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Content" ) ) . setCellRenderer ( new UpdateInfoTextAreaCellRender ( ) ) ;
}
@ -304,18 +298,18 @@ public class UpdateMainDialog extends UIDialog {
updateButton . setEnabled ( false ) ;
double [ ] rowSize = { TableLayout . PREFERRED } ;
double [ ] colSize = { TableLayout . PREFERRED } ;
UILabel versionLabel = new UILabel ( UpdateConstants . DEFAULT_APP_NAME + StringUtils . BLANK + ProductConstants . VERSION ) ;
versionLabel . setFont ( new Font ( "Default" , Font . BOLD , 16 ) ) ;
double [ ] colSize = { UPDATE_CONTENT_PANE_LABEL_COLUMN_SIZE , TableLayout . PREFERRED } ;
updateVersionReminderPane = initPaneContent (
Color . WHITE , rowSize , colSize ,
new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Designer_Version" ) ) ,
new UILabel ( UpdateConstants . DEFAULT_APP_NAME + StringUtils . BLANK + ProductConstants . VERSION )
Color . WHITE , rowSize , colSize , versionLabel
) ;
String notInstallVersion = InterProviderFactory . getProvider ( ) . getLocText ( "Fine-Core_Basic_About_No_Build" ) ;
String versionBuildNo = GeneralUtils . getVersion ( ) + HYPHEN + GeneralUtils . readBuildNO ( ) ;
jarCurrentLabel = new UILabel ( ComparatorUtils . equals ( notInstallVersion , GeneralUtils . readBuildNO ( ) ) ? notInstallVersion : versionBuildNo , SwingConstants . CENTER ) ;
UILabel noJarPreviousRevision = new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_No_Previous_Version" ) ) ;
UpdateActionLabel jarRestorePreviousRevision = new UpdateActionLabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Restore" ) , false ) ;
jarRestorePreviousRevision . setForeground ( new Color ( RESTORE_LABEL_COLOR ) ) ;
jarRestorePreviousRevision . addActionListener ( new ActionListener ( ) {
@ -327,7 +321,7 @@ public class UpdateMainDialog extends UIDialog {
} ) ;
//choose RestoreLabel to show
boolean isNeedRestore = ArrayUtils . isNotEmpty ( UpdateFileUtils . listBackupVersions ( ) ) ;
jarRestoreLabel = isNeedRestore ? jarRestorePreviousRevision : noJarPreviousRevision ;
jarRestoreLabel = isNeedRestore ? jarRestorePreviousRevision : null ;
}
private void initComponents ( ) {
@ -542,7 +536,8 @@ public class UpdateMainDialog extends UIDialog {
private ArrayList < Object [ ] > generateUpdateInfoList ( JSONArray jsonArray , String keyword ) throws Exception {
for ( int i = 0 ; i < jsonArray . length ( ) ; i + + ) {
JSONObject jo = ( JSONObject ) jsonArray . get ( i ) ;
String updateTitle = ( String ) jo . get ( "jiraId" ) + jo . get ( "info" ) ;
String updateTitle = ( String ) jo . get ( "jiraId" ) + " " + jo . get ( "info" ) ;
String updateVersionStr = ( String ) jo . get ( "version" ) ;
String updateTimeStr = ( String ) jo . get ( "updateTime" ) ;
Date updateTime = UPDATELOG_FORMAT . parse ( updateTimeStr ) ;
//形如 Build#release-2018.07.31.03.03.52.80
@ -557,7 +552,7 @@ public class UpdateMainDialog extends UIDialog {
}
}
if ( isValidLogInfo ( updateTitle ) ) {
updateInfoList . add ( new Object [ ] { UPDATE_INFO_TABLE_FORMAT . format ( updateTime ) , updateTitle , updateTime . after ( curJarDate ) } ) ;
updateInfoList . add ( new Object [ ] { UPDATE_INFO_TABLE_FORMAT . format ( updateTime ) , updateVersionStr , update Title , updateTime . after ( curJarDate ) } ) ;
}
}
return new ArrayList < > ( updateInfoList ) ;
@ -590,14 +585,12 @@ public class UpdateMainDialog extends UIDialog {
Date currentDate = ( new SimpleDateFormat ( "yyyy.MM.dd.HH.mm.ss" ) ) . parse ( currentNO , new ParsePosition ( currentNO . indexOf ( "-" ) + 1 ) ) ;
if ( DateUtils . subtractDate ( jarDate , currentDate , DateUtils . SECOND ) > 0 ) {
updateButton . setEnabled ( true ) ;
updateLabel . setVisible ( true ) ;
loadingLabel . stopLoading ( buildNO . contains ( "-" ) ? buildNO . substring ( buildNO . lastIndexOf ( "-" ) + 1 ) : buildNO ) ;
} else {
loadingLabel . stopLoading ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Updater_Already_Latest_Version" ) ) ;
}
} else {
updateButton . setEnabled ( true ) ;
updateLabel . setVisible ( true ) ;
loadingLabel . stopLoading ( buildNO . contains ( "-" ) ? buildNO . substring ( buildNO . lastIndexOf ( "-" ) + 1 ) : buildNO ) ;
}
@ -666,7 +659,8 @@ public class UpdateMainDialog extends UIDialog {
}
private ActionLabel getNewFeatureActionLabel ( final String text ) {
ActionLabel actionLabel = new ActionLabel ( text ) ;
ActionLabel actionLabel = new ActionLabel ( text , new Color ( RESTORE_LABEL_COLOR ) ) ;
actionLabel . setDrawUnderLine ( false ) ;
actionLabel . addActionListener ( new NewFeatureAction ( ) ) ;
return actionLabel ;
}
@ -701,7 +695,6 @@ public class UpdateMainDialog extends UIDialog {
progressBar . setString ( Toolkit . i18nText ( "Fine-Design_Update_Info_Wait_Message" ) ) ;
UpdateCallBack callBack = new UpdateProgressCallBack ( progressBar ) ;
updateButton . setEnabled ( false ) ;
updateLabel . setVisible ( false ) ;
RestoreResultDialog . deletePreviousPropertyFile ( ) ;
final String installLib = StableUtils . pathJoin ( StableUtils . getInstallHome ( ) , ProjectConstants . LOGS_NAME , UpdateConstants . INSTALL_LIB ) ;
final JFrame frame = DesignerContext . getDesignerFrame ( ) ;