Browse Source

REPORT-75919 【迭代】更新日志-交互问题

1、修改交互
feature/x
Link.Zhao 2 years ago
parent
commit
479ea1a2f5
  1. 19
      designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java
  2. 69
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  3. 6
      designer-base/src/main/java/com/fr/design/update/ui/widget/UpdateInfoTable.java
  4. 6
      designer-base/src/main/java/com/fr/design/update/ui/widget/UpdateInfoTableCellRender.java
  5. 2
      designer-base/src/main/java/com/fr/design/update/ui/widget/UpdateInfoTextAreaCellRender.java

19
designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java

@ -14,11 +14,18 @@ import java.awt.event.MouseEvent;
public class ActionLabel extends UILabel {
private ActionListener actionListener;
private Color color;
// 文字是否有下划线
private boolean drawUnderLine = true;
public ActionLabel(String text) {
this(text, Color.blue);
}
public ActionLabel(String text, boolean drawUnderLine) {
this(text, Color.blue);
this.drawUnderLine = drawUnderLine;
}
public ActionLabel(String text, Color color) {
super(text);
this.color = color;
@ -39,7 +46,9 @@ public class ActionLabel extends UILabel {
super.paintComponent(_gfx);
_gfx.setColor(this.color);
_gfx.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1);
if (drawUnderLine) {
_gfx.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1);
}
}
private MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() {
@ -95,4 +104,12 @@ public class ActionLabel extends UILabel {
}
}
};
public boolean isDrawUnderLine() {
return drawUnderLine;
}
public void setDrawUnderLine(boolean drawUnderLine) {
this.drawUnderLine = drawUnderLine;
}
}

69
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -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, updateTitle, 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();

6
designer-base/src/main/java/com/fr/design/update/ui/widget/UpdateInfoTable.java

@ -10,6 +10,12 @@ import java.util.Vector;
* Created by XINZAI on 2018/8/21.
*/
public class UpdateInfoTable extends JTable {
public static int UPDATE_DATE_INDEX = 0;
public static int UPDATE_VERSION_INDEX = 1;
public static int UPDATE_TITLE_INDEX = 2;
public static int SIGN_INDEX = 3;
private UpdateInfoTableModel dataModel;
public UpdateInfoTable(TableModel dm) {

6
designer-base/src/main/java/com/fr/design/update/ui/widget/UpdateInfoTableCellRender.java

@ -18,11 +18,11 @@ public class UpdateInfoTableCellRender extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
cell.setBackground((row & 1) != 0 ? new Color(0xf0f0f0) : Color.WHITE);
if ((Boolean) table.getValueAt(row, 2)) {
if ((Boolean) table.getValueAt(row, UpdateInfoTable.SIGN_INDEX)) {
cell.setBackground(new Color(0xdfecfd));
}
if (column == 0) {
//设置首列日期居中显示
if (column == UpdateInfoTable.UPDATE_DATE_INDEX || column == UpdateInfoTable.UPDATE_VERSION_INDEX) {
//设置日期,版本居中显示
setHorizontalAlignment(JLabel.CENTER);
for (int i = 1; row - i >= 0; i++) {

2
designer-base/src/main/java/com/fr/design/update/ui/widget/UpdateInfoTextAreaCellRender.java

@ -35,7 +35,7 @@ public class UpdateInfoTextAreaCellRender extends JTextArea implements TableCell
setText(value == null ? "" : value.toString());
setBackground((row & 1) != 0 ? new Color(0xf0f0f0) : Color.WHITE);
if ((Boolean) table.getValueAt(row, 2)) {
if ((Boolean) table.getValueAt(row, UpdateInfoTable.SIGN_INDEX)) {
setBackground(new Color(0xdfecfd));
}
return this;

Loading…
Cancel
Save