Browse Source

Merge pull request #1175 in DESIGN/design from feature/10.0 to refactor/19.4.3

* commit '3d8ece2c7ff736201019eec8fe0e333b940d68ec': (28 commits)
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
  MOBILE-23325 【单选按钮样式】图文按钮:上传图片后,移动端图片显示很模糊
  KERNEL-418 更新升级重构
  无jira任务,sonar问题修复
  无jira任务,sonar问题修复
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
  CHART-10233 插件超链
  CHART-10233
  CHART-10233 超链面板
  CHART-10233 代码质量
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
  CHART-10233 代码质量
  CHART-10233 超链面板
  REPORT-21689 水印密度最小值限制,根据交互提供的内容补充
  REPORT-21689 水印密度最小值限制,根据交互提供的内容补充
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
  ...
persist/11.0
Wim.Zhai 5 years ago
parent
commit
d83780bfc5
  1. 20
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  2. 19
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  3. 28
      designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java
  4. 34
      designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java
  5. 107
      designer-base/src/main/java/com/fr/design/report/WatermarkPane.java
  6. 79
      designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java
  7. 60
      designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java
  8. 2
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java
  9. 55
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java
  10. 118
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  11. 23
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  12. 2
      designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java
  13. 3
      designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java
  14. 19
      designer-base/src/main/java/com/fr/design/utils/ImageUtils.java
  15. 13
      designer-base/src/main/java/com/fr/design/web/CustomIconPane.java
  16. 26
      designer-base/src/test/java/com/fr/design/update/ui/dialog/RestoreResultDialogTest.java
  17. 8
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  18. 2
      designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java
  19. 207
      designer-chart/src/main/java/com/fr/design/chartx/component/HyperLinkPane.java
  20. 12
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  21. 36
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java
  22. 2
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java
  23. 7
      designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java
  24. 3
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  25. 12
      designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java
  26. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  27. 644
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  28. 9
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java
  29. 3
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

20
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -2,6 +2,7 @@ package com.fr.design.data;
import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor;
import com.fr.data.core.DataCoreXmlUtils;
@ -30,6 +31,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException;
import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleContext;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
@ -48,8 +50,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 设计器管理操作数据集的类:
@ -444,11 +446,18 @@ public abstract class DesignTableDataManager {
} catch (Exception e) {
throw new TableDataException(e.getMessage(), e);
} finally {
new Timer().schedule(new TimerTask() {
ScheduledExecutorService scheduledExecutorService = ModuleContext
.getExecutor()
.newSingleThreadScheduledExecutor(new NamedThreadFactory(""));
scheduledExecutorService.schedule(new Runnable() {
@Override
public void run() {
loadingBar.close();
if (loadingBar != null) {
loadingBar.close();
}
}
}, 100);
}, 100, TimeUnit.MILLISECONDS);
scheduledExecutorService.shutdown();
}
}
@ -513,6 +522,7 @@ public abstract class DesignTableDataManager {
if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter.
final ParameterInputPane pPane = new ParameterInputPane(inParameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}

19
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -39,6 +39,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
private String spinnerName = StringUtils.EMPTY;
private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null;
private boolean lessMinValue = false;
public UISpinner(double minValue, double maxValue, double dierta) {
@ -93,6 +94,18 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
return textField;
}
public UIButton getNextButton() {
return nextButton;
}
public boolean isLessMinValue() {
return lessMinValue;
}
public void resetLessMinValue() {
lessMinValue = false;
}
public void setValue(double value) {
setValue(value, true);
}
@ -109,7 +122,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(spinnerName);
}
value = value < minValue ? minValue : value;
lessMinValue = value < minValue;
value = lessMinValue ? minValue : value;
value = value > maxValue ? maxValue : value;
if (CommonUtils.equals(value, this.value)) {
return;
@ -131,7 +145,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(spinnerName);
}
value = value < minValue ? minValue : value;
lessMinValue = value < minValue;
value = lessMinValue ? minValue : value;
value = value > maxValue ? maxValue : value;
if (CommonUtils.equals(value, this.value)) {

28
designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java

@ -3,8 +3,6 @@ package com.fr.design.gui.ispinner;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/**
* Created by IntelliJ IDEA.
@ -31,7 +29,7 @@ public class UnsignedIntUISpinner extends UISpinner {
@Override
protected UINumberField initNumberField() {
final UIIntNumberField numberField = new UIIntNumberField() {
return new UIIntNumberField() {
public boolean shouldResponseChangeListener() {
return false;
}
@ -44,29 +42,5 @@ public class UnsignedIntUISpinner extends UISpinner {
};
}
};
numberField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
/**
* 失去焦点后再做范围限制不然最小值为 100 输个 1 都不让....
* @param e
*/
@Override
public void focusLost(FocusEvent e) {
double value = numberField.getValue();
if (!isOverMaxOrMinValue(value)) {
return;
}
numberField.setValue(value < minValue ? minValue : maxValue);
}
private boolean isOverMaxOrMinValue(double value) {
return value < minValue || value > maxValue;
}
});
return numberField;
}
}

34
designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java

