Browse Source

Merge remote-tracking branch 'origin/feature/10.0' into feature/10.0

persist/11.0
Maksim 5 years ago
parent
commit
ec79d994a5
  1. 79
      designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java
  2. 56
      designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java
  3. 2
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java
  4. 40
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java
  5. 55
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  6. 23
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  7. 93
      designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java
  8. 19
      designer-base/src/main/java/com/fr/design/utils/ImageUtils.java
  9. 13
      designer-base/src/main/java/com/fr/design/web/CustomIconPane.java
  10. 207
      designer-chart/src/main/java/com/fr/design/chartx/component/HyperLinkPane.java
  11. 3
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  12. 12
      designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java
  13. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  14. 3
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

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");
}
}
}

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

@ -1,56 +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 DESIGNER_BACKUP_DIR = "designerbackup";
String UPDATE_CACHE_CONFIG_X = "updateCacheConfig10";
String UPDATE_CACHE_INFO_X = "updateCacheInfo10";
String JXBROWSER = "jxbrowser";
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;

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

@ -1,16 +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;
@ -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"))) {
@ -100,7 +100,7 @@ public class RestoreResultDialog extends JDialog {
this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore"));
}
public static boolean deletePreviousPropertyFile() {
static boolean deletePreviousPropertyFile() {
File moveFile = new File(RestartHelper.MOVE_FILE);
File delFile = new File(RestartHelper.RECORD_FILE);
if (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) {
@ -159,7 +159,7 @@ public class RestoreResultDialog extends JDialog {
private void putJarBackupFiles() {
Map<String, String> map = new HashMap<>();
java.util.List<String> list = new ArrayList<>();
List<String> list = new ArrayList<>();
String installHome = StableUtils.getInstallHome();
putJarBackupFilesToInstallLib(installHome, map, list);
@ -168,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()));
}
}
}
}

55
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;
@ -14,7 +15,6 @@ 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;
@ -29,12 +29,7 @@ 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.project.ProjectConstants;
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;
@ -431,6 +426,7 @@ public class UpdateMainDialog extends UIDialog {
private void afterInit() {
if (autoUpdateAfterInit) {
updateButton.setEnabled(true);
updateButton.doClick();
}
}
@ -588,7 +584,6 @@ public class UpdateMainDialog extends UIDialog {
updateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
backup();
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);
@ -599,14 +594,15 @@ public class UpdateMainDialog extends UIDialog {
new FileProcess(callBack) {
@Override
public void onDownloadSuccess() {
updateButton.setEnabled(true);
progressBar.setVisible(false);
deleteForDesignerUpdate();
RestartHelper.restart();
}
@Override
public void onDownloadFailed() {
progressBar.setVisible(false);
JOptionPane.showMessageDialog(getParent(),"Update Failed");
deleteForDesignerUpdate();
JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message"));
RestartHelper.restart();
}
}.execute();
@ -615,40 +611,11 @@ public class UpdateMainDialog extends UIDialog {
});
}
/**
* Jar还原按钮兼容
*/
private void backup() {
String installHome = StableUtils.getInstallHome();
//jar包备份文件的目录为"backup/"+jar包当前版本号
String todayBackupDir = StableUtils.pathJoin(installHome, getBackupDirectory(), (GeneralUtils.readBuildNO()));
backupFilesFromInstallEnv(installHome, todayBackupDir);
backupFilesFromInstallLib(installHome, todayBackupDir);
jarCurrentLabel.setText(downloadFileConfig.optString("buildNO"));
}
private void backupFilesFromInstallEnv(String installHome, String todayBackupDir) {
for (String file : UpdateConstants.JARS_FOR_SERVER_X) {
try {
IOUtils.copy(
new File(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)),
new File(StableUtils.pathJoin(todayBackupDir)));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
}
private void backupFilesFromInstallLib(String installHome, String todayBackupDir) {
for (String file : UpdateConstants.JARS_FOR_DESIGNER_X) {
try {
IOUtils.copy(
new File(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)),
new File(StableUtils.pathJoin(todayBackupDir)));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
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);
}
//获取备份目录

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() {

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

@ -1,26 +1,16 @@
package com.fr.design.upm;
import com.fr.design.dialog.BasicPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.ModernUIPane;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.design.upm.event.DownloadEvent;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileNotFoundException;
/**
* @author richie
@ -39,61 +29,40 @@ public class UpmShowPane extends BasicPane {
UpmShowPane() {
setLayout(new BorderLayout());
boolean flag = false;
File file = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),ProjectConstants.LIB_NAME));
File[] files = file.listFiles();
if (files != null) {
for (File file1 : files) {
if (file1.getName().contains(UpdateConstants.JXBROWSER)) {
flag = true;
break;
if (UpmFinder.checkUPMResourcesExist()) {
modernUIPane = new ModernUIPane.Builder<>()
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
})
.withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap())
.build();
EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
}
}else {
FineLoggerFactory.getLogger().error("Designer lib can not be null");
}
if (flag) {
if (UpmFinder.checkUPMResourcesExist()) {
modernUIPane = new ModernUIPane.Builder<>()
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
})
.withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap())
.build();
EventDispatcher.listen(DownloadEvent.UPDATE, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
});
} else {
modernUIPane = new ModernUIPane.Builder<>()
.withComponent(WarnComponent.KEY)
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
}).build();
EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
});
}
});
} else {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());
dialog.setAutoUpdateAfterInit();
dialog.showDialog();
modernUIPane = new ModernUIPane.Builder<>()
.withComponent(WarnComponent.KEY)
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser()));
}
}).build();
EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener<String>() {
@Override
public void on(Event event, String param) {
modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap());
}
});
}
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));
}

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;
}
}
}

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());
}

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