Browse Source

Merge branch 'release/8.0' into 8.0

# Conflicts:
#	designer_base/src/com/fr/design/locale/designer.properties
#	designer_base/src/com/fr/design/locale/designer_en_US.properties
#	designer_base/src/com/fr/design/locale/designer_ja_JP.properties
#	designer_base/src/com/fr/design/locale/designer_ko_KR.properties
#	designer_base/src/com/fr/design/locale/designer_zh_CN.properties
#	designer_base/src/com/fr/design/locale/designer_zh_TW.properties
paul 8 years ago
parent
commit
1b67e7cff9
  1. 68
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  2. 202
      designer/src/com/fr/start/Designer.java
  3. 46
      designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java
  4. 1
      designer_base/src/com/fr/design/dialog/InformationWarnPane.java
  5. 54
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  6. 6
      designer_base/src/com/fr/design/extra/ShopManagerPane.java
  7. 54
      designer_base/src/com/fr/design/extra/WebViewDlgHelper.java
  8. 4
      designer_base/src/com/fr/design/locale/designer.properties
  9. 4
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  10. 4
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  11. 4
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  12. 4
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  13. 4
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  14. 178
      designer_base/src/com/fr/design/utils/concurrent/ThreadFactoryBuilder.java
  15. 141
      designer_base/src/com/fr/design/write/submit/CustomJobPane.java
  16. 1
      designer_base/src/com/fr/env/EnvListPane.java
  17. 42
      designer_base/src/com/fr/start/Demo.java
  18. 7
      designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java
  19. 35
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  20. 6
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java
  21. 2
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java
  22. 117
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

68
designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java