@ -1,10 +1,14 @@
package com.fr.design.gui.style;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.module.ModuleContext;
import com.fr.value.ClearableLazyValue;
import org.jetbrains.annotations.NotNull;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created with IntelliJ IDEA.
@ -14,31 +18,35 @@ import java.util.TimerTask;
* To change this template use File | Settings | File Templates.
*/
public class FormatePaneNumField extends UITextField {
private Timer timer;
private ClearableLazyValue<ScheduledExecutorService> ses = new ClearableLazyValue<ScheduledExecutorService>() {
@NotNull
@Override
protected ScheduledExecutorService compute() {
return ModuleContext.getExecutor()
.newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange"));
}
};
public FormatePaneNumField() {
super();
}
@Override
protected void attributeChange() {
if (!AbstractAttrNoScrollPane.isHasChangeListener()) {
return;
}
if(timer != null){
timer.cancel();
}
timer = new Timer();
timer.schedule(new TimerTask() {
ses.getValue().schedule(new Runnable() {
@Override
public void run() {
runChange();
}
},100);
}, 100, TimeUnit.MILLISECONDS);
}
protected void runChange(){
protected void runChange() {
super.attributeChange();
timer.cancel();
ses.getValue().shutdown();
ses.drop();
}
}

107
designer-base/src/main/java/com/fr/design/report/WatermarkPane.java

@ -23,6 +23,9 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.Color;
@ -30,6 +33,13 @@ import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.FocusAdapter;
import java.awt.Dialog;
import java.awt.FlowLayout;
/**
* Created by plough on 2018/5/15.
@ -49,6 +59,13 @@ public class WatermarkPane extends BasicPane {
private UISpinner verticalGapSpinner;
// 文字颜色
private NewColorSelectPane colorPane;
//间距超过限制消息
private UILabel message;
//横向间距最小值
public static final int HORIZONTAL_GAP_MIX = 100;
//纵向间距最小值
public static final int VERTICAL_GAP_MIX = 50;
private static final Dimension SPINNER_DIMENSION = new Dimension(75, 20);
@ -57,6 +74,7 @@ public class WatermarkPane extends BasicPane {
}
private void initComponents() {
message = new UILabel();
this.setBorder(BorderFactory.createEmptyBorder(4, 4, -5, 4));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -93,7 +111,7 @@ public class WatermarkPane extends BasicPane {
public WatermarkAttr update() {
WatermarkAttr watermark = new WatermarkAttr();
watermark.setText(formulaPane.getUITextField().getText());
watermark.setFontSize((int)fontSizeComboBox.getSelectedItem());
watermark.setFontSize((int) fontSizeComboBox.getSelectedItem());
watermark.setHorizontalGap((int) horizontalGapSpinner.getValue());
watermark.setVerticalGap((int) verticalGapSpinner.getValue());
watermark.setColor(colorPane.getColor());
@ -109,7 +127,7 @@ public class WatermarkPane extends BasicPane {
this.formulaPane = formulaPane;
}
protected UIScrollPane initRightPane(){
protected UIScrollPane initRightPane() {
formulaPane = new TinyFormulaPane();
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontSizeComboBox.setEditable(true);
@ -117,7 +135,17 @@ public class WatermarkPane extends BasicPane {
verticalGapSpinner = new UnsignedIntUISpinner(50, Integer.MAX_VALUE, 1, 100);
horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0));
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
//失去焦点时要判断是否要弹出提示
horizontalGapSpinner.getTextField().addFocusListener(
createFocusListener4GapNumberField(horizontalGapSpinner, HORIZONTAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Horizontal_Gap_Over_Warning")));
verticalGapSpinner.getTextField().addFocusListener(createFocusListener4GapNumberField(verticalGapSpinner, VERTICAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Vertical_Gap_Over_Warning")));
//next 按钮 释放时也要判断是否要弹出提示
horizontalGapSpinner.getNextButton().addMouseListener(createMouseListener4GapNextButton(horizontalGapSpinner, HORIZONTAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Horizontal_Gap_Over_Warning")));
verticalGapSpinner.getNextButton().addMouseListener(createMouseListener4GapNextButton(verticalGapSpinner, VERTICAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Vertical_Gap_Over_Warning")));
JPanel fontSizeTypePane = new JPanel(new BorderLayout(10, 0));
fontSizeTypePane.add(fontSizeComboBox, BorderLayout.CENTER);
//水印间距面板
@ -144,18 +172,18 @@ public class WatermarkPane extends BasicPane {
JPanel rightContentPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Watermark_Text")), formulaPane},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Font_Size")), fontSizeTypePane},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Watermark_Gap")),watermarkGapPane },
{null,watermarkGapTipsPane },
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Watermark_Gap")), watermarkGapPane},
{null, watermarkGapTipsPane},
{colorLabelPane, colorPane},
}, rowSize, columnSize, 10);
rightContentPane.setBorder(BorderFactory.createEmptyBorder(15, 12, 10, 12));
UIScrollPane configPane = new UIScrollPane(rightContentPane);
configPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Config"),null));
configPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Config"), null));
return configPane;
}
protected void populateFontSize(int fontSize){
protected void populateFontSize(int fontSize) {
this.fontSizeComboBox.setSelectedItem(fontSize);
this.fontSizeComboBox.addItemListener(new ItemListener() {
@Override
@ -165,7 +193,7 @@ public class WatermarkPane extends BasicPane {
});
}
protected void populateWatermarkGap(WatermarkAttr watermark){
protected void populateWatermarkGap(WatermarkAttr watermark) {
this.horizontalGapSpinner.setValue(watermark.getHorizontalGap());
this.horizontalGapSpinner.addUISpinnerFocusListenner(new FocusListener() {
@ -195,7 +223,7 @@ public class WatermarkPane extends BasicPane {
});
}
protected void paintPreviewPane(){
protected void paintPreviewPane() {
watermarkPreviewPane.repaint(update());
}
@ -235,4 +263,65 @@ public class WatermarkPane extends BasicPane {
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark");
}
/**
* 创建水印间距文本段焦点监听器
*
* @return
*/
private FocusListener createFocusListener4GapNumberField(final UISpinner spinner, final int limitMinValue, final String messageStr) {
return new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (!spinner.isLessMinValue()) {
return;
}
spinner.resetLessMinValue();
createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString());
}
};
}
/**
* 创建水印间距微调器 NextButton 的鼠标释放监听器
*
* @param messageStr 提示消息
* @param limitMinValue 限制的最小值
* @return
*/
private MouseListener createMouseListener4GapNextButton(final UISpinner spinner, final int limitMinValue, final String messageStr) {
MouseAdapter mouseAdapter = new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (!spinner.isLessMinValue()) {
return;
}
spinner.resetLessMinValue();
createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString());
}
};
return mouseAdapter;
}
/**
* 创建超过水印间距限制的对话框
*
* @param messageStr 提示消息
*/
private void createGapDialog(String messageStr) {
JDialog dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(WatermarkPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), true);
dialog.setSize(new Dimension(268, 118));
message.setText(messageStr);
JPanel upPane = new JPanel();
UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
upPane.add(uiLabel);
upPane.add(message);
dialog.add(upPane);
dialog.setResizable(false);
dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(WatermarkPane.this));
dialog.setVisible(true);
dialog.dispose();
}
}

79
designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java

@ -0,0 +1,79 @@
package com.fr.design.update.actions;
import com.fr.decision.update.backup.Recover;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.decision.update.exception.UpdateException;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import java.io.File;
import java.io.IOException;
/**
* @author Bryant
* @version 10.0
* Created by Bryant on 2019-10-09
*/
public class RecoverForDesigner implements Recover {
@Override
public boolean recover() {
try{
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNERBACKUPPATH),
StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME));
return true;
} catch (IOException ignore) {
FineLoggerFactory.getLogger().error("Recover error for designer");
return false;
}
}
@Override
public boolean backup() {
String installHome = StableUtils.getInstallHome();
//jar包备份文件的目录为"backup/"+jar包当前版本号
String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO()));
backupFilesFromInstallEnv(todayBackupDir);
backupFilesFromInstallLib(installHome, todayBackupDir);
try {
File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH));
CommonUtils.mkdirs(file);
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH));
return true;
}catch (IOException e) {
UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage(),exception);
return false;
}
}
private void backupFilesFromInstallEnv(String todayBackupDir) {
try {
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)));
IOUtils.copyFilesInDirByPath(
StableUtils.pathJoin(WorkContext.getCurrent().getPath(),ProjectConstants.LIB_NAME),
StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH));
} catch (IOException e) {
UpdateException exception = new UpdateException(e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in env failed");
}
}
private void backupFilesFromInstallLib(String installHome, String todayBackupDir) {
try {
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)));
IOUtils.copyFilesInDirByPath(
StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH));
} catch (IOException e) {
UpdateException exception = new UpdateException(e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in install failed");
}
}
}

60
designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java

@ -1,60 +0,0 @@
package com.fr.design.update.domain;
/**
* Created by XINZAI on 2018/8/21.
*/
import java.awt.Color;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 更新升级的常量
*/
public interface UpdateConstants {
String APPS_FOLDER_NAME = "webapps";
int CONNECTION_TIMEOUT = 1000 * 5;
Color BAR_COLOR = new Color(0x3384F0);
String CHANGELOG_X_START = "2018-07-11";
String DEFAULT_APP_NAME = "FineReport";
String DOWNLOAD_DIR = "update";
String DESIGNER_BACKUP_DIR = "designerbackup";
String UPDATE_CACHE_CONFIG_X = "updateCacheConfig10";
String UPDATE_CACHE_INFO_X = "updateCacheInfo10";
int BYTE = 153600;
List<String> JARS_FOR_SERVER_X = Collections.unmodifiableList(Arrays.asList(new String[]{
"fine-activator-10.0.jar",
"fine-core-10.0.jar",
"fine-report-engine-10.0.jar",
"fine-decision-10.0.jar",
"fine-decision-report-10.0.jar",
"fine-schedule-10.0.jar",
"fine-schedule-report-10.0.jar",
"fine-swift-log-adaptor-10.0.jar",
"fine-webui-10.0.jar",
"fine-datasource-10.0.jar",
"fine-third-10.0.jar",
"fine-accumulator-10.0.jar"
}));
List<String> JARS_FOR_DESIGNER_X = Collections.unmodifiableList(Arrays.asList(new String[]{
"fine-report-designer-10.0.jar",
"aspectjrt.jar"
}));
List<String> LOG_TYPE = Collections.unmodifiableList(Arrays.asList(new String[]{
"REPORT", "MOBILE", "CHART", "PFC", "BI"
}));
}

2
designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java

@ -1,9 +1,9 @@
package com.fr.design.update.ui.dialog;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.factory.DirectoryOperationFactory;
import com.fr.design.update.ui.widget.ColorfulCellRender;
import com.fr.design.utils.gui.GUICoreUtils;

55
designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java

@ -1,17 +1,16 @@
package com.fr.design.update.ui.dialog;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.design.RestartHelper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
@ -25,6 +24,7 @@ import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -45,7 +45,7 @@ public class RestoreResultDialog extends JDialog {
initCommonComponents();
}
public RestoreResultDialog(Frame parent, boolean modal, String jarDir) {
RestoreResultDialog(Frame parent, boolean modal, String jarDir) {
super(parent, modal);
this.jarRestoreDir = jarDir;
if (ComparatorUtils.equals(jarDir, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restore_Old_Version"))) {
@ -92,9 +92,7 @@ public class RestoreResultDialog extends JDialog {
jarProgressLabel.setVisible(true);
progressLabelPane.add(jarProgressLabel);
pane.add(progressLabelPane, BorderLayout.CENTER);
UpdateMainDialog.deletePreviousPropertyFile();
deletePreviousPropertyFile();
putJarBackupFiles();
restartButton.setEnabled(true);
restartLaterButton.setEnabled(true);
@ -102,6 +100,15 @@ public class RestoreResultDialog extends JDialog {
this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore"));
}
static boolean deletePreviousPropertyFile() {
File moveFile = new File(RestartHelper.MOVE_FILE);
File delFile = new File(RestartHelper.RECORD_FILE);
if (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) {
return StableUtils.deleteFile(moveFile) && StableUtils.deleteFile(delFile);
}
return false;
}
private void initOldVersionRestoreComps() {
this.setResizable(false);
JPanel pane = new JPanel();
@ -151,8 +158,8 @@ public class RestoreResultDialog extends JDialog {
}
private void putJarBackupFiles() {
Map<String, String> map = new HashMap<String, String>();
java.util.List<String> list = new ArrayList<String>();
Map<String, String> map = new HashMap<>();
List<String> list = new ArrayList<>();
String installHome = StableUtils.getInstallHome();
putJarBackupFilesToInstallLib(installHome, map, list);
@ -161,23 +168,29 @@ public class RestoreResultDialog extends JDialog {
RestartHelper.saveFilesWhichToDelete(list.toArray(new String[list.size()]));
}
private void putJarBackupFilesToInstallLib(String installHome, Map<String, String> map, java.util.List<String> list) {
List<String> files = UpdateConstants.JARS_FOR_DESIGNER_X;
private void putJarBackupFilesToInstallLib(String installHome, Map<String, String> map, List<String> list) {
String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR;
for (String file : files) {
map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file),
StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file));
list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file));
File installLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.DESIGNERBACKUPPATH));
File[] files = installLib.listFiles();
if (files != null) {
for (File file : files) {
map.put(file.getAbsolutePath(),
StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName()));
list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName()));
}
}
}
private void putJarBackupFilesToInstallEnv(String installHome, Map<String, String> map, java.util.List<String> list) {
List<String> files = UpdateConstants.JARS_FOR_SERVER_X;
private void putJarBackupFilesToInstallEnv(String installHome, Map<String, String> map, List<String> list) {
String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR;
for (String file : files) {
map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file),
StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file));
list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file));
File installEnv = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.BACKUPPATH));
File[] files = installEnv.listFiles();
if (files != null) {
for (File file : files) {
map.put(file.getAbsolutePath(),
StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, file.getName()));
list.add(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, file.getName()));
}
}
}
}

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