@ -5,11 +5,16 @@ package com.fr.design.mainframe.bbs;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.*;
import com.fr.design.extra.LoginContextListener;
import com.fr.design.extra.LoginWebBridge;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.UserLoginContext;
import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils;
@ -21,15 +26,22 @@ import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.SwingConstants;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Frame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author neil
@ -37,6 +49,7 @@ import java.util.Date;
*/
public class UserInfoLabel extends UILabel {
private static final int JRE_VERSION_8 = 8;
//默认查询消息时间, 30s
private static final long CHECK_MESSAGE_TIME = 30 * 1000L;
//默认论坛检测到更新后的弹出延迟时间
@ -73,6 +86,10 @@ public class UserInfoLabel extends UILabel {
}
public UserInfoLabel(UserInfoPane userInfoPane) {
init(userInfoPane);
}
private void init(UserInfoPane userInfoPane) {
this.userInfoPane = userInfoPane;
String userName = DesignerEnvManager.getEnvManager().getBBSName();
@ -83,22 +100,7 @@ public class UserInfoLabel extends UILabel {
LoginWebBridge loginWebBridge = new LoginWebBridge();
loginWebBridge.setUserName(userName, UserInfoLabel.this);
LoginCheckContext.addLoginCheckListener(new LoginCheckListener() {
@Override
public void loginChecked() {
/*
if (bbsLoginDialog == null) {
bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(), UserInfoLabel.this);
}
bbsLoginDialog.clearLoginInformation();
bbsLoginDialog.showTipForDownloadPluginWithoutLogin();
bbsLoginDialog.setModal(true);
bbsLoginDialog.showWindow();
*/
}
});
if (StableUtils.getMajorJavaVersion() == 8) {
if (StableUtils.getMajorJavaVersion() == JRE_VERSION_8) {
PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
}
LoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this);
@ -125,12 +127,13 @@ public class UserInfoLabel extends UILabel {
userInfoPane.markUnSignIn();
}
/**
* showBBSDialog 弹出BBS资讯框
*/
public static void showBBSDialog() {
Thread showBBSThread = new Thread(new Runnable() {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1),
new ThreadFactoryBuilder().setNameFormat("bbs-dlg-thread-%s").build());
threadPoolExecutor.execute(new Runnable() {
@Override
public void run() {
// vito:最新mac10.12和javafx弹出框初始化时会有大几率卡死在native方法,这里先屏蔽一下。
@ -152,18 +155,22 @@ public class UserInfoLabel extends UILabel {
return;
}
String res = hc.getResponseText();
if (res.indexOf(BBSConstants.UPDATE_KEY) == -1) {
if (!res.contains(BBSConstants.UPDATE_KEY)) {
return;
}
try {
BBSDialog bbsLabel = new BBSDialog(DesignerContext.getDesignerFrame());
bbsLabel.showWindow(SiteCenter.getInstance().acquireUrlByKind("bbs.popup"));
Class<?> clazz = Class.forName("com.fr.design.mainframe.bbs.BBSDialog");
Constructor constructor = clazz.getConstructor(Frame.class);
Object instance = constructor.newInstance(DesignerContext.getDesignerFrame());
Method showWindow = clazz.getMethod("showWindow", String.class);
showWindow.invoke(instance, SiteCenter.getInstance().acquireUrlByKind("bbs.popup"));
DesignerEnvManager.getEnvManager().setLastShowBBSNewsTime(DateUtils.DATEFORMAT2.format(new Date()));
} catch (Throwable e) {
} catch (Throwable ignored) {
// ignored
}
}
});
showBBSThread.start();
}
private void sleep(long millis) {
@ -230,6 +237,7 @@ public class UserInfoLabel extends UILabel {
private MouseAdapter userInfoAdapter = new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
UserInfoLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
@ -245,6 +253,7 @@ public class UserInfoLabel extends UILabel {
//私人消息
UIMenuItem priviteMessage = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Privite-Message"));
priviteMessage.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (StringUtils.isNotEmpty(userName)) {
try {
@ -261,6 +270,7 @@ public class UserInfoLabel extends UILabel {
//切换账号
UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account"));
closeOther.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
UserLoginContext.fireLoginContextListener();
}

202
designer/src/com/fr/start/Designer.java

@ -20,7 +20,12 @@ import com.fr.design.gui.ibutton.UIPreviewButton;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.ActiveKeyGenerator;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.bbs.UserInfoLabel;
import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -30,6 +35,7 @@ import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.module.DesignerModule;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
@ -38,29 +44,36 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLTools;
import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import java.awt.*;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class Designer extends BaseDesigner {
private static final int TOOLBARPANEVGAP = -4;
private static final int PREVIEW_DOWN_X_GAP = 92;
private static final int GAP = 7;
private static final String OLD_ENV_FOLDER_71 = ".FineReport71";
private static final String OLD_ENV_FOLDER_70 = ".FineReport70";
private UserInfoPane userInfoPane;
private UIButton saveButton;
private UIButton undo;
private UIButton redo;
private UIPreviewButton run;
/**
* 设计器启动的Main方法
@ -132,6 +145,7 @@ public class Designer extends BaseDesigner {
UILargeToolbar largeToolbar = super.createLargeToolbar();
largeToolbar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 4));
largeToolbar.add(new JPanel() {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = 1;
@ -141,6 +155,7 @@ public class Designer extends BaseDesigner {
createRunButton(largeToolbar);
largeToolbar.add(run);
largeToolbar.add(new JPanel() {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = GAP;
@ -154,8 +169,10 @@ public class Designer extends BaseDesigner {
/**
* 创建上面一排的工具栏按钮
*
* @return 按钮
*/
@Override
public UIButton[] createUp() {
return new UIButton[]{createSaveButton(), createUndoButton(), createRedoButton()};
}
@ -176,7 +193,7 @@ public class Designer extends BaseDesigner {
});
return saveButton;
}
private UIButton createUndoButton() {
undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png"));
undo.setToolTipText(KeySetUtils.UNDO.getMenuKeySetName());
@ -211,10 +228,12 @@ public class Designer extends BaseDesigner {
private void createRunButton(UILargeToolbar largeToolbar) {
run = new UIPreviewButton(new UIButton(UIConstants.PAGE_BIG_ICON) {
@Override
public Dimension getPreferredSize() {
return new Dimension(34, 34);
}
}, new UIButton(UIConstants.PREVIEW_DOWN) {
@Override
public Dimension getPreferredSize() {
return new Dimension(34, 10);
}
@ -284,10 +303,12 @@ public class Designer extends BaseDesigner {
/**
* 生成工具栏
*
* @param toolbarComponent 工具栏
* @param plus 对象
* @return 更新后的toolbar
* @return 更新后的toolbar
*/
@Override
public JComponent resetToolBar(JComponent toolbarComponent, ToolBarMenuDockPlus plus) {
//如果是处于权限编辑状态
if (BaseUtils.isAuthorityEditing()) {
@ -325,85 +346,90 @@ public class Designer extends BaseDesigner {
public JTemplate<?, ?> createNewTemplate() {
return new JWorkBook();
}
/**
* 创建论坛登录面板, chart那边不需要
*
* @return 面板组件
*
*/
public Component createBBSLoginPane(){
if (userInfoPane == null){
userInfoPane = new UserInfoPane();
* 创建论坛登录面板, chart那边不需要
*
* @return 面板组件
*/
@Override
public Component createBBSLoginPane() {
if (userInfoPane == null) {
userInfoPane = new UserInfoPane();
}
return userInfoPane;
}
@Override
protected SplashPane createSplashPane() {
return new ReportSplashPane();
}
/**
* 收集用户信息吗
*
*/
* 收集用户信息吗
*/
@Override
protected void collectUserInformation() {
//定制的就不弹出来了
if (!ComparatorUtils.equals(ProductConstants.APP_NAME, ProductConstants.DEFAULT_APPNAME)) {
return;
}
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
final String key = envManager.getActivationKey();
//本地验证通过
if(ActiveKeyGenerator.localVerify(key)){
onLineVerify(envManager, key);
UserInfoLabel.showBBSDialog();
return;
}
if(StableUtils.checkDesignerActive(readOldKey())){
//只要有老的key, 就不弹窗, 下次启动的时候, 在线验证下就行.
String newKey = ActiveKeyGenerator.generateActiveKey();
envManager.setActivationKey(newKey);
UserInfoLabel.showBBSDialog();
return;
}
//定制的就不弹出来了
if (!ComparatorUtils.equals(ProductConstants.APP_NAME, ProductConstants.DEFAULT_APPNAME)) {
return;
}
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
final String key = envManager.getActivationKey();
//本地验证通过
if (ActiveKeyGenerator.localVerify(key)) {
onLineVerify(envManager, key);
UserInfoLabel.showBBSDialog();
return;
}
if (StableUtils.checkDesignerActive(readOldKey())) {
//只要有老的key, 就不弹窗, 下次启动的时候, 在线验证下就行.
String newKey = ActiveKeyGenerator.generateActiveKey();
envManager.setActivationKey(newKey);
UserInfoLabel.showBBSDialog();
return;
}
CollectUserInformationDialog activeDialog = new CollectUserInformationDialog(
DesignerContext.getDesignerFrame());
DesignerContext.getDesignerFrame());
activeDialog.setVisible(true);
}
private void onLineVerify(DesignerEnvManager envManager, final String key){
int status = envManager.getActiveKeyStatus();
//没有联网验证过
if (status != 0) {
Thread authThread = new Thread(new Runnable() {
@Override
public void run() {
ActiveKeyGenerator.onLineVerify(key);
}
});
authThread.start();
}
private void onLineVerify(DesignerEnvManager envManager, final String key) {
int status = envManager.getActiveKeyStatus();
//没有联网验证过
if (status != 0) {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1),
new ThreadFactoryBuilder().setNameFormat("net-verify-thread-%s").build());
threadPoolExecutor.execute(new Runnable() {
@Override
public void run() {
ActiveKeyGenerator.onLineVerify(key);
}
});
}
}
private File getOldEnvFile(String folderName){
String userHome = System.getProperty("user.home");
if (userHome == null) {
userHome = System.getProperty("userHome");
}
String filePath = StableUtils.pathJoin(userHome, folderName, ProductConstants.APP_NAME + "Env.xml");
private File getOldEnvFile(String folderName) {
String userHome = System.getProperty("user.home");
if (userHome == null) {
userHome = System.getProperty("userHome");
}
String filePath = StableUtils.pathJoin(userHome, folderName, ProductConstants.APP_NAME + "Env.xml");
return new File(filePath);
}
private String getOldActiveKeyFromFile(File envFile){
private String getOldActiveKeyFromFile(File envFile) {
if (!envFile.exists()) {
return StringUtils.EMPTY;
}
return StringUtils.EMPTY;
}
DesignerEnvManager temp = new DesignerEnvManager();
try {
XMLTools.readFileXML(temp, envFile);
@ -412,26 +438,26 @@ public class Designer extends BaseDesigner {
}
return temp.getActivationKey();
}
//默认只从7.0和711的设计器里读取key
private String readOldKey(){
File file71 = getOldEnvFile(OLD_ENV_FOLDER_71);
if (!file71.exists()) {
File file70 = getOldEnvFile(OLD_ENV_FOLDER_70);
return getOldActiveKeyFromFile(file70);
}
return getOldActiveKeyFromFile(file71);
private String readOldKey() {
File file71 = getOldEnvFile(OLD_ENV_FOLDER_71);
if (!file71.exists()) {
File file70 = getOldEnvFile(OLD_ENV_FOLDER_70);
return getOldActiveKeyFromFile(file70);
}
return getOldActiveKeyFromFile(file71);
}
/**
* 设计器退出时, 做的一些操作.
*
*/
public void shutDown(){
InformationCollector collector = InformationCollector.getInstance();
collector.collectStopTime();
collector.saveXMLFile();
* 设计器退出时, 做的一些操作.
*/
@Override
public void shutDown() {
InformationCollector collector = InformationCollector.getInstance();
collector.collectStopTime();
collector.saveXMLFile();
Env currentEnv = FRContext.getCurrentEnv();
currentEnv.doWhenServerShutDown();
}

46
designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java

@ -3,6 +3,7 @@ package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.impl.TableDataSourceDependent;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
@ -45,6 +46,7 @@ import java.util.Map;
public class TableDataTreePane extends BasicTableDataTreePane {
private static TableDataTreePane singleton = new TableDataTreePane();
private static final int TIP_DISMISS_DELAY = 3000;
public synchronized static BasicTableDataTreePane getInstance(DesignModelAdapter<?, ?> tc) {
@ -71,25 +73,21 @@ public class TableDataTreePane extends BasicTableDataTreePane {
private PreviewTableDataAction previewTableDataAction;
private TableDataTreePane() {
init();
}
private void init() {
this.setLayout(new BorderLayout(4, 0));
this.setBorder(null);
dataTree = new TableDataTree();
ToolTipManager.sharedInstance().registerComponent(dataTree);
ToolTipManager.sharedInstance().setDismissDelay(3000);
ToolTipManager.sharedInstance().setDismissDelay(TIP_DISMISS_DELAY);
ToolTipManager.sharedInstance().setInitialDelay(0);
addMenuDef = new MenuDef(Inter.getLocText("FR-Action_Add"));
addMenuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH);
createAddMenuDef();
GeneralContext.addPluginReadListener(new PluginReadListener() {
@Override
public void success(Status status) {
addMenuDef.clearShortCuts();
createAddMenuDef();
}
});
editAction = new EditAction();
removeAction = new RemoveAction();
previewTableDataAction = new PreviewTableDataAction(dataTree);
@ -112,13 +110,9 @@ public class TableDataTreePane extends BasicTableDataTreePane {
jPanel.add(buttonPane, BorderLayout.NORTH);
jPanel.add(scrollPane, BorderLayout.CENTER);
this.add(jPanel, BorderLayout.CENTER);
dataTree.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
checkButtonEnabled();
}
});
dataTree.addKeyListener(getTableTreeNodeListener(editAction, previewTableDataAction, removeAction, op, dataTree));
initListeners();
// TreeCellEditor
dataTree.setEditable(true);
TableDataTreeCellEditor treeCellEditor = new TableDataTreeCellEditor(new UITextField(), dataTree, this);
@ -128,6 +122,23 @@ public class TableDataTreePane extends BasicTableDataTreePane {
checkButtonEnabled();
}
private void initListeners() {
GeneralContext.addPluginReadListener(new PluginReadListener() {
@Override
public void success(Status status) {
addMenuDef.clearShortCuts();
createAddMenuDef();
}
});
dataTree.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
checkButtonEnabled();
}
});
dataTree.addKeyListener(getTableTreeNodeListener(editAction, previewTableDataAction, removeAction, op, dataTree));
}
protected void checkButtonEnabled() {
super.checkButtonEnabled(editAction, previewTableDataAction, removeAction, op, dataTree);
@ -187,6 +198,9 @@ public class TableDataTreePane extends BasicTableDataTreePane {
tc.renameTableData(oldName, nPanel.getObjectName(), false);
TableDataSource tds = tc.getBook();
TableData td = uPanel.updateBean();
if (td instanceof TableDataSourceDependent) {
((TableDataSourceDependent) td).setTableDataSource(tds);
}
String tdName = nPanel.getObjectName();
tds.putTableData(tdName, td);
Map<String, String> map = new HashMap<String, String>();

1
designer_base/src/com/fr/design/dialog/InformationWarnPane.java

@ -143,7 +143,6 @@ public class InformationWarnPane extends JPanel{
contentPane.add(InformationWarnPane.this);
contentPane.add(this.createControlButtonPane());
this.setModal(true);
this.pack();
GUICoreUtils.centerWindow(this);
}

54
designer_base/src/com/fr/design/extra/LoginWebBridge.java

@ -6,14 +6,16 @@ import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.ucenter.Client;
import com.fr.design.extra.ucenter.XMLHelper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.ComparatorUtils;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import javafx.scene.web.WebEngine;
import javax.swing.*;
import java.awt.*;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import java.awt.Desktop;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
@ -55,6 +57,10 @@ public class LoginWebBridge {
private String userName;
public LoginWebBridge() {
init();
}
private void init() {
String username = DesignerEnvManager.getEnvManager().getBBSName();
setUserName(username, uiLabel);
}
@ -79,7 +85,7 @@ public class LoginWebBridge {
this.pluginuiLabel = uiLabel;
}
public void setQqDialog(UIDialog qqDialog) {
public void setQQDialog(UIDialog qqDialog) {
closeQQWindow();
this.qqDialog = qqDialog;
}
@ -216,7 +222,7 @@ public class LoginWebBridge {
return NET_FAILED;
}
String loginResult = login(username, password);
if (loginResult.equals(LOGININ)) {
if (ComparatorUtils.equals(loginResult, LOGININ)) {
updateUserInfo(username);
loginSuccess(username, uiLabel);
setUserName(username, uiLabel);
@ -271,24 +277,23 @@ public class LoginWebBridge {
String result = uc.uc_user_login(username, password);
result = new String(result.getBytes("iso-8859-1"), "gbk");
LinkedList<String> list = XMLHelper.uc_unserialize(result);
if (list.size() > 0) {
int $uid = Integer.parseInt(list.get(0));
if ($uid > 0) {
DesignerEnvManager.getEnvManager().setBbsUid($uid);
DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
DesignerEnvManager.getEnvManager().setBBSPassword(password);
return LOGININ;//登录成功,0
} else if ($uid == -1) {
return USERNAME_NOT_EXSIT;//用户名不存在,-1
} else if ($uid == -2) {
return PASSWORD_ERROR;//密码错误,-2
} else {
return UNKNOWN_ERROR;//未知错误,-3
}
} else {
if (list.size() == 0) {
return NET_FAILED;
}
int uid = Integer.parseInt(list.get(0));
if (uid > 0) {
DesignerEnvManager.getEnvManager().setBbsUid(uid);
DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
DesignerEnvManager.getEnvManager().setBBSPassword(password);
return LOGININ;//登录成功,0
} else if (uid == -1) {
return USERNAME_NOT_EXSIT;//用户名不存在,-1
} else if (uid == -2) {
return PASSWORD_ERROR;//密码错误,-2
} else {
return UNKNOWN_ERROR;//未知错误,-3
}
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
}
@ -313,21 +318,22 @@ public class LoginWebBridge {
public void getLoginInfo(String userInfo) {
org.json.JSONObject jo = new org.json.JSONObject(userInfo);
String status = jo.get("status").toString();
if (status.equals(LOGIN_SUCCESS)) {
if (ComparatorUtils.equals(status, LOGIN_SUCCESS)) {
String username = jo.get("username").toString();
int uid = Integer.parseInt(jo.get("uid") == null ? "" : jo.get("uid").toString());
int uid = Integer.parseInt(jo.get("uid") == null ? StringUtils.EMPTY : jo.get("uid").toString());
closeWindow();
closeQQWindow();
pluginuiLabel.setText(username);
DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setBbsUid(uid);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
} else if (status.equals(LOGIN_FAILED)) {
} else if (ComparatorUtils.equals(status, LOGIN_FAILED)) {
//账号没有QQ授权
closeQQWindow();
try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("QQ_binding")));
} catch (Exception exp) {
} catch (Exception ignore) {
// ignored
}
}
}

6
designer_base/src/com/fr/design/extra/ShopManagerPane.java

@ -2,9 +2,9 @@ package com.fr.design.extra;
import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter;
import javafx.embed.swing.JFXPanel;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* @author richie
@ -19,7 +19,7 @@ import java.awt.*;
*/
public class ShopManagerPane extends BasicPane {
public ShopManagerPane(JFXPanel webPane) {
public ShopManagerPane(Component webPane) {
setLayout(new BorderLayout());
add(webPane, BorderLayout.CENTER);
}

54
designer_base/src/com/fr/design/extra/WebViewDlgHelper.java

@ -15,9 +15,12 @@ import com.fr.general.http.HttpClient;
import com.fr.plugin.PluginVerifyException;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.File;
import java.lang.reflect.Constructor;
import java.net.HttpURLConnection;
import java.util.concurrent.ExecutionException;
@ -97,24 +100,46 @@ public class WebViewDlgHelper {
}
public static void createQQLoginDialog() {
QQLoginWebPane webPane = new QQLoginWebPane(new File(installHome).getAbsolutePath());
UIDialog qqlog = new QQLoginDialog(DesignerContext.getDesignerFrame(), webPane);
LoginWebBridge.getHelper().setQqDialog(qqlog);
qqlog.setVisible(true);
try {
Class<?> clazz = Class.forName("com.fr.design.extra.QQLoginWebPane");
Constructor constructor = clazz.getConstructor(String.class);
Component webPane = (Component) constructor.newInstance(new File(installHome).getAbsolutePath());
UIDialog qqLoginDialog = new QQLoginDialog(DesignerContext.getDesignerFrame(), webPane);
LoginWebBridge.getHelper().setQQDialog(qqLoginDialog);
qqLoginDialog.setVisible(true);
} catch (Throwable ignored) {
// ignored
}
}
private static void showPluginDlg(String mainJsPath) {
BasicPane managerPane = new ShopManagerPane(new PluginWebPane(mainJsPath));
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
try {
Class<?> clazz = Class.forName("com.fr.design.extra.PluginWebPane");
Constructor constructor = clazz.getConstructor(String.class);
Component webPane = (Component) constructor.newInstance(mainJsPath);
BasicPane managerPane = new ShopManagerPane(webPane);
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
} catch (Throwable ignored) {
// ignored
}
}
private static void showLoginDlg() {
LoginWebPane webPane = new LoginWebPane(new File(installHome).getAbsolutePath());
UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), webPane);
LoginWebBridge.getHelper().setDialogHandle(qqdlg);
qqdlg.setVisible(true);
try {
Class<?> clazz = Class.forName("com.fr.design.extra.LoginWebPane");
Constructor constructor = clazz.getConstructor(String.class);
Component webPane = (Component) constructor.newInstance(new File(installHome).getAbsolutePath());
UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), webPane);
LoginWebBridge.getHelper().setDialogHandle(qqdlg);
qqdlg.setVisible(true);
} catch (Throwable ignored) {
// ignored
}
}
private static Component initTraditionalStore() {
@ -136,6 +161,7 @@ public class WebViewDlgHelper {
PluginHelper.downloadPluginFile(scriptsId, username, password, new Process<Double>() {
@Override
public void process(Double integer) {
// ignored
}
});
} catch (PluginVerifyException e) {

4
designer_base/src/com/fr/design/locale/designer.properties

@ -1,4 +1,4 @@
# generated time: 星期二 十月 24 16:58:25 CST 2017
# generated time: \u661F\u671F\u4E8C \u5341\u6708 24 16:58:25 CST 2017
FR-Designer-BBSLogin_Account=
FR-Designer-BBSLogin_Connection-Failure=
FR-Designer-BBSLogin_Forgot-Password=
@ -1945,3 +1945,5 @@ FR-Designer_Decimal_Places=Decimal Places:
FR-Base-Load_Resource_File=Load resource file
FR-Designer_Get_Activation_Code=Click\! Get user information code
FR-Designer_Display_Position=Display position
FR-Designer_Template-Version-Warning="Your template file is currently open by a later production designer, will continue to open the original template properties mistakes or risk losing Make sure your design template designer version lower than the deployment server version."
FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect.

4
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -1,4 +1,4 @@
# generated time: 星期二 十月 24 16:58:25 CST 2017
# generated time: \u661F\u671F\u4E8C \u5341\u6708 24 16:58:25 CST 2017
FR-Designer-BBSLogin_Account=User name
FR-Designer-BBSLogin_Connection-Failure=Connection failure, check your network status
FR-Designer-BBSLogin_Forgot-Password=Forget Password
@ -1946,3 +1946,5 @@ FR-Designer_Decimal_Places=Decimal Places:
FR-Base-Load_Resource_File=Load Configuration File
FR-Designer_Get_Activation_Code=Get Activation Code
FR-Designer_Display_Position=Position
FR-Designer_Template-Version-Warning=The current template file is designed by higher vision designer. It may cause errors or loss of attributes if continue the operation! Please upgrade your designer. Make sure that your designer version is lower than the deployment server version.
FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect.

4
designer_base/src/com/fr/design/locale/designer_ja_JP.properties

@ -1,4 +1,4 @@
# generated time: 星期二 十月 24 16:58:25 CST 2017
# generated time: \u661F\u671F\u4E8C \u5341\u6708 24 16:58:25 CST 2017
FR-Designer-BBSLogin_Account=\u30E6\u30FC\u30B6\u30FC\u540D
FR-Designer-BBSLogin_Connection-Failure=\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\u73FE\u5728\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u72B6\u614B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044
FR-Designer-BBSLogin_Forgot-Password=\u30D1\u30B9\u30EF\u30FC\u30C9\u3092\u5FD8\u308C\u305F
@ -1946,3 +1946,5 @@ FR-Designer_Decimal_Places=\u5C0F\u6570\u67A0\u6570:
FR-Base-Load_Resource_File=\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30ED\u30FC\u30C9
FR-Designer_Get_Activation_Code=\u30AF\u30EA\u30C3\u30AF\u3057\u3066\!\u30A2\u30AF\u30C6\u30A3\u30D9\u30FC\u30C8\u30B3\u30FC\u30C9\u3092\u53D6\u5F97
FR-Designer_Display_Position=\u8868\u793A\u4F4D\u7F6E
FR-Designer_Template-Version-Warning=\u958B\u3044\u305F\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u30D5\u30A1\u30A4\u30EB\u306F\u3001\u4E0A\u4F4D\u30A8\u30C7\u30A3\u30B7\u30E7\u30F3\u306E\u30C7\u30B6\u30A4\u30CA\u30FC\u3067\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u4E0A\u4F4D\u30A8\u30C7\u30A3\u30B7\u30E7\u30F3\u3067\u4F5C\u6210\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u304F\u3068\u30A8\u30E9\u30FC\u306E\u767A\u751F\u539F\u56E0\u3068\u306A\u308B\u307B\u304B\u3001\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u6A5F\u80FD\u3084\u5C5E\u6027\u306E\u4E00\u90E8\u3092\u5931\u3046\u6050\u308C\u304C\u3042\u308A\u307E\u3059\u3002\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u4F5C\u6210\u7528\u306E\u30C7\u30B6\u30A4\u30CA\u30FC\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u304C\u3001\u914D\u5099\u3055\u308C\u308B\u30A8\u30C7\u30A3\u30B7\u30E7\u30F3\u3088\u308A\u3082\u4E0B\u4F4D\u306E\u30A8\u30C7\u30A3\u30B7\u30E7\u30F3\u3067\u3042\u308B\u3053\u3068\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
FR-Designer_Env_Des_Https=

4
designer_base/src/com/fr/design/locale/designer_ko_KR.properties

@ -1,4 +1,4 @@
# generated time: 星期二 十月 24 16:58:25 CST 2017
# generated time: \u661F\u671F\u4E8C \u5341\u6708 24 16:58:25 CST 2017
FR-Designer-BBSLogin_Account=\u7528\u6237\u540D
FR-Designer-BBSLogin_Connection-Failure=\uB124\uD2B8\uC6CC\uD06C\uB9C1\uD06C\uC2E4\uD328.\uD604\uC7AC\uB124\uD2B8\uC6CC\uD06C\uC0C1\uD0DC\uB97C\uAC80\uC0AC\uD574\uC8FC\uC2ED\uC2DC\uC624.
FR-Designer-BBSLogin_Forgot-Password=\u5FD8\u8BB0\u5BC6\u7801
@ -1945,3 +1945,5 @@ FR-Designer_Decimal_Places=\uC18C\uC218\uC218\uB7C9:
FR-Base-Load_Resource_File=\uB85C\uB529\uAD6C\uC131\uD30C\uC77C
FR-Designer_Get_Activation_Code=\!\uB97C\uD074\uB9AD\uD558\uC5EC\uD65C\uC131\uCF54\uB4DC\uB97C\uC5BB\uC2B5\uB2C8\uB2E4.
FR-Designer_Display_Position=\uC704\uCE58\uBCF4\uC774\uAE30
FR-Designer_Template-Version-Warning=\uC2E4\uD589\uD658\uACBD\uBCF4\uB2E4 \uB192\uC740 \uBC84\uC804\uC758 \uB514\uC790\uC774\uB108\uB85C \uAC1C\uBC1C\uB41C \uD30C\uC77C\uC785\uB2C8\uB2E4.\uACC4\uC18D\uC2E4\uD589\uC2DC \uC5D0\uB7EC\uAC00 \uB728\uAC70\uB098 \uC124\uC815\uB41C \uAE30\uB2A5\uC774 \uBE60\uC9C0\uB294 \uACBD\uC6B0\uAC00 \uC788\uC73C\uBBC0\uB85C \uBC84\uC804 \uD655\uC778\uD558\uACE0 \uC2E4\uD589\uD558\uC2DC\uAE38\uBC14\uB78D\uB2C8\uB2E4.(\uB0AE\uC740 \uBC84\uC804\uC740 \uACB8\uC6A9\uD558\uB098,\uB192\uC740 \uBC84\uC804\uC758 \uB514\uC790\uC774\uB108\uC5D0\uC11C \uC124\uC815\uB41C \uBD80\uBD84\uAE30\uB2A5\uC740 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC744\uC218 \uC788\uC2B5\uB2C8\uB2E4.
FR-Designer_Env_Des_Https=

4
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -1,4 +1,4 @@
# generated time: 星期二 十月 24 16:58:25 CST 2017
# generated time: \u661F\u671F\u4E8C \u5341\u6708 24 16:58:25 CST 2017
FR-Designer-BBSLogin_Account=\u7528\u6237\u540D
FR-Designer-BBSLogin_Connection-Failure=\u7F51\u7EDC\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u5F53\u524D\u7F51\u7EDC\u72B6\u6001
FR-Designer-BBSLogin_Forgot-Password=\u5FD8\u8BB0\u5BC6\u7801
@ -1945,3 +1945,5 @@ FR-Designer_Decimal_Places=\u5C0F\u6570\u6570\u76EE\uFF1A
FR-Base-Load_Resource_File=\u52A0\u8F7D\u914D\u7F6E\u6587\u4EF6
FR-Designer_Get_Activation_Code=\u70B9\u51FB\!\u83B7\u53D6\u6FC0\u6D3B\u7801
FR-Designer_Display_Position=\u663E\u793A\u4F4D\u7F6E
FR-Designer_Template-Version-Warning="\u60A8\u5F53\u524D\u6253\u5F00\u7684\u6A21\u677F\u6587\u4EF6\u662F\u7531\u66F4\u9AD8\u7248\u672C\u7684\u8BBE\u8BA1\u5668\u5236\u4F5C\u7684\uFF0C\u7EE7\u7EED\u6253\u5F00\u4F1A\u6709\u51FA\u9519\u6216\u8005\u4E22\u5931\u539F\u6709\u6A21\u677F\u5C5E\u6027\u7684\u98CE\u9669\u3002 \u8BF7\u786E\u4FDD\u60A8\u8BBE\u8BA1\u7684\u6A21\u677F\u7684\u8BBE\u8BA1\u5668\u7248\u672C\u4F4E\u4E8E\u90E8\u7F72\u7684\u670D\u52A1\u5668\u7248\u672C\u3002"
FR-Designer_Env_Des_Https=\u82E5\u542F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8BC1\u4E66\u8DEF\u5F84\u3001https\u79D8\u94A5\uFF09\uFF0C\u5FC5\u987B\u91CD\u542F\u8BBE\u8BA1\u5668\u624D\u80FD\u751F\u6548\u3002

4
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -1,4 +1,4 @@
# generated time: 星期二 十月 24 16:58:25 CST 2017
# generated time: \u661F\u671F\u4E8C \u5341\u6708 24 16:58:25 CST 2017
FR-Designer-BBSLogin_Account=\u767B\u5165\u5E33\u865F
FR-Designer-BBSLogin_Connection-Failure=\u767B\u5165\u9023\u63A5\u5931\u6557\uFF0C\u8ACB\u6AA2\u67E5\u7576\u524D\u7DB2\u8DEF\u72C0\u614B
FR-Designer-BBSLogin_Forgot-Password=\u5FD8\u8A18\u5BC6\u78BC
@ -1946,3 +1946,5 @@ FR-Designer_Decimal_Places=\u5C0F\u6578\u6578\u76EE\uFF1A
FR-Base-Load_Resource_File=\u52A0\u8F09\u914D\u7F6E\u6A94\u6848
FR-Designer_Get_Activation_Code=\u9EDE\u64CA\!\u7372\u53D6\u7528\u6236\u8A0A\u606F\u78BC
FR-Designer_Display_Position=\u986F\u793A\u4F4D\u7F6E
FR-Designer_Template-Version-Warning="\u60A8\u7576\u524D\u6253\u958B\u7684\u6A21\u677F\u6A94\u6848\u662F\u7531\u66F4\u9AD8\u7248\u672C\u7684\u8A2D\u8A08\u5668\u88FD\u4F5C\u7684\uFF0C\u7E7C\u7E8C\u6253\u958B\u6703\u6709\u51FA\u932F\u6216\u8005\u4E1F\u5931\u539F\u6709\u6A21\u677F\u5C6C\u6027\u7684\u98A8\u96AA\u3002 \u8ACB\u78BA\u4FDD\u60A8\u8A2D\u8A08\u7684\u6A21\u677F\u7684\u8A2D\u8A08\u5668\u7248\u672C\u4F4E\u65BC\u90E8\u7F72\u7684\u4F3A\u670D\u5668\u7248\u672C\u3002"
FR-Designer_Env_Des_Https=\u82E5\u555F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8B49\u66F8\u8DEF\u5F91\u3001https\u7955\u9470\uFF09\uFF0C\u5FC5\u9808\u91CD\u555F\u8A2D\u8A08\u5668\u624D\u80FD\u751F\u6548\u3002

178
designer_base/src/com/fr/design/utils/concurrent/ThreadFactoryBuilder.java

@ -0,0 +1,178 @@
/*
* Copyright (C) 2010 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.fr.design.utils.concurrent;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Locale;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
/**
* A ThreadFactory builder, providing any combination of these features:
* <ul>
* <li>whether threads should be marked as {@linkplain Thread#setDaemon daemon} threads
* <li>a {@linkplain ThreadFactoryBuilder#setNameFormat naming format}
* <li>a {@linkplain Thread#setPriority thread priority}
* <li>an {@linkplain Thread#setUncaughtExceptionHandler uncaught exception handler}
* <li>a {@linkplain ThreadFactory#newThread backing thread factory}
* </ul>
* <p>If no backing thread factory is provided, a default backing thread factory is used as if by
* calling {@code setThreadFactory(}{@link Executors#defaultThreadFactory()}{@code )}.
*
* @author Kurt Alfred Kluever
* @since 4.0
*/
public final class ThreadFactoryBuilder {
private String nameFormat = null;
private Boolean daemon = null;
private Integer priority = null;
private UncaughtExceptionHandler uncaughtExceptionHandler = null;
private ThreadFactory backingThreadFactory = null;
/**
* Creates a new {@link ThreadFactory} builder.
*/
public ThreadFactoryBuilder() {
// 这个注释毫无意义,就是为了通过SonarQube
}
/**
* Sets the naming format to use when naming threads ({@link Thread#setName}) which are created
* with this ThreadFactory.
*
* @param nameFormat a {@link String#format(String, Object...)}-compatible format String, to which
* a unique integer (0, 1, etc.) will be supplied as the single parameter. This integer will
* be unique to the built instance of the ThreadFactory and will be assigned sequentially. For
* example, {@code "rpc-pool-%d"} will generate thread names like {@code "rpc-pool-0"},
* {@code "rpc-pool-1"}, {@code "rpc-pool-2"}, etc.
* @return this for the builder pattern
*/
public ThreadFactoryBuilder setNameFormat(String nameFormat) {
String unused = format(nameFormat, 0); // fail fast if the format is bad or null
this.nameFormat = nameFormat;
return this;
}
/**
* Sets daemon or not for new threads created with this ThreadFactory.
*
* @param daemon whether or not new Threads created with this ThreadFactory will be daemon threads
* @return this for the builder pattern
*/
public ThreadFactoryBuilder setDaemon(boolean daemon) {
this.daemon = daemon;
return this;
}
/**
* Sets the priority for new threads created with this ThreadFactory.
*
* @param priority the priority for new Threads created with this ThreadFactory
* @return this for the builder pattern
*/
public ThreadFactoryBuilder setPriority(int priority) {
// Thread#setPriority() already checks for validity. These error messages
// are nicer though and will fail-fast.
if (priority < Thread.MIN_PRIORITY) {
throw new IllegalArgumentException(format("Thread priority (%s) must be >= %s", priority, Thread.MIN_PRIORITY));
}
if (priority > Thread.MAX_PRIORITY) {
throw new IllegalArgumentException(format("Thread priority (%s) must be <= %s", priority, Thread.MAX_PRIORITY));
}
this.priority = priority;
return this;
}
/**
* Sets the {@link UncaughtExceptionHandler} for new threads created with this ThreadFactory.
*
* @param uncaughtExceptionHandler the uncaught exception handler for new Threads created with
* this ThreadFactory
* @return this for the builder pattern
*/
public ThreadFactoryBuilder setUncaughtExceptionHandler(
UncaughtExceptionHandler uncaughtExceptionHandler) {
if (uncaughtExceptionHandler == null) {
throw new NullPointerException();
}
this.uncaughtExceptionHandler = uncaughtExceptionHandler;
return this;
}
/**
* Sets the backing {@link ThreadFactory} for new threads created with this ThreadFactory. Threads
* will be created by invoking #newThread(Runnable) on this backing {@link ThreadFactory}.
*
* @param backingThreadFactory the backing {@link ThreadFactory} which will be delegated to during
* thread creation.
* @return this for the builder pattern
*/
public ThreadFactoryBuilder setThreadFactory(ThreadFactory backingThreadFactory) {
if (backingThreadFactory == null) {
throw new NullPointerException();
}
this.backingThreadFactory = backingThreadFactory;
return this;
}
/**
* Returns a new thread factory using the options supplied during the building process. After
* building, it is still possible to change the options used to build the ThreadFactory and/or
* build again. State is not shared amongst built instances.
*
* @return the fully constructed {@link ThreadFactory}
*/
public ThreadFactory build() {
return doBuild(this);
}
// Split out so that the anonymous ThreadFactory can't contain a reference back to the builder.
// At least, I assume that's why. TODO(cpovirk): Check, and maybe add a test for this.
private static ThreadFactory doBuild(ThreadFactoryBuilder builder) {
final String nameFormat = builder.nameFormat;
final Boolean daemon = builder.daemon;
final Integer priority = builder.priority;
final UncaughtExceptionHandler uncaughtExceptionHandler = builder.uncaughtExceptionHandler;
final ThreadFactory backingThreadFactory =
(builder.backingThreadFactory != null)
? builder.backingThreadFactory
: Executors.defaultThreadFactory();
final AtomicLong count = (nameFormat != null) ? new AtomicLong(0) : null;
return new ThreadFactory() {
@Override
public Thread newThread(Runnable runnable) {
Thread thread = backingThreadFactory.newThread(runnable);
if (nameFormat != null) {
thread.setName(format(nameFormat, count.getAndIncrement()));
}
if (daemon != null) {
thread.setDaemon(daemon);
}
if (priority != null) {
thread.setPriority(priority);
}
if (uncaughtExceptionHandler != null) {
thread.setUncaughtExceptionHandler(uncaughtExceptionHandler);
}
return thread;
}
};
}
private static String format(String format, Object... args) {
return String.format(Locale.ROOT, format, args);
}
}

141
designer_base/src/com/fr/design/write/submit/CustomJobPane.java

@ -1 +1,140 @@
package com.fr.design.write.submit; import com.fr.base.GraphHelper; import com.fr.data.AbstractClassJob; import com.fr.design.data.tabledata.tabledatapane.ClassNameSelectPane; import com.fr.design.beans.BasicBeanPane; import com.fr.design.formula.JavaEditorPane; import com.fr.design.gui.frpane.ObjectProperiesPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.general.Inter; import com.fr.stable.StringUtils; import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** * Author : Shockway * Date: 13-7-29 * Time: 下午6:48 */ public abstract class CustomJobPane extends BasicBeanPane { protected UITextField classNameTextField; protected ObjectProperiesPane objectProperiesPane; public static final int DEFAULT_LENGTH = 30; public CustomJobPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); JPanel reportletNamePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); classNameTextField = new UITextField(getLengthOfTextField()); reportletNamePane.add(classNameTextField); UIButton browserButton = new UIButton(Inter.getLocText("FR-Designer_Select")); browserButton.setPreferredSize(new Dimension( GraphHelper.getLocTextWidth("FR-Designer_Select") + 20, classNameTextField.getPreferredSize().height)); UIButton editButton = new UIButton(Inter.getLocText("FR-Designer_Edit")); editButton.setPreferredSize(new Dimension( GraphHelper.getLocTextWidth("FR-Designer_Edit") + 20, classNameTextField.getPreferredSize().height)); reportletNamePane.add(browserButton); reportletNamePane.add(editButton); browserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { final ClassNameSelectPane bPane = new ClassNameSelectPane(); bPane.setClassPath(classNameTextField.getText()); bPane.showWindow( SwingUtilities.getWindowAncestor(getWindowAncestor()), new DialogActionAdapter() { public void doOk() { classNameTextField.setText(bPane.getClassPath()); checkAddButtonEnable(); } }).setVisible(true); } }); editButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JavaEditorPane javaEditorPane = new JavaEditorPane(classNameTextField.getText(), JavaEditorPane.DEFAULT_SUBMIT_JOB); final BasicDialog dlg = javaEditorPane.showMediumWindow(SwingUtilities.getWindowAncestor(CustomJobPane.this), new DialogActionAdapter() { public void doOk() { classNameTextField.setText(javaEditorPane.getClassText()); checkAddButtonEnable(); } }); javaEditorPane.addSaveActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dlg.doOK(); } }); dlg.setVisible(true); } }); reportletNamePane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_ClassName"), null)); this.add(reportletNamePane, BorderLayout.NORTH); objectProperiesPane = new ObjectProperiesPane(); objectProperiesPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_Property"), null)); this.add(objectProperiesPane, BorderLayout.CENTER); UITextArea area = new UITextArea(2, 1); area.setText(Inter.getLocText(new String[]{"Come_True", "Interface"}) + ":com.fr.data.SubmitJob"); JPanel dsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); dsPane.add(area); dsPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_Custom_Job_Description"), null)); this.add(dsPane, BorderLayout.SOUTH); checkAddButtonEnable(); } public int getLengthOfTextField() { return DEFAULT_LENGTH; } protected String title4PopupWindow() { return "CustomJob"; } protected Component getWindowAncestor() { return this; } @Override public void populateBean(Object ob) { if (ob instanceof AbstractClassJob) { AbstractClassJob cj = (AbstractClassJob) ob; this.classNameTextField.setText(cj.getClassName()); this.objectProperiesPane.populateBean(cj.getPropertyMap()); checkAddButtonEnable(); } } /** * 添加按钮可用 */ public void checkAddButtonEnable() { objectProperiesPane.enableAddButton(StringUtils.isNotEmpty(classNameTextField.getText())); } /** * 重置 */ public void reset() { this.classNameTextField.setText(null); this.checkAddButtonEnable(); } }
package com.fr.design.write.submit;
import com.fr.base.GraphHelper;
import com.fr.data.AbstractClassJob;
import com.fr.design.data.tabledata.tabledatapane.ClassNameSelectPane;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.formula.JavaEditorPane;
import com.fr.design.gui.frpane.ObjectProperiesPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Author : Shockway
* Date: 13-7-29
* Time: 下午6:48
*/
public abstract class CustomJobPane extends BasicBeanPane {
protected UITextField classNameTextField;
protected ObjectProperiesPane objectProperiesPane;
public static final int DEFAULT_LENGTH = 30;
public CustomJobPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel reportletNamePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane();
classNameTextField = new UITextField(getLengthOfTextField());
reportletNamePane.add(classNameTextField);
UIButton browserButton = new UIButton(Inter.getLocText("FR-Designer_Select"));
browserButton.setPreferredSize(new Dimension(
GraphHelper.getLocTextWidth("FR-Designer_Select") + 20,
classNameTextField.getPreferredSize().height));
UIButton editButton = new UIButton(Inter.getLocText("FR-Designer_Edit"));
editButton.setPreferredSize(new Dimension(
GraphHelper.getLocTextWidth("FR-Designer_Edit") + 20,
classNameTextField.getPreferredSize().height));
reportletNamePane.add(browserButton);
reportletNamePane.add(editButton);
browserButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
final ClassNameSelectPane bPane = new ClassNameSelectPane();
bPane.setClassPath(classNameTextField.getText());
bPane.showWindow(
SwingUtilities.getWindowAncestor(getWindowAncestor()),
new DialogActionAdapter() {
public void doOk() {
classNameTextField.setText(bPane.getClassPath());
checkAddButtonEnable();
}
}).setVisible(true);
}
});
editButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JavaEditorPane javaEditorPane = new JavaEditorPane(classNameTextField.getText(), JavaEditorPane.DEFAULT_SUBMIT_JOB);
final BasicDialog dlg = javaEditorPane.showMediumWindow(SwingUtilities.getWindowAncestor(CustomJobPane.this),
new DialogActionAdapter() {
public void doOk() {
classNameTextField.setText(javaEditorPane.getClassText());
checkAddButtonEnable();
}
});
javaEditorPane.addSaveActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dlg.doOK();
}
});
dlg.setVisible(true);
}
});
reportletNamePane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_ClassName"), null));
this.add(reportletNamePane, BorderLayout.NORTH);
objectProperiesPane = new ObjectProperiesPane();
objectProperiesPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_Property"), null));
this.add(objectProperiesPane, BorderLayout.CENTER);
UITextArea area = new UITextArea(2, 1);
area.setText(Inter.getLocText(new String[]{"Come_True", "Interface"}) + ":com.fr.data.AbstractSubmitTask");
JPanel dsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
dsPane.add(area);
dsPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer_Custom_Job_Description"), null));
this.add(dsPane, BorderLayout.SOUTH);
checkAddButtonEnable();
}
public int getLengthOfTextField() {
return DEFAULT_LENGTH;
}
protected String title4PopupWindow() {
return "CustomJob";
}
protected Component getWindowAncestor() {
return this;
}
@Override
public void populateBean(Object ob) {
if (ob instanceof AbstractClassJob) {
AbstractClassJob cj = (AbstractClassJob) ob;
this.classNameTextField.setText(cj.getClassName());
this.objectProperiesPane.populateBean(cj.getPropertyMap());
checkAddButtonEnable();
}
}
/**
* 添加按钮可用
*/
public void checkAddButtonEnable() {
objectProperiesPane.enableAddButton(StringUtils.isNotEmpty(classNameTextField.getText()));
}
/**
* 重置
*/
public void reset() {
this.classNameTextField.setText(null);
this.checkAddButtonEnable();
}
}

1
designer_base/src/com/fr/env/EnvListPane.java vendored

@ -377,6 +377,7 @@ public class EnvListPane extends JListControlPane {
previewTextArea.setText(Inter.getLocText("Env-Des2"));
try {
previewTextArea.getDocument().insertString(previewTextArea.getText().length(), Inter.getLocText("Env_Des"), this.getRedSytleAttribute());
previewTextArea.getDocument().insertString(previewTextArea.getText().length(), "\n" + Inter.getLocText("FR-Designer_Env_Des_Https"), this.getRedSytleAttribute());
} catch (BadLocationException e) {
FRContext.getLogger().error(e.getMessage(), e);
}

42
designer_base/src/com/fr/start/Demo.java

@ -8,42 +8,42 @@ import com.fr.stable.StableUtils;
import java.io.IOException;
public class Demo {
public static void main(String[] args) {
String installHome = StableUtils.getInstallHome();
if (installHome == null) {
FRContext.getLogger().error("Can not find the install home, please check it.");
return;
}
public static void main(String[] args) {
String installHome = StableUtils.getInstallHome();
if (installHome == null) {
FRContext.getLogger().error("Can not find the install home, please check it.");
return;
}
String executorPath;
if (OperatingSystem.isMacOS()) {
executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app --args demo");
executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app");
} else {
executorPath = StableUtils.pathJoin(installHome, "bin", "designer.exe demo");
}
if (!new java.io.File(executorPath).exists()) {
FRContext.getLogger().error(executorPath + " can not be found.");
}
if (!new java.io.File(executorPath).exists()) {
FRContext.getLogger().error(executorPath + " can not be found.");
}
if (OperatingSystem.isMacOS()) {
ProcessBuilder builder = new ProcessBuilder();
builder.command("open -a", executorPath);
ProcessBuilder builder = new ProcessBuilder();
builder.command("open", "-a", executorPath, "--args", "demo");
try {
builder.start();
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
} else {
// ProcessBuilder这种方式在window下报错:系统找不到指定文件
Runtime rt = Runtime.getRuntime();
try {
rt.exec(executorPath);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
// ProcessBuilder这种方式在window下报错:系统找不到指定文件
Runtime rt = Runtime.getRuntime();
try {
rt.exec(executorPath);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
System.exit(0);
}
System.exit(0);
}
}

7
designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java

@ -659,13 +659,6 @@ public class ChartInteractivePane extends BasicScrollPane<Chart> implements UIOb
private void populateHyperlink(Plot plot) {
HashMap paneMap = renewMapWithPlot(plot);
//安装平台内打开插件时,添加相应按钮
Set<HyperlinkProvider> providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG);
for (HyperlinkProvider provider : providers) {
NameableCreator nc = provider.createHyperlinkCreator();
paneMap.put(nc.getHyperlink(), nc.getUpdatePane());
}
List<UIMenuNameableCreator> list = refreshList(paneMap);
superLink.refreshMenuAndAddMenuAction(list);

35
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -722,7 +722,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
protected void delete(XCreator creator, int creatorWidth, int creatorHeight) {
int x = creator.getX();
int y = creator.getY();
recalculateChildrenSize(x, y, creatorWidth, creatorHeight);
recalculateChildrenSize(x, y, creatorWidth, creatorHeight, true);
}
/**
@ -734,6 +734,19 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* @param creatorHeight 删除的组件之前所在布局的高度
*/
public void recalculateChildrenSize(int x, int y, int creatorWidth, int creatorHeight) {
recalculateChildrenSize(x, y, creatorWidth, creatorHeight, false);
}
/**
* 重新计算内部组件大小
*
* @param x 坐标x
* @param y 坐标y
* @param creatorWidth 删除的组件之前所在布局的宽度
* @param creatorHeight 删除的组件之前所在布局的高度
* @param isDel 删除操作
*/
public void recalculateChildrenSize(int x, int y, int creatorWidth, int creatorHeight, boolean isDel) {
if (container.getComponentCount() == 0) {
return;
} else {
@ -744,11 +757,11 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) {
calculateRightRelatComponent(x, width + actualVal);
} else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) {
calculateLefttRelatComponent(width + actualVal);
calculateLefttRelatComponent(width + actualVal, isDel);
} else if (!downComps.isEmpty() && getAllWidth(downComps) == width) {
calculateDownRelatComponent(y, height + actualVal);
} else if (!upComps.isEmpty() && getAllWidth(upComps) == width) {
calculateUpRelatComponent(height + actualVal);
calculateUpRelatComponent(height + actualVal, isDel);
} else {
// 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理
calculateNoRelatedComponent(x, y, width, height);
@ -823,7 +836,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
return;
}
}
recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height);
recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height, true);
}
private void calculateNoRelatedWhileRightBott(Rectangle bound, Component rcomp) {
@ -858,7 +871,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
return;
}
}
recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height);
recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height, true);
}
private int getMinWidth(List<Component> comps) {
@ -1095,7 +1108,11 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* 删除或拉伸控件左边框时 调整左侧的组件位置大小
*/
protected boolean calculateLefttRelatComponent(int objWidth) {
if (isBeyondAdjustWidthScope(objWidth)) {
return calculateLefttRelatComponent(objWidth, false);
}
protected boolean calculateLefttRelatComponent(int objWidth, boolean isDel) {
if (!isDel && isBeyondAdjustWidthScope(objWidth)) {
return false;
}
int count = leftComps.size();
@ -1153,7 +1170,11 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
* 删除或拉伸上边框 调整上方的组件位置大小
*/
protected boolean calculateUpRelatComponent(int objHeight) {
if (isBeyondAdjustHeightScope(objHeight)) {
return calculateUpRelatComponent(objHeight, false);
}
protected boolean calculateUpRelatComponent(int objHeight, boolean isDel) {
if (!isDel && isBeyondAdjustHeightScope(objHeight)) {
return false;
}
int count = upComps.size();

6
designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java

@ -2,6 +2,7 @@ package com.fr.design.designer.properties;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
@ -97,6 +98,11 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr
if (row == 0) {
if (state == WBodyLayoutType.FIT.getTypeValue()) {
return switch2FitBodyLayout();
} else {
XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent();
if (xfl.toData().removeMargin()) {
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified();
}
}
}
if (row == 1) {

2
designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java

@ -12,6 +12,7 @@ import com.fr.design.mainframe.widget.editors.FitLayoutDirectionEditor;
import com.fr.design.mainframe.widget.editors.LayoutTypeEditor;
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
@ -152,6 +153,7 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel {
wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED);
Component[] components = xfl.getComponents();
xfl.removeAll();
xfl.toData().removeMargin();
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0));
xfl.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0);
for (Component component : components) {

117
designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

@ -5,24 +5,45 @@ import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.AbstractLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import java.awt.*;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 表单选中工具类
*
* @author yaoh.wu
* @version 2017年11月15日13点51分
* @since 8.0
*/
public class FormSelectionUtils {
//组件复制时坐标偏移
/**
* 组件复制时坐标偏移
*/
private static final int DELAY_X_Y = 20;
//组件重命名后缀
/**
* 组件重命名后缀
*/
private static final String POSTFIX = "_c";
private FormSelectionUtils() {
@ -47,6 +68,25 @@ public class FormSelectionUtils {
Toolkit.getDefaultToolkit().beep();
}
public static void rebuildSelection(FormDesigner designer) {
ArrayList<XCreator> newSelection = new ArrayList<>();
List<Widget> widgetList = new ArrayList<>();
for (XCreator comp : designer.getSelectionModel().getSelection().getSelectedCreators()) {
widgetList.add(comp.toData());
}
designer.getSelectionModel().setSelectedCreators(
rebuildSelection(designer.getRootComponent(), widgetList, newSelection));
}
public static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, Widget[] selectWidgets) {
List<Widget> selectionWidget = new ArrayList<>();
if (selectWidgets != null) {
selectionWidget.addAll(Arrays.asList(selectWidgets));
}
return FormSelectionUtils.rebuildSelection(rootComponent, selectionWidget, new ArrayList<XCreator>());
}
/**
* 绝对布局粘贴
*/
@ -92,26 +132,15 @@ public class FormSelectionUtils {
designer.getSelectionModel().getSelection().reset();
for (XCreator creator : clipboard.getSelectedCreators()) {
try {
Widget copied = copyWidget(designer, creator);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) {
if (!adapter.accept(copiedCreator, x - tabContainerRect.x, y - tabContainerRect.y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return;
}
} else {
if (!adapter.accept(copiedCreator, x, y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return;
}
}
boolean addSuccess = adapter.addBean(copiedCreator, x, y);
if (addSuccess) {
designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator);
if (creator instanceof XWScaleLayout) {
//XWScaleLayout封装了在自适应布局中需要保持默认高度的控件,由于自适应粘贴时会再次包装,因此复制时要进行解包
Component[] innerComponents = creator.getComponents();
for (Component innerComponent : innerComponents) {
XCreator innerXCreator = (XCreator) innerComponent;
relativePasteXCreator(designer, innerXCreator, adapter, tabContainerRect, x, y);
}
} catch (CloneNotSupportedException e) {
FRContext.getLogger().error(e.getMessage(), e);
} else {
relativePasteXCreator(designer, creator, adapter, tabContainerRect, x, y);
}
}
rebuildSelection(designer);
@ -119,6 +148,31 @@ public class FormSelectionUtils {
designer.getSelectionModel().getSelection().getSelectedCreator(), DesignerEvent.CREATOR_PASTED);
}
private static void relativePasteXCreator(FormDesigner designer, XCreator creator, LayoutAdapter adapter, Rectangle tabContainerRect, int x, int y) {
try {
Widget copied = copyWidget(designer, creator);
XCreator copiedXCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) {
if (!adapter.accept(copiedXCreator, x - tabContainerRect.x, y - tabContainerRect.y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return;
}
} else {
if (!adapter.accept(copiedXCreator, x, y)) {
designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste"));
return;
}
}
boolean addSuccess = adapter.addBean(copiedXCreator, x, y);
if (addSuccess) {
designer.getSelectionModel().getSelection().addSelectedCreator(copiedXCreator);
}
} catch (CloneNotSupportedException e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
}
/**
* 组件复用绝对布局获取粘贴组件位置
*/
@ -182,23 +236,6 @@ public class FormSelectionUtils {
return name.toString();
}
public static void rebuildSelection(FormDesigner designer) {
ArrayList<XCreator> newSelection = new ArrayList<>();
List<Widget> widgetList = new ArrayList<>();
for (XCreator comp : designer.getSelectionModel().getSelection().getSelectedCreators()) {
widgetList.add(comp.toData());
}
designer.getSelectionModel().setSelectedCreators(
rebuildSelection(designer.getRootComponent(), widgetList, newSelection));
}
public static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, Widget[] selectWidgets) {
List<Widget> selectionWidget = new ArrayList<>();
if (selectWidgets != null) {
selectionWidget.addAll(Arrays.asList(selectWidgets));
}
return FormSelectionUtils.rebuildSelection(rootComponent, selectionWidget, new ArrayList<XCreator>());
}
private static ArrayList<XCreator> rebuildSelection(XCreator rootComponent, List<Widget> selectionWidget,
ArrayList<XCreator> newSelection) {

Loading…
Cancel
Save