@ -1,5 +1,6 @@
package com.fr.design.update.ui.dialog;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.decision.update.info.UpdateCallBack;
import com.fr.decision.update.info.UpdateProgressCallBack;
import com.fr.design.RestartHelper;
@ -9,11 +10,11 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.actions.FileProcess;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.domain.UpdateInfoCachePropertyManager;
import com.fr.design.update.factory.DirectoryOperationFactory;
import com.fr.design.update.ui.widget.LoadingLabel;
@ -23,22 +24,15 @@ import com.fr.design.update.ui.widget.UpdateInfoTableCellRender;
import com.fr.design.update.ui.widget.UpdateInfoTableModel;
import com.fr.design.update.ui.widget.UpdateInfoTextAreaCellRender;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.general.*;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.*;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.workspace.WorkContext;
import com.sun.java.swing.plaf.motif.MotifProgressBarUI;
@ -46,21 +40,11 @@ import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.TableRowSorter;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -69,6 +53,8 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutionException;
import static java.nio.charset.StandardCharsets.*;
/**
* Created by XINZAI on 2018/8/21.
*/
@ -121,8 +107,6 @@ public class UpdateMainDialog extends UIDialog {
//搜索更新信息关键词文本框
private UITextField searchUpdateInfoKeyword;
private boolean updateSuccessful;
private UpdateInfoTable updateInfoTable;
private ArrayList<Object[]> updateInfoList;
@ -248,12 +232,12 @@ public class UpdateMainDialog extends UIDialog {
updateInfoTable.setShowGrid(false);
updateInfoTable.setCellSelectionEnabled(false);
TableRowSorter<UpdateInfoTableModel> sorter = new TableRowSorter<UpdateInfoTableModel>(updateInfoTable.getDataModel());
TableRowSorter<UpdateInfoTableModel> sorter = new TableRowSorter<>(updateInfoTable.getDataModel());
sorter.setSortable(updateTimeColIndex, true);
sorter.setSortable(updateTitleColIndex, false);
sorter.setSortable(updateSignColIndex, false);
updateInfoTable.setRowSorter(sorter);
List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>();
List<RowSorter.SortKey> sortKeys = new ArrayList<>();
sortKeys.add(new RowSorter.SortKey(updateTimeColIndex, SortOrder.DESCENDING));
sorter.setSortKeys(sortKeys);
@ -367,6 +351,7 @@ public class UpdateMainDialog extends UIDialog {
try {
downloadFileConfig = get();
showDownLoadInfo();
afterInit();
} catch (InterruptedException e) {
stopLoading();
Thread.currentThread().interrupt();
@ -380,7 +365,7 @@ public class UpdateMainDialog extends UIDialog {
}
private SwingWorker<JSONArray, Void> getUpdateInfo(final String keyword) {
updateInfoList = new ArrayList<Object[]>();
updateInfoList = new ArrayList<>();
lastUpdateCacheTime = UpdateConstants.CHANGELOG_X_START;
String cacheConfigPath = getUpdateCacheConfig();
cacheProperty = new UpdateInfoCachePropertyManager(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), "resources", "offlineres", cacheConfigPath));
@ -395,6 +380,8 @@ public class UpdateMainDialog extends UIDialog {
return new SwingWorker<JSONArray, Void>() {
@Override
protected JSONArray doInBackground() {
CloseableHttpClient httpClient;
CloseableHttpResponse response;
try {
getUpdateInfoSuccess = false;
//step1:read from cache file
@ -403,16 +390,15 @@ public class UpdateMainDialog extends UIDialog {
if (downloadFileConfig == null) {
throw new Exception("network error.");
}
HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("changelog10") + "&start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr());
hc.asGet();
hc.setTimeout(UpdateConstants.CONNECTION_TIMEOUT * 2);
String responseText = hc.getResponseText();
HttpGet get = new HttpGet(CloudCenter.getInstance().acquireUrlByKind("changelog10") + "&start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr());
httpClient = HttpToolbox.getHttpClient(CloudCenter.getInstance().acquireUrlByKind("changelog10") + "&start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr());
response = httpClient.execute(get);
String responseText = CommonIOUtils.inputStream2String(response.getEntity().getContent(),EncodeConstants.ENCODING_UTF_8).trim();
JSONArray array = JSONArray.create();
//假如返回"-1",说明socket出错了
if (!ComparatorUtils.equals(responseText, "-1")) {
array = new JSONArray(responseText);
}
hc.release();
return array;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
@ -430,7 +416,6 @@ public class UpdateMainDialog extends UIDialog {
getUpdateInfoSuccess = true;
//step4:update cache file,start from cacheRecordTime,end latest server jartime
updateCachedInfoFile(jsonArray);
afterInit();
} catch (Exception e) {
getUpdateInfoSuccess = true;
FineLoggerFactory.getLogger().error(e.getMessage());
@ -441,6 +426,7 @@ public class UpdateMainDialog extends UIDialog {
private void afterInit() {
if (autoUpdateAfterInit) {
updateButton.setEnabled(true);
updateButton.doClick();
}
}
@ -454,7 +440,7 @@ public class UpdateMainDialog extends UIDialog {
return;
}
if (cacheFile.exists()) {
try (InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8");
try (InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), StandardCharsets.UTF_8);
BufferedReader br = new BufferedReader(streamReader)) {
String readStr, updateTimeStr;
while ((readStr = br.readLine()) != null) {
@ -499,13 +485,14 @@ public class UpdateMainDialog extends UIDialog {
if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) {
return;
}
try (OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), EncodeConstants.ENCODING_UTF_8);
BufferedWriter bufferWriter = new BufferedWriter(writerStream)) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = (JSONObject) jsonArray.get(i);
bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title"));
bufferWriter.newLine();
bufferWriter.flush();
try (OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), UTF_8)) {
try (BufferedWriter bufferWriter = new BufferedWriter(writerStream)) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = (JSONObject) jsonArray.get(i);
bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title"));
bufferWriter.newLine();
bufferWriter.flush();
}
}
}
lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS;
@ -523,6 +510,9 @@ public class UpdateMainDialog extends UIDialog {
//形如 Build#release-2018.07.31.03.03.52.80
String currentNO = GeneralUtils.readBuildNO();
Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1));
if (curJarDate == null) {
curJarDate = updateTime;
}
if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) {
if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateTitle, keyword)) {
continue;
@ -532,7 +522,7 @@ public class UpdateMainDialog extends UIDialog {
updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateTitle, updateTime.after(curJarDate)});
}
}
return new ArrayList<Object[]>(updateInfoList);
return new ArrayList<>(updateInfoList);
}
private boolean containsKeyword(String str, String keyword) {
@ -594,25 +584,26 @@ public class UpdateMainDialog extends UIDialog {
updateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (updateSuccessful) {
RestartHelper.restart();
} else {
int a = JOptionPane.showConfirmDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"),Toolkit.i18nText("Fine-Design_Update_Info_Title"), JOptionPane.OK_CANCEL_OPTION);
if (a == 0) {
progressBar.setVisible(true);
progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message"));
UpdateCallBack callBack = new UpdateProgressCallBack(progressBar);
deletePreviousPropertyFile();
updateButton.setEnabled(false);
updateLabel.setVisible(false);
new FileProcess(callBack) {
@Override
public void onDownloadSuccess() {
updateButton.setEnabled(true);
progressBar.setVisible(false);
updateSuccessful = true;
updateButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restart_Designer"));
deleteForDesignerUpdate();
RestartHelper.restart();
}
@Override
public void onDownloadFailed() {
progressBar.setVisible(false);
deleteForDesignerUpdate();
JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message"));
RestartHelper.restart();
}
}.execute();
}
@ -620,22 +611,13 @@ public class UpdateMainDialog extends UIDialog {
});
}
/**
* 确保升级更新之前删除以前的配置文件
*/
public static void deletePreviousPropertyFile() {
//在进行更新升级之前确保move和delete.properties删除
File moveFile = new File(RestartHelper.MOVE_FILE);
File delFile = new File(RestartHelper.RECORD_FILE);
if ((moveFile.exists()) && (!moveFile.delete())) {
FineLoggerFactory.getLogger().error(RestartHelper.MOVE_FILE + "delete failed!");
}
if ((delFile.exists()) && (!delFile.delete())) {
FineLoggerFactory.getLogger().error(RestartHelper.RECORD_FILE + "delete failed!");
}
private void deleteForDesignerUpdate() {
File designerBackup = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH));
CommonUtils.deleteFile(designerBackup);
File downloadForDesigner = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DOWNLOADPATH));
CommonUtils.deleteFile(downloadForDesigner);
}
//获取备份目录
private String getBackupDirectory() {
return UpdateConstants.DESIGNER_BACKUP_DIR;
@ -687,10 +669,8 @@ public class UpdateMainDialog extends UIDialog {
/**
* 检查有效性
*
* @throws Exception
*/
@Override
public void checkValid() throws Exception {
}
}

23
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -2,7 +2,9 @@ package com.fr.design.upm;
import com.fr.base.FRContext;
import com.fr.design.dialog.UIDialog;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
@ -51,11 +53,24 @@ public class UpmFinder {
}
public static void showUPMDialog() {
UpmShowPane upmPane = new UpmShowPane();
if (dialog == null) {
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane);
boolean flag = true;
try {
Class.forName("com.teamdev.jxbrowser.chromium.Browser");
} catch (ClassNotFoundException e) {
flag = false;
}
if (flag) {
UpmShowPane upmPane = new UpmShowPane();
if (dialog == null) {
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane);
}
dialog.setVisible(true);
} else {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());
dialog.setAutoUpdateAfterInit();
dialog.showDialog();
}
dialog.setVisible(true);
}
public static void closeWindow() {

2
designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java

@ -3,7 +3,6 @@ package com.fr.design.upm;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
@ -30,5 +29,6 @@ public class UpmShowDialog extends UIDialog {
@Override
public void checkValid() throws Exception {
}
}

3
designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java

@ -27,7 +27,7 @@ public class UpmShowPane extends BasicPane {
return "UPM";
}
public UpmShowPane() {
UpmShowPane() {
setLayout(new BorderLayout());
if (UpmFinder.checkUPMResourcesExist()) {
modernUIPane = new ModernUIPane.Builder<>()
@ -65,5 +65,4 @@ public class UpmShowPane extends BasicPane {
}
add(modernUIPane, BorderLayout.CENTER);
}
}

19
designer-base/src/main/java/com/fr/design/utils/ImageUtils.java

@ -240,6 +240,7 @@ public class ImageUtils {
* @param opacityCompatible 是否处理背景透明
*/
public static BufferedImage scale(BufferedImage srcImg, float scale, boolean opacityCompatible) {
int scaleType;
if (scale < 0) {
// 自动修正负数
scale = -scale;
@ -247,7 +248,15 @@ public class ImageUtils {
int width = mul(Integer.toString(srcImg.getWidth(null)), Float.toString(scale)).intValue(); // 得到源图宽
int height = mul(Integer.toString(srcImg.getHeight(null)), Float.toString(scale)).intValue(); // 得到源图长
return CoreGraphHelper.toBufferedImage(scale(srcImg, width, height, opacityCompatible));
int srcHeight = srcImg.getHeight(null);
int srcWidth = srcImg.getWidth(null);
if (srcHeight < height || srcWidth < width) {
// 放大图片使用平滑模式
scaleType = Image.SCALE_SMOOTH;
} else {
scaleType = Image.SCALE_DEFAULT;
}
return CoreGraphHelper.toBufferedImage(scale(srcImg, width, height, opacityCompatible, scaleType));
}
private static BigDecimal mul(String v1, String v2) {
@ -268,18 +277,12 @@ public class ImageUtils {
* @param opacityCompatible 是否处理背景透明
* @return {@link Image}
*/
private static Image scale(BufferedImage srcImg, int width, int height, boolean opacityCompatible) {
public static Image scale(BufferedImage srcImg, int width, int height, boolean opacityCompatible, int scaleType) {
int srcHeight = srcImg.getHeight(null);
int srcWidth = srcImg.getWidth(null);
int scaleType;
if (srcHeight == height && srcWidth == width) {
// 源与目标长宽一致返回原图
return srcImg;
} else if (srcHeight < height || srcWidth < width) {
// 放大图片使用平滑模式
scaleType = Image.SCALE_SMOOTH;
} else {
scaleType = Image.SCALE_DEFAULT;
}
if (opacityCompatible) {//需要保留透明度背景
BufferedImage toImg = CoreGraphHelper.createBufferedImage(width, height, srcImg.getType());

13
designer-base/src/main/java/com/fr/design/web/CustomIconPane.java

@ -16,12 +16,12 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.ImageUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.ComparatorUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.ListMap;
import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations;
@ -39,6 +39,9 @@ import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* carl自定义Icon编辑
@ -452,13 +455,7 @@ public class CustomIconPane extends BasicPane {
String path = jf.getSelectedFile().getAbsolutePath();
// 图片存储有最大值48*48限制,没有超过最大值时,按原图大小存储,超过最大值后,压缩至最大值存储
Image image = BaseUtils.readImage(path);
BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH),
Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bufferedImage.createGraphics();
g2d.drawImage(image, 0, 0, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), null);
bufferedImage.flush();
g2d.dispose();
iconImage = bufferedImage;
iconImage = ImageUtils.scale((BufferedImage) image, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), true, Image.SCALE_SMOOTH);
if (iconImage != null) {
showImageLabel.setIcon(new ImageIcon(iconImage));
}

26
designer-base/src/test/java/com/fr/design/update/ui/dialog/RestoreResultDialogTest.java

@ -0,0 +1,26 @@
package com.fr.design.update.ui.dialog;
import com.fr.design.RestartHelper;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
public class RestoreResultDialogTest {
@Test
public void testDeletePreviousPropertyFile() {
File moveFile = new File(RestartHelper.MOVE_FILE);
File recordFile = new File(RestartHelper.RECORD_FILE);
try {
StableUtils.makesureFileExist(moveFile);
StableUtils.makesureFileExist(recordFile);
Assert.assertTrue(RestoreResultDialog.deletePreviousPropertyFile());
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
}
}

8
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -165,7 +165,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length];
int index = 0;
for (String chartID : chartIDs) {
ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(chartID);
ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID);
if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) {
continue;
}
@ -364,7 +364,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
try {
//兼容 图表类型选择界面会调到这边
ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID);
ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getCharts(chartID);
result = new String[charts.length];
for (int i = 0; i < charts.length; i++) {
//Chart && AbstractChart
@ -403,7 +403,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
//兼容
private String[] getCompatibleSubName(String chartID, ChartTypeUIProvider provider) {
ChartProvider[] chartProviders = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID);
ChartProvider[] chartProviders = ChartTypeManager.getInstanceWithCheck().getCharts(chartID);
if (chartProviders.length == 1) {
return new String[]{getName(chartID)};
@ -453,7 +453,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
try {
ChartProvider chartProvider = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID)[0];
ChartProvider chartProvider = ChartTypeManager.getInstanceWithCheck().getCharts(chartID)[0];
if (chartProvider instanceof Chart) {
//AbstractExtendedChartUIProvider
result = ((Chart) chartProvider).getChartName();

2
designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java

@ -126,7 +126,7 @@ public class ChartTypePane extends ChartCommonWizardPane {
ChartProvider chart4Update = cc.getSelectedChartProvider();
if (chart4Update == null) {
String plotID = this.chartIDs[mainTypeList.getSelectedIndex()];
ChartProvider chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()];
ChartProvider chart = ChartTypeManager.getInstance().getCharts(plotID)[iconViewList.getSelectedIndex()];
try {
chart4Update = (ChartProvider) chart.clone();
cc.addChart(chart4Update);

207
designer-chart/src/main/java/com/fr/design/chartx/component/HyperLinkPane.java

@ -0,0 +1,207 @@
package com.fr.design.chartx.component;
import com.fr.base.BaseFormula;
import com.fr.chart.web.ChartHyperPoplink;
import com.fr.chart.web.ChartHyperRelateCellLink;
import com.fr.chart.web.ChartHyperRelateFloatLink;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.javascript.ChartEmailPane;
import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane;
import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateCellLinkPane;
import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateFloatLinkPane;
import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.fun.HyperlinkProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.UIListControlPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.hyperlink.ReportletHyperlinkPane;
import com.fr.design.hyperlink.WebHyperlinkPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.javascript.JavaScriptImplPane;
import com.fr.design.javascript.ParameterJavaScriptPane;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.NameObject;
import com.fr.js.EmailJavaScript;
import com.fr.js.FormHyperlinkProvider;
import com.fr.js.JavaScript;
import com.fr.js.JavaScriptImpl;
import com.fr.js.NameJavaScript;
import com.fr.js.NameJavaScriptGroup;
import com.fr.js.ParameterJavaScript;
import com.fr.js.ReportletHyperlink;
import com.fr.js.WebHyperlink;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Nameable;
import com.fr.stable.bridge.StableFactory;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.JPanel;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2019-09-25
*/
public class HyperLinkPane extends UIListControlPane implements UIObserver {
private Map<String, BaseFormula> hyperLinkEditorMap;
private UIObserverListener uiObserverListener;
public HyperLinkPane() {
super();
this.setBorder(null);
}
@Override
public NameableCreator[] createNameableCreators() {
List<NameableCreator> creators = new ArrayList<NameableCreator>();
creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Reportlet"),
ReportletHyperlink.class, ReportletHyperlinkPane.class));
creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Mail"), EmailJavaScript.class, NewChartEmailPane.class));
creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Web"),
WebHyperlink.class, WebHyperlinkPane.class));
creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Dynamic_Parameters"),
ParameterJavaScript.class, ParameterJavaScriptPane.class));
creators.add(new NameObjectCreator("JavaScript", JavaScriptImpl.class, JavaScriptImplPane.class));
creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Float_Chart"),
ChartHyperPoplink.class, ChartHyperPoplinkPane.class));
creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Cell"),
ChartHyperRelateCellLink.class, ChartHyperRelateCellLinkPane.class));
creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Float"),
ChartHyperRelateFloatLink.class, ChartHyperRelateFloatLinkPane.class));
FormHyperlinkProvider hyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class);
creators.add(new NameObjectCreator(Toolkit.i18nText("Fine-Design_Chart_Link_Form"),
hyperlink.getClass(), FormHyperlinkPane.class));
Set<HyperlinkProvider> providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG);
for (HyperlinkProvider provider : providers) {
NameableCreator nc = provider.createHyperlinkCreator();
creators.add(nc);
}
return creators.toArray(new NameableCreator[creators.size()]);
}
public BasicBeanPane createPaneByCreators(NameableCreator creator) {
Constructor<? extends BasicBeanPane> constructor;
try {
constructor = creator.getUpdatePane().getConstructor(HashMap.class, boolean.class);
return constructor.newInstance(hyperLinkEditorMap, false);
} catch (InstantiationException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (IllegalAccessException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (NoSuchMethodException e) {
return super.createPaneByCreators(creator);
} catch (InvocationTargetException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
@Override
public void registerChangeListener(UIObserverListener listener) {
uiObserverListener = listener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
@Override
protected JPanel getLeftTopPane(UIToolbar topToolBar) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f, e};
double[] rowSize = {p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(getAddItemText()), topToolBar},
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
@Override
public void saveSettings() {
if (isPopulating) {
return;
}
uiObserverListener.doChange();
}
public void update(NameJavaScriptGroup nameGroup) {
Nameable[] nameables = update();
nameGroup.clear();
for (int i = 0; i < nameables.length; i++) {
JavaScript javaScript = (JavaScript) ((NameObject) nameables[i]).getObject();
String name = nameables[i].getName();
NameJavaScript nameJava = new NameJavaScript(name, javaScript);
nameGroup.addNameHyperlink(nameJava);
}
}
public void populate(NameJavaScriptGroup nameGroup, Map<String, BaseFormula> hyperLinkEditorMap) {
this.hyperLinkEditorMap = hyperLinkEditorMap;
List<NameObject> nameObjects = new ArrayList<NameObject>();
for (int i = 0; nameGroup != null && i < nameGroup.size(); i++) {
NameJavaScript javaScript = nameGroup.getNameHyperlink(i);
if (javaScript != null && javaScript.getJavaScript() != null) {
JavaScript script = javaScript.getJavaScript();
nameObjects.add(new NameObject(javaScript.getName(), script));
}
}
this.populate(nameObjects.toArray(new NameObject[nameObjects.size()]));
doLayout();
}
/**
* 弹出列表的标题.
*
* @return 返回标题字符串.
*/
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Hyperlink");
}
@Override
protected String getAddItemText() {
return Toolkit.i18nText("Fine-Design_Basic_Add_Hyperlink");
}
//邮箱
public static class NewChartEmailPane extends ChartEmailPane {
@Override
protected boolean needRenamePane() {
return false;
}
}
}

12
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -19,15 +19,15 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* 图表 属性表, 类型选择 界面.
@ -124,7 +124,8 @@ public class ChartTypePane extends AbstractChartAttrPane{
String lastPlotID = chart.getID();
try{
ChartProvider newDefaultChart = (ChartProvider) ((AbstractChartTypePane) getSelectedPane()).getDefaultChart().clone();
AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane();
ChartProvider newDefaultChart =(ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone();
if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) {
//vanChart 和 chart 之间切换
//不同chart之间切换
@ -135,7 +136,6 @@ public class ChartTypePane extends AbstractChartAttrPane{
}catch (CloneNotSupportedException e){
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
//这一步会替换plot
((AbstractChartTypePane)getSelectedPane()).updateBean(chart);

36
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java

@ -1,9 +1,13 @@
package com.fr.design.mainframe.chart.gui.style.series;
import java.util.Timer;
import java.util.TimerTask;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.module.ModuleContext;
import com.fr.value.ClearableLazyValue;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created with IntelliJ IDEA.
@ -13,28 +17,34 @@ import com.fr.design.gui.itextfield.UINumberField;
* To change this template use File | Settings | File Templates.
*/
public class ColorPickerPaneNumFiled extends UINumberField {
private Timer timer;
private ClearableLazyValue<ScheduledExecutorService> ses = new ClearableLazyValue<ScheduledExecutorService>() {
@NotNull
@Override
protected ScheduledExecutorService compute() {
return ModuleContext.getExecutor()
.newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange"));
}
};
public ColorPickerPaneNumFiled() {
super();
}
@Override
protected void attributeChange() {
if(timer != null){
timer.cancel();
}
timer = new Timer();
timer.schedule(new TimerTask() {
ses.getValue().schedule(new Runnable() {
@Override
public void run() {
// kuns: 默认修改500, 在地图修改系列颜色text时, 快速响应.
runChange();
}
},500);// kuns: 默认修改500, 在地图修改系列颜色text时, 快速响应.
}, 500, TimeUnit.MILLISECONDS);
}
protected void runChange(){
protected void runChange() {
super.attributeChange();
timer.cancel();
ses.getValue().shutdown();
ses.drop();
}

2
designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java

@ -67,7 +67,7 @@ public class ExtendedTypePane<T extends AbstractChart> extends AbstractChartType
@Override
public ChartProvider getDefaultChart() {
return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0];
return ChartTypeManager.getInstance().getCharts(getPlotID())[0];
}
@Override

7
designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java

@ -38,6 +38,13 @@ public class HeatMapIndependentVanChartInterface extends MapIndependentVanChartI
return Toolkit.i18nText("Fine-Design_Chart_New_HeatMap");
}
@Override
public String[] getSubName() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_New_HeatMap"),
};
}
@Override
public String[] getDemoImagePath() {
return new String[]{

3
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java

@ -92,6 +92,9 @@ public class XCardAddButton extends XButton {
if(cardLayout == null && tagLayout ==null ){
initRelateLayout();
}
if (cardLayout == null) {
throw new IllegalArgumentException("cardLayout can not be null");
}
int index = cardLayout.toData().getWidgetCount();
//添加新的tab,并将原来的设为未选中状态

12
designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java

@ -126,11 +126,13 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
int titleH = title==null ? 0 : WTitleLayout.TITLE_HEIGHT;
for (int i=0; i< target.getComponentCount(); i++) {
Component comp = target.getComponent(i);
if (comp == title) {
comp.setBounds(0, 0, width, WTitleLayout.TITLE_HEIGHT);
} else if (comp == body) {
int y = titleH+gap;
comp.setBounds(0, y, width, height-y);
if (comp != null) {
if (comp == title) {
comp.setBounds(0, 0, width, WTitleLayout.TITLE_HEIGHT);
} else if (comp == body) {
int y = titleH + gap;
comp.setBounds(0, y, width, height-y);
}
}
}
}

2
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -573,8 +573,8 @@ public class EditingMouseListener extends MouseInputAdapter {
GUICoreUtils.showPopupMenu(cellPopupMenu, designer, e.getX(), e.getY());
}
}
creator.doLayout();
}
creator.doLayout();
LayoutUtils.layoutRootContainer(designer.getRootComponent());
}

644
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -30,6 +30,7 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.sun.management.OperatingSystemMXBean;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
@ -43,11 +44,14 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.lang.management.ManagementFactory;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@ -58,309 +62,339 @@ import java.util.concurrent.TimeUnit;
*/
public class InformationCollector implements XMLReadable, XMLWriter {
// 24小时上传一次
private static final long DELTA = 24 * 3600 * 1000L;
private static final long SEND_DELAY = 300 * 1000L;
private static final String FILE_NAME = "fr.info";
private static final String XML_START_STOP_LIST = "StartStopList";
private static final String XML_START_STOP = "StartStop";
private static final String XML_LAST_TIME = "LastTime";
private static final String ATTR_START = "start";
private static final String ATTR_STOP = "stop";
private static final String XML_JAR = "JarInfo";
private static final String XML_VERSION = "Version";
private static final String XML_USERNAME = "Username";
private static final String XML_UUID = "UUID";
private static final String XML_KEY = "ActiveKey";
private static final String XML_OS = "OS";
private static InformationCollector collector;
//启动时间与关闭时间列表
private List<StartStopTime> startStop = new ArrayList<StartStopTime>();
//上一次的发送时间
private String lastTime;
private StartStopTime current = new StartStopTime();
public static InformationCollector getInstance() {
if (collector == null) {
collector = new InformationCollector();
readEncodeXMLFile(collector, collector.getInfoFile());
}
return collector;
}
private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) {
if (xmlFile == null || !xmlFile.exists()) {
return;
}
String charset = EncodeConstants.ENCODING_UTF_8;
try {
String decodeContent = getDecodeFileContent(xmlFile);
InputStream xmlInputStream = new ByteArrayInputStream(decodeContent.getBytes(charset));
InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset);
XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader);
if (xmlReader != null) {
xmlReader.readXMLObject(xmlReadable);
}
xmlInputStream.close();
} catch (FileNotFoundException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException {
InputStream encodeInputStream = new FileInputStream(xmlFile);
String encodeContent = IOUtils.inputStream2String(encodeInputStream);
return DesUtils.getDecString(encodeContent);
}
private long getLastTimeMillis() {
if (StringUtils.isEmpty(this.lastTime)) {
return 0;
}
try {
return DateUtils.string2Date(this.lastTime, true).getTime();
} catch (Exception e) {
return -1;
}
}
private JSONObject getJSONContentAsByte() {
JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray();
for (int i = 0; i < startStop.size(); i++) {
JSONObject jo = new JSONObject();
jo.put(ATTR_START, startStop.get(i).getStartDate());
jo.put(ATTR_STOP, startStop.get(i).getStopDate());
startStopArray.put(jo);
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
content.put(XML_START_STOP, startStopArray);
content.put(XML_UUID, envManager.getUUID());
content.put(XML_JAR, GeneralUtils.readBuildNO());
content.put(XML_VERSION, ProductConstants.RELEASE_VERSION);
content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername());
content.put(XML_KEY, envManager.getActivationKey());
content.put(XML_OS, System.getProperty("os.name"));
}
return content;
}
private void sendUserInfo() {
long currentTime = new Date().getTime();
long lastTime = getLastTimeMillis();
if (currentTime - lastTime <= DELTA) {
return;
}
JSONObject content = getJSONContentAsByte();
String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10");
boolean success = false;
try {
HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", content);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (success) {
this.reset();
}
}
/**
* 收集开始使用时间发送信息
*/
public void collectStartTime() {
this.current.setStartDate(dateToString());
sendUserInfoInOtherThread();
}
private void sendUserInfoInOtherThread() {
if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) {
return;
}
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector"));
service.schedule(new Runnable() {
@Override
public void run() {
sendUserInfo();
FocusPointMessageUploader.getInstance().sendToCloudCenter();
TemplateInfoCollector.getInstance().sendTemplateInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
}
}, SEND_DELAY, TimeUnit.MILLISECONDS);
}
/**
* 收集结束使用时间
*/
public void collectStopTime() {
this.current.setStopDate(dateToString());
}
private String dateToString() {
DateFormat df = FRContext.getDefaultValues().getDateTimeFormat();
return df.format(new Date());
}
private void reset() {
this.startStop.clear();
this.lastTime = dateToString();
}
private File getInfoFile() {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME));
}
/**
* 保存xml文件
*/
public void saveXMLFile() {
File xmlFile = this.getInfoFile();
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_UTF_8);
String encodeCotent = DesUtils.getEncString(fileContent);
writeEncodeContentToFile(encodeCotent, xmlFile);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 将文件内容写到输出流中
*/
private static void writeEncodeContentToFile(String fileContent, File file) {
try (FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8);
BufferedWriter bw = new BufferedWriter(osw)) {
bw.write(fileContent);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
startStop.add(current);
writer.startTAG("Info");
//启停信息
writeStartStopList(writer);
//上一次更新的时间
writeTag(XML_LAST_TIME, this.lastTime, writer);
writer.end();
}
private void writeStartStopList(XMLPrintWriter writer) {
//启停
writer.startTAG(XML_START_STOP_LIST);
for (int i = 0; i < startStop.size(); i++) {
startStop.get(i).writeXML(writer);
}
writer.end();
}
private void writeTag(String tag, String content, XMLPrintWriter writer) {
if (StringUtils.isEmpty(content)) {
return;
}
writer.startTAG(tag);
writer.textNode(content);
writer.end();
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String name = reader.getTagName();
if (XML_START_STOP_LIST.equals(name)) {
readStartStopList(reader);
} else if (XML_LAST_TIME.equals(name)) {
readLastTime(reader);
}
}
}
private void readLastTime(XMLableReader reader) {
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastTime = tmpVal;
}
}
private void readStartStopList(XMLableReader reader) {
startStop.clear();
reader.readXMLObject(new XMLReadable() {
public void readXML(XMLableReader reader) {
if (XML_START_STOP.equals(reader.getTagName())) {
StartStopTime startStopTime = new StartStopTime();
reader.readXMLObject(startStopTime);
startStop.add(startStopTime);
}
}
});
}
private class StartStopTime implements XMLReadable, XMLWriter {
private String startDate;
private String stopDate;
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getStopDate() {
return stopDate;
}
public void setStopDate(String endDate) {
this.stopDate = endDate;
}
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_START_STOP);
if (StringUtils.isNotEmpty(startDate)) {
writer.attr(ATTR_START, this.startDate);
}
if (StringUtils.isNotEmpty(stopDate)) {
writer.attr(ATTR_STOP, this.stopDate);
}
writer.end();
}
public void readXML(XMLableReader reader) {
this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY);
this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY);
}
}
/**
* 24小时上传一次
*/
private static final long DELTA = 24 * 3600 * 1000L;
private static final long SEND_DELAY = 300 * 1000L;
private static final int BYTE_TO_MB = 1024 * 1024;
private static final String FILE_NAME = "fr.info";
private static final String XML_START_STOP_LIST = "StartStopList";
private static final String XML_START_STOP = "StartStop";
private static final String XML_LAST_TIME = "LastTime";
private static final String ATTR_START = "start";
private static final String ATTR_STOP = "stop";
private static final String XML_JAR = "JarInfo";
private static final String XML_VERSION = "Version";
private static final String XML_USERNAME = "Username";
private static final String XML_UUID = "UUID";
private static final String XML_KEY = "ActiveKey";
private static final String XML_OS = "OS";
private static final String XML_ARCH = "arch";
private static final String XML_AVAILABLE_PROCESSORS = "cpu";
private static final String XML_PHYSICAL_MEMORY = "systemMemory";
private static InformationCollector collector;
/**
* 启动时间与关闭时间列表
*/
private List<StartStopTime> startStop = new ArrayList<StartStopTime>();
/**
* 上一次的发送时间
*/
private String lastTime;
private StartStopTime current = new StartStopTime();
public static InformationCollector getInstance() {
if (collector == null) {
collector = new InformationCollector();
readEncodeXMLFile(collector, collector.getInfoFile());
}
return collector;
}
private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) {
if (xmlFile == null || !xmlFile.exists()) {
return;
}
String charset = EncodeConstants.ENCODING_UTF_8;
try {
String decodeContent = getDecodeFileContent(xmlFile);
InputStream xmlInputStream = new ByteArrayInputStream(decodeContent.getBytes(charset));
InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset);
XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader);
if (xmlReader != null) {
xmlReader.readXMLObject(xmlReadable);
}
xmlInputStream.close();
} catch (FileNotFoundException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException {
InputStream encodeInputStream = new FileInputStream(xmlFile);
String encodeContent = IOUtils.inputStream2String(encodeInputStream);
return DesUtils.getDecString(encodeContent);
}
private long getLastTimeMillis() {
if (StringUtils.isEmpty(this.lastTime)) {
return 0;
}
try {
return Objects.requireNonNull(DateUtils.string2Date(this.lastTime, true)).getTime();
} catch (Exception e) {
return -1;
}
}
private JSONObject getJSONContentAsByte() {
JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray();
for (StartStopTime startStopTime : startStop) {
JSONObject jo = new JSONObject();
jo.put(ATTR_START, startStopTime.getStartDate());
jo.put(ATTR_STOP, startStopTime.getStopDate());
startStopArray.put(jo);
}
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
content.put(XML_START_STOP, startStopArray);
content.put(XML_UUID, envManager.getUUID());
content.put(XML_JAR, GeneralUtils.readBuildNO());
content.put(XML_VERSION, ProductConstants.RELEASE_VERSION);
content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername());
content.put(XML_KEY, envManager.getActivationKey());
content.put(XML_OS, System.getProperty("os.name"));
content.put(XML_ARCH, System.getProperty("os.arch"));
content.put(XML_AVAILABLE_PROCESSORS, Runtime.getRuntime().availableProcessors());
content.put(XML_PHYSICAL_MEMORY, getTotalPhysicalMemorySize());
return content;
}
/**
* 获取物理内存单位GB
*
* @return 物理内存
*/
private static long getTotalPhysicalMemorySize() {
OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
return bean.getTotalPhysicalMemorySize() / BYTE_TO_MB;
}
private void sendUserInfo() {
long currentTime = System.currentTimeMillis();
long lastTime = getLastTimeMillis();
if (currentTime - lastTime <= DELTA) {
return;
}
JSONObject content = getJSONContentAsByte();
String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10");
boolean success = false;
try {
HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", content);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (success) {
this.reset();
}
}
/**
* 收集开始使用时间发送信息
*/
public void collectStartTime() {
this.current.setStartDate(dateToString());
sendUserInfoInOtherThread();
}
private void sendUserInfoInOtherThread() {
if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) {
return;
}
ScheduledExecutorService service = Executors
.newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector"));
service.schedule(new Runnable() {
@Override
public void run() {
sendUserInfo();
FocusPointMessageUploader.getInstance().sendToCloudCenter();
TemplateInfoCollector.getInstance().sendTemplateInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
}
}, SEND_DELAY, TimeUnit.MILLISECONDS);
service.shutdown();
}
/**
* 收集结束使用时间
*/
public void collectStopTime() {
this.current.setStopDate(dateToString());
}
private String dateToString() {
DateFormat df = FRContext.getDefaultValues().getDateTimeFormat();
return df.format(new Date());
}
private void reset() {
this.startStop.clear();
this.lastTime = dateToString();
}
private File getInfoFile() {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME));
}
/**
* 保存xml文件
*/
public void saveXMLFile() {
File xmlFile = this.getInfoFile();
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
String encodeCotent = DesUtils.getEncString(fileContent);
writeEncodeContentToFile(encodeCotent, xmlFile);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 将文件内容写到输出流中
*/
private static void writeEncodeContentToFile(String fileContent, File file) {
try (FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
BufferedWriter bw = new BufferedWriter(osw)) {
bw.write(fileContent);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
startStop.add(current);
writer.startTAG("Info");
//启停信息
writeStartStopList(writer);
//上一次更新的时间
writeTag(XML_LAST_TIME, this.lastTime, writer);
writer.end();
}
private void writeStartStopList(XMLPrintWriter writer) {
//启停
writer.startTAG(XML_START_STOP_LIST);
for (StartStopTime startStopTime : startStop) {
startStopTime.writeXML(writer);
}
writer.end();
}
private void writeTag(String tag, String content, XMLPrintWriter writer) {
if (StringUtils.isEmpty(content)) {
return;
}
writer.startTAG(tag);
writer.textNode(content);
writer.end();
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String name = reader.getTagName();
if (XML_START_STOP_LIST.equals(name)) {
readStartStopList(reader);
} else if (XML_LAST_TIME.equals(name)) {
readLastTime(reader);
}
}
}
private void readLastTime(XMLableReader reader) {
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastTime = tmpVal;
}
}
private void readStartStopList(XMLableReader reader) {
startStop.clear();
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader reader) {
if (XML_START_STOP.equals(reader.getTagName())) {
StartStopTime startStopTime = new StartStopTime();
reader.readXMLObject(startStopTime);
startStop.add(startStopTime);
}
}
});
}
private class StartStopTime implements XMLReadable, XMLWriter {
private String startDate;
private String stopDate;
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getStopDate() {
return stopDate;
}
public void setStopDate(String endDate) {
this.stopDate = endDate;
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_START_STOP);
if (StringUtils.isNotEmpty(startDate)) {
writer.attr(ATTR_START, this.startDate);
}
if (StringUtils.isNotEmpty(stopDate)) {
writer.attr(ATTR_STOP, this.stopDate);
}
writer.end();
}
@Override
public void readXML(XMLableReader reader) {
this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY);
this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY);
}
}
}

9
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java

@ -8,6 +8,7 @@ import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
@ -30,14 +31,15 @@ public class StartupMessageCollector {
private static final String XML_STARTUP_TIME = "t";
private static final String XML_STARTUP_LOG = "startupLog";
private static final String XML_STARTUP_Memory = "designerMemory";
private static final String XML_STARTUP_MEMORY = "designerMemory";
private static final String XML_STARTUP_COST = "cost";
private static final String XML_UUID = "UUID";
private static final String XML_BUILD_NO = "buildNO";
private static final String STARTUP_URL_KEY = "user.info.v10.startup";
private static final String LOG_TYPE = "single";
private static final int BYTE_TO_MB = 1024 * 1024;
public static final StartupMessageCollector INSTANCE = new StartupMessageCollector();
private static final StartupMessageCollector INSTANCE = new StartupMessageCollector();
private StartupMessageCollector() {
}
@ -67,10 +69,11 @@ public class StartupMessageCollector {
}
JSONObject json = JSONObject.create()
.put(XML_UUID, DesignerEnvManager.getEnvManager().getUUID())
.put(XML_BUILD_NO, GeneralUtils.readBuildNO())
.put(XML_STARTUP_TIME, FineRuntime.getAppStartTime() + FineRuntime.getStartingTime())
.put(XML_STARTUP_COST, FineRuntime.getStartingTime())
.put(XML_STARTUP_LOG, profile)
.put(XML_STARTUP_Memory, Runtime.getRuntime().totalMemory() / BYTE_TO_MB);
.put(XML_STARTUP_MEMORY, Runtime.getRuntime().maxMemory() / BYTE_TO_MB);
sendInfo(json, url + LOG_TYPE);
}
});

3
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -8,6 +8,7 @@ import com.fr.base.passport.FinePassportManager;
import com.fr.base.process.ProcessOperator;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.config.MarketConfig;
import com.fr.decision.update.backup.RecoverManager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.NewFormAction;
@ -57,6 +58,7 @@ import com.fr.design.module.DesignModuleFactory;
import com.fr.design.parameter.FormParameterReader;
import com.fr.design.parameter.ParameterPropertyPane;
import com.fr.design.parameter.WorkBookParameterReader;
import com.fr.design.update.actions.RecoverForDesigner;
import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane;
import com.fr.form.stable.ElementCaseThumbnailProcessor;
import com.fr.general.xml.GeneralXMLTools;
@ -128,6 +130,7 @@ public class DesignerActivator extends Activator {
UserInfoPane.getInstance().updateBBSUserInfo();
storePassport();
AlphaFineHelper.switchConfig4Locale();
RecoverManager.register(new RecoverForDesigner());
}
@Override

Loading…
Cancel
Save