Browse Source

Merge pull request #344 in BA/design from ~NEIL/design:release to master

* commit '661fcbe959eb4d84b8605937b6e4fe7b600165a2': (92 commits)
  1
  1
  1
  ct
  ct
  只开放给部分客户测试,工具栏上先屏蔽绝对布局
  update
  update
  插件依赖中文乱码问题
  REPORT-341:表单下边距设置比较大的时候, 会导致二分出来效果不对.
  将“轻量重输出”写成插件,去掉原来的菜单项
  日文设计器,报表Web属性_填报页面设置排版问题,把最后一排按钮遮住了,现设置水平滚动条
  ip部分 sitecenter加了一下
  防止初始化的时候没有值,在调用的时候去取值
  update
  update
  异步生成模型数据
  bugfix:从插件管理里面登录,用户名显示不了
  网址部分修改
  update
  ...
master
neil 8 years ago
parent
commit
1a036d81a7
  1. 2
      designer/src/com/fr/design/mainframe/bbs/LoginDialog.java
  2. 33
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  3. 11
      designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java
  4. 11
      designer/src/com/fr/design/report/ValueVerifierEditPane.java
  5. 8
      designer/src/com/fr/design/webattr/PageWebSettingPane.java
  6. 20
      designer_base/src/com/fr/design/DesignerEnvManager.java
  7. 13
      designer_base/src/com/fr/design/extra/LoginPane.java
  8. 235
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  9. 2
      designer_base/src/com/fr/design/extra/LoginWebPane.java
  10. 47
      designer_base/src/com/fr/design/extra/PluginHelper.java
  11. 63
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  12. 47
      designer_base/src/com/fr/design/extra/QQLoginWebBridge.java
  13. 167
      designer_base/src/com/fr/design/extra/QQLoginWebPane.java
  14. 6
      designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java
  15. 4
      designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java
  16. 36
      designer_base/src/com/fr/design/extra/modal-dialog.css
  17. 271
      designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java
  18. BIN
      designer_base/src/com/fr/design/extra/plugindependence/image/background.png
  19. 257
      designer_base/src/com/fr/design/extra/ucenter/Client.java
  20. 113
      designer_base/src/com/fr/design/extra/ucenter/PHPFunctions.java
  21. 39
      designer_base/src/com/fr/design/extra/ucenter/XMLHelper.java
  22. 5
      designer_base/src/com/fr/design/formula/FunctionConstants.java
  23. 2
      designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java
  24. 68
      designer_base/src/com/fr/design/gui/itableeditorpane/UIArrayFormulaTableModel.java
  25. 23
      designer_base/src/com/fr/env/RemoteEnv.java
  26. 12
      designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
  27. 2
      designer_chart/src/com/fr/design/chart/gui/ChartComponent.java
  28. 36
      designer_form/src/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java
  29. 3
      designer_form/src/com/fr/design/designer/beans/painters/FRFitLayoutPainter.java
  30. 9
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  31. 2
      designer_form/src/com/fr/design/designer/creator/XWFitLayout.java
  32. 30
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

2
designer/src/com/fr/design/mainframe/bbs/LoginDialog.java

@ -15,7 +15,7 @@ import java.awt.*;
* Created by zhaohehe on 16/7/26. * Created by zhaohehe on 16/7/26.
*/ */
public class LoginDialog extends UIDialog { public class LoginDialog extends UIDialog {
private static final Dimension DEFAULT_SHOP = new Dimension(404, 234); private static final Dimension DEFAULT_SHOP = new Dimension(404, 204);
public LoginDialog(Frame frame, BasicPane pane) { public LoginDialog(Frame frame, BasicPane pane) {
super(frame); super(frame);

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

@ -47,6 +47,8 @@ public class UserInfoLabel extends UILabel{
private static final int MIN_MESSAGE_COUNT = 1; private static final int MIN_MESSAGE_COUNT = 1;
private static final int MENU_HEIGHT = 20; private static final int MENU_HEIGHT = 20;
private static final int DEFAULT_BBS_UID = 0;
//用户名 //用户名
private String userName; private String userName;
//消息条数 //消息条数
@ -78,7 +80,10 @@ public class UserInfoLabel extends UILabel{
this.addMouseListener(userInfoAdapter); this.addMouseListener(userInfoAdapter);
this.setHorizontalAlignment(SwingConstants.CENTER); this.setHorizontalAlignment(SwingConstants.CENTER);
this.setText(userName); this.setText(userName);
setUserName(userName);
LoginWebBridge loginWebBridge = new LoginWebBridge();
loginWebBridge.setUserName(userName, UserInfoLabel.this);
LoginCheckContext.addLoginCheckListener(new LoginCheckListener() { LoginCheckContext.addLoginCheckListener(new LoginCheckListener() {
@Override @Override
public void loginChecked() { public void loginChecked() {
@ -92,6 +97,9 @@ public class UserInfoLabel extends UILabel{
} }
}); });
PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
QQLoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this);
UserLoginContext.addLoginContextListener(new LoginContextListener() { UserLoginContext.addLoginContextListener(new LoginContextListener() {
@Override @Override
public void showLoginContext() { public void showLoginContext() {
@ -101,9 +109,21 @@ public class UserInfoLabel extends UILabel{
LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this); LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
QQLoginWebBridge.getHelper().setLoginlabel(); QQLoginWebBridge.getHelper().setLoginlabel();
qqdlg.setVisible(true); qqdlg.setVisible(true);
clearLoginInformation();
updateInfoPane();
} }
}); });
}
private void clearLoginInformation(){
DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setBbsUid(DEFAULT_BBS_UID);
}
private void updateInfoPane(){
userInfoPane.markUnSignIn();
} }
/** /**
@ -117,9 +137,7 @@ public class UserInfoLabel extends UILabel{
if(!FRContext.isChineseEnv()){ if(!FRContext.isChineseEnv()){
return; return;
} }
String lastBBSNewsTime = DesignerEnvManager.getEnvManager().getLastShowBBSNewsTime(); String lastBBSNewsTime = DesignerEnvManager.getEnvManager().getLastShowBBSNewsTime();
try { try {
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
if (ComparatorUtils.equals(lastBBSNewsTime, today)) { if (ComparatorUtils.equals(lastBBSNewsTime, today)) {
@ -129,25 +147,20 @@ public class UserInfoLabel extends UILabel{
} catch (InterruptedException e) { } catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage()); FRContext.getLogger().error(e.getMessage());
} }
HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.popup")); HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.popup"));
if (!hc.isServerAlive()){ if (!hc.isServerAlive()){
return; return;
} }
String res = hc.getResponseText(); String res = hc.getResponseText();
if (res.indexOf(BBSConstants.UPDATE_KEY) == -1){ if (res.indexOf(BBSConstants.UPDATE_KEY) == -1){
return; return;
} }
try { try {
BBSDialog bbsLabel = new BBSDialog(DesignerContext.getDesignerFrame()); BBSDialog bbsLabel = new BBSDialog(DesignerContext.getDesignerFrame());
bbsLabel.showWindow(SiteCenter.getInstance().acquireUrlByKind("bbs.popup")); bbsLabel.showWindow(SiteCenter.getInstance().acquireUrlByKind("bbs.popup"));
DesignerEnvManager.getEnvManager().setLastShowBBSNewsTime(DateUtils.DATEFORMAT2.format(new Date())); DesignerEnvManager.getEnvManager().setLastShowBBSNewsTime(DateUtils.DATEFORMAT2.format(new Date()));
} catch (Throwable e) { } catch (Throwable e) {
} }
} }
}); });
showBBSThread.start(); showBBSThread.start();
@ -181,7 +194,6 @@ public class UserInfoLabel extends UILabel{
if(StringUtils.isEmpty(this.userName)){ if(StringUtils.isEmpty(this.userName)){
updateMessageCount(); updateMessageCount();
} }
//往designerenvmanger里写一下 //往designerenvmanger里写一下
DesignerEnvManager.getEnvManager().setBBSName(userName); DesignerEnvManager.getEnvManager().setBBSName(userName);
this.userName = userName; this.userName = userName;
@ -210,7 +222,6 @@ public class UserInfoLabel extends UILabel{
} catch (Exception e) { } catch (Exception e) {
} }
} }
sleep(CHECK_MESSAGE_TIME); sleep(CHECK_MESSAGE_TIME);
} }
} }
@ -259,6 +270,7 @@ public class UserInfoLabel extends UILabel{
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
userName = DesignerEnvManager.getEnvManager().getBBSName();
if(StringUtils.isNotEmpty(userName)) { if(StringUtils.isNotEmpty(userName)) {
UIPopupMenu menu = new UIPopupMenu(); UIPopupMenu menu = new UIPopupMenu();
menu.setOnlyText(true); menu.setOnlyText(true);
@ -295,5 +307,4 @@ public class UserInfoLabel extends UILabel{
} }
} }
}; };
} }

11
designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java

@ -14,6 +14,7 @@ import java.util.Date;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.extra.LoginWebBridge;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.DateUtils; import com.fr.general.DateUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
@ -34,6 +35,9 @@ public class UserInfoPane extends BasicPane{
private static final int WIDTH = 104; private static final int WIDTH = 104;
private static final int HEIGHT = 24; private static final int HEIGHT = 24;
//登录成功
private static final String LOGININ = "0";
// 登录框弹出间隔时间 // 登录框弹出间隔时间
private static final int LOGIN_DIFF_DAY = 7; private static final int LOGIN_DIFF_DAY = 7;
// 等待国际化等相关初始化工作完成之后再弹出登录框 // 等待国际化等相关初始化工作完成之后再弹出登录框
@ -74,10 +78,11 @@ public class UserInfoPane extends BasicPane{
public void run() { public void run() {
String username = DesignerEnvManager.getEnvManager().getBBSName(); String username = DesignerEnvManager.getEnvManager().getBBSName();
String password = DesignerEnvManager.getEnvManager().getBBSPassword(); String password = DesignerEnvManager.getEnvManager().getBBSPassword();
if(!BBSLoginDialog.login(username, password)){ String loginResult = LoginWebBridge.getHelper().login(username, password);
markUnSignIn(); if (loginResult.equals(LOGININ)) {
}else{
markSignIn(username); markSignIn(username);
}else {
markUnSignIn();
} }
} }
}); });

11
designer/src/com/fr/design/report/ValueVerifierEditPane.java

@ -3,13 +3,14 @@ package com.fr.design.report;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.data.VerifyItem; import com.fr.data.VerifyItem;
import com.fr.design.gui.itableeditorpane.ActionStyle; import com.fr.design.gui.itableeditorpane.ActionStyle;
import com.fr.design.gui.itableeditorpane.UIArrayTableModel; import com.fr.design.gui.itableeditorpane.UIArrayFormulaTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.report.write.ValueVerifier; import com.fr.report.write.ValueVerifier;
import com.fr.stable.FormulaProvider; import com.fr.stable.FormulaProvider;
import com.fr.stable.StableUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -23,7 +24,7 @@ public class ValueVerifierEditPane extends JPanel {
public ValueVerifierEditPane() { public ValueVerifierEditPane() {
// ben:UITableEditorPane; // ben:UITableEditorPane;
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
tableEditorPane = new UITableEditorPane<Object[]>(new UIArrayTableModel(columnNames, new int[] { tableEditorPane = new UITableEditorPane(new UIArrayFormulaTableModel(columnNames, new int[] {
ActionStyle.ADDSTYLE, ActionStyle.DELETESTYLE, ActionStyle.ADDSTYLE, ActionStyle.DELETESTYLE,
ActionStyle.MOVEUPSTYLE, ActionStyle.MOVEDOWNSTYLE})); ActionStyle.MOVEUPSTYLE, ActionStyle.MOVEDOWNSTYLE}));
this.add(tableEditorPane, BorderLayout.CENTER); this.add(tableEditorPane, BorderLayout.CENTER);
@ -45,7 +46,11 @@ public class ValueVerifierEditPane extends JPanel {
if (formula == null) { if (formula == null) {
continue; continue;
} }
os[tableDataCount++] = new Object[]{formula.getPureContent(), item.getMessage()}; String msg = item.getMessage();
if (!StableUtils.canBeFormula(msg)) {
msg = "\"" + msg + "\"";//如果报错信息是以前的写法(字符串)就拼上""
}
os[tableDataCount++] = new Object[]{formula, new Formula(msg)};
} }
this.tableEditorPane.populate(os); this.tableEditorPane.populate(os);
} }

8
designer/src/com/fr/design/webattr/PageWebSettingPane.java

@ -52,10 +52,10 @@ public class PageWebSettingPane extends WebSettingPane<WebPage> {
double[] columnSize = { p,p,p}; double[] columnSize = { p,p,p};
double[] rowSize = { p, p,p,p }; double[] rowSize = { p, p,p,p };
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("Report_Show_Location") + ":", UILabel.RIGHT),buttonpane,null}, new Component[]{new UILabel(Inter.getLocText("Report_Show_Location") + ":", UILabel.RIGHT), buttonpane,null},
new Component[]{new UILabel(Inter.getLocText("PageSetup-Page") + ":", UILabel.RIGHT),isShowAsImageBox,isAutoScaleBox}, new Component[]{new UILabel(Inter.getLocText("PageSetup-Page") + ":", UILabel.RIGHT), isShowAsImageBox, isAutoScaleBox},
new Component[]{null,isTDHeavyBox,null} new Component[]{null, isTDHeavyBox, null}
} ; };
return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
} }

20
designer_base/src/com/fr/design/DesignerEnvManager.java

@ -93,6 +93,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private String bbsName; private String bbsName;
//当前设计器用户的论坛密码 //当前设计器用户的论坛密码
private String bbsPassword; private String bbsPassword;
//当前设计器用户的论坛ID
private int bbsUid;
//当前设计器用户的昵称显示(带消息)
private String inShowBBsName;
//上一次登录弹窗的时间, 为了控制一天只弹一次窗口 //上一次登录弹窗的时间, 为了控制一天只弹一次窗口
private String lastShowBBSTime; private String lastShowBBSTime;
//上一次资讯弹窗时间, 为了控制一天只弹一次 //上一次资讯弹窗时间, 为了控制一天只弹一次
@ -1149,6 +1153,22 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.bbsPassword = bbsPassword; this.bbsPassword = bbsPassword;
} }
public int getBbsUid() {
return bbsUid;
}
public void setBbsUid(int bbsUid) {
this.bbsUid = bbsUid;
}
public void setInShowBBsName(String inShowBBsName) {
this.inShowBBsName = inShowBBsName;
}
public String getInShowBBsName() {
return inShowBBsName;
}
public String getLastShowBBSTime() { public String getLastShowBBSTime() {
return lastShowBBSTime; return lastShowBBSTime;
} }

13
designer_base/src/com/fr/design/extra/LoginPane.java

@ -4,6 +4,7 @@ import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -53,6 +54,7 @@ public class LoginPane extends BasicPane {
} }
} }
} else { } else {
initTraditionalStore();
} }
} }
@ -91,7 +93,6 @@ public class LoginPane extends BasicPane {
@Override @Override
protected void done() { protected void done() {
try { try {
if (get()) { if (get()) {
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome());
@ -112,7 +113,6 @@ public class LoginPane extends BasicPane {
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);
} }
} }
}.execute(); }.execute();
} }
@ -140,4 +140,13 @@ public class LoginPane extends BasicPane {
} }
}.execute(); }.execute();
} }
private void initTraditionalStore() {
UITabbedPane tabbedPane = new UITabbedPane();
add(tabbedPane, BorderLayout.CENTER);
PluginInstalledPane installedPane = new PluginInstalledPane();
tabbedPane.addTab(installedPane.tabTitle(), installedPane);
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_Update"), new PluginUpdatePane(tabbedPane));
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane));
}
} }

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

@ -3,38 +3,64 @@ package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog; 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.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.FRLogger;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javafx.scene.web.WebEngine; import javafx.scene.web.WebEngine;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URI; import java.net.URI;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.HashMap;
import java.util.LinkedList;
/**
* Created by zhaohehe on 16/8/1.
*/
public class LoginWebBridge { public class LoginWebBridge {
private static final String LOGIN_SUCCESS_FLAG = "http://bbs.finereport.com"; //默认查询消息时间, 30s
private static final long CHECK_MESSAGE_TIME = 30 * 1000L;
//数据查询正常的标志 ok
private static final String SUCCESS_MESSAGE_STATUS = "ok";
//数据通讯失败
private static final String FAILED_MESSAGE_STATUS = "error";
//消息条数
private int messageCount;
//最低消息的条数
private static final int MIN_MESSAGE_COUNT = 0;
//登录成功
private static final String LOGININ = "0"; private static final String LOGININ = "0";
private static final String LOGIN_INFO_EMPTY = "-1"; //用户名不存在
private static final String DISCONNECTED = "-2"; private static final String USERNAME_NOT_EXSIT = "-1";
//密码错误
private static final String PASSWORD_ERROR = "-2";
//未知错误
private static final String UNKNOWN_ERROR = "-3"; private static final String UNKNOWN_ERROR = "-3";
//网络连接失败
private static final String NET_FAILED = "-4";
//用户名,密码为空
private static final String LOGIN_INFO_EMPTY = "-5";
private static final int TIME_OUT = 10000; private static final int TIME_OUT = 10000;
private static com.fr.design.extra.LoginWebBridge helper; private static com.fr.design.extra.LoginWebBridge helper;
private UIDialog uiDialog; private UIDialog uiDialog;
private UILabel uiLabel; private UILabel uiLabel;
private String userName;
public int getMessageCount() {
return messageCount;
}
/**
* 测试论坛网络连接
* @return
*/
private boolean testConnection() { private boolean testConnection() {
HttpClient client = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.test")); HttpClient client = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.test"));
return client.isServerAlive(); return client.isServerAlive();
@ -60,9 +86,6 @@ public class LoginWebBridge {
private WebEngine webEngine; private WebEngine webEngine;
private LoginWebBridge() {
}
public void setEngine(WebEngine webEngine) { public void setEngine(WebEngine webEngine) {
this.webEngine = webEngine; this.webEngine = webEngine;
} }
@ -75,12 +98,108 @@ public class LoginWebBridge {
this.uiLabel = uiLabel; this.uiLabel = uiLabel;
} }
public LoginWebBridge() {
String username = DesignerEnvManager.getEnvManager().getBBSName();
setUserName(username, uiLabel);
}
/**
* 设置显示的用户名
* @param userName 登录用户名
* @param label label显示
*/
public void setUserName(String userName, UILabel label) {
if (uiLabel == null) {
this.uiLabel = label;
}
if(StringUtils.isEmpty(userName)){
return;
}
if(!StringUtils.isEmpty(this.userName)){
updateMessageCount();
}
DesignerEnvManager.getEnvManager().setBBSName(userName);
this.userName = userName;
}
/**
* 定时取后台论坛消息
*/
private void updateMessageCount(){
//启动获取消息更新的线程
//登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数.
Thread updateMessageThread = new Thread(new Runnable() {
@Override
public void run() {
sleep(CHECK_MESSAGE_TIME);
while(StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getBBSName())){
HashMap<String, String> para = new HashMap<>();
int uid = DesignerEnvManager.getEnvManager().getBbsUid();
para.put("uid", String.valueOf(uid));
HttpClient getMessage = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.message"), para);
getMessage.asGet();
if(getMessage.isServerAlive()){
try {
String res = getMessage.getResponseText();
if (res.equals(FAILED_MESSAGE_STATUS)) {
}else {
JSONObject jo = new JSONObject(res);
if (jo.getString("status").equals(SUCCESS_MESSAGE_STATUS)) {
setMessageCount(Integer.parseInt(jo.getString("message")));
}
}
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
}
}
sleep(CHECK_MESSAGE_TIME);
}
}
});
updateMessageThread.start();
}
/**
* 设置获取的消息长度并设置显示
* @param count
*/
public void setMessageCount(int count) {
if (count == MIN_MESSAGE_COUNT) {
uiLabel.setText(DesignerEnvManager.getEnvManager().getBBSName());
DesignerEnvManager.getEnvManager().setInShowBBsName(DesignerEnvManager.getEnvManager().getBBSName());
return;
}
this.messageCount = count;
StringBuilder sb = new StringBuilder();
sb.append(StringUtils.BLANK).append(this.userName)
.append("(").append(this.messageCount)
.append(")").append(StringUtils.BLANK);
DesignerEnvManager.getEnvManager().setInShowBBsName(sb.toString());
uiLabel.setText(sb.toString());
}
private String encode(String str){
try {
return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
return str;
}
}
private void sleep(long millis){
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage());
}
}
/** /**
* 注册页面 * 注册页面
*/ */
public void registerHref() { public void registerHref() {
try { try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default"))); Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.register")));
}catch (Exception e) { }catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FRContext.getLogger().info(e.getMessage());
} }
@ -98,25 +217,47 @@ public class LoginWebBridge {
} }
/** /**
* 登录操作的回调 * 设计器端的用户登录
* @param username * @param username 用户名
* @param password * @param password 密码
* @return * @return 登录信息标志
*/ */
public String defaultLogin(String username, String password) { public String defaultLogin(String username, String password) {
return login(username, password, uiLabel);
}
/**
* 插件管理的用户登录部分
* @param username 用户名
* @param password 密码
* @param uiLabel 设计器端的label
* @return 登录信息标志
*/
public String pluginManageLogin(String username, String password, UILabel uiLabel) {
return login(username, password, uiLabel);
}
/**
* 登录操作
* @param username 用户名
* @param password 密码
* @param uiLabel 两边的label显示
* @return 登录信息标志
*/
private String login(String username, String password, UILabel uiLabel) {
if (!StringUtils.isNotBlank(username) && !StringUtils.isNotBlank(password)) { if (!StringUtils.isNotBlank(username) && !StringUtils.isNotBlank(password)) {
return LOGIN_INFO_EMPTY; return LOGIN_INFO_EMPTY;
} }
if (!testConnection()) { if (!testConnection()) {
return DISCONNECTED; return NET_FAILED;
} }
if (login(username, password)) { String loginResult = login(username, password);
if (loginResult.equals(LOGININ)) {
updateUserInfo(username, password); updateUserInfo(username, password);
loginSuccess(username); loginSuccess(username, uiLabel);
return LOGININ; setUserName(username, uiLabel);
}else {
return UNKNOWN_ERROR;
} }
return loginResult;
} }
/** /**
@ -126,19 +267,27 @@ public class LoginWebBridge {
if (uiDialog != null) { if (uiDialog != null) {
uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
uiDialog.setVisible(false); uiDialog.setVisible(false);
uiDialog.dispose();
} }
} }
/**
* 更新后台的用户信息
* @param username 用户名
* @param password 密码
*/
public void updateUserInfo(String username,String password) { public void updateUserInfo(String username,String password) {
DesignerEnvManager.getEnvManager().setBBSName(username); DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setBBSPassword(password); DesignerEnvManager.getEnvManager().setBBSPassword(password);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
this.userName = username;
} }
/** /**
* 关闭窗口并且重新赋值 * 关闭窗口并且重新赋值
* @param username * @param username
*/ */
public void loginSuccess(String username) { public void loginSuccess(String username, UILabel uiLabel) {
closeWindow(); closeWindow();
uiLabel.setText(username); uiLabel.setText(username);
} }
@ -161,28 +310,30 @@ public class LoginWebBridge {
}); });
} }
public boolean login(String username, String password) { public String login(String username, String password) {
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
try { try {
username = URLEncoder.encode(username, EncodeConstants.ENCODING_GBK); Client uc = new Client();
password = URLEncoder.encode(password, EncodeConstants.ENCODING_GBK); String result = uc.uc_user_login(username, password);
} catch (UnsupportedEncodingException e) { result = new String(result.getBytes("iso-8859-1"), "gbk");
FRLogger.getLogger().error(e.getMessage()); LinkedList<String> list = XMLHelper.uc_unserialize(result);
} if (list.size() > 0) {
String url = SiteCenter.getInstance().acquireUrlByKind("bbs.login") + "&username=" + username + "&password=" + password; int $uid = Integer.parseInt(list.get(0));
HttpClient client = new HttpClient(url); if ($uid > 0) {
client.setTimeout(TIME_OUT); DesignerEnvManager.getEnvManager().setBbsUid($uid);
if (client.getResponseCodeNoException() == HttpURLConnection.HTTP_OK) { return LOGININ;//登录成功,0
try { } else if ($uid == -1) {
String res = client.getResponseText(EncodeConstants.ENCODING_GBK); return USERNAME_NOT_EXSIT;//用户名不存在,-1
if (res.contains(LOGIN_SUCCESS_FLAG)) { } else if ($uid == -2) {
return true; return PASSWORD_ERROR;//密码错误,-2
} } else {
} catch (Exception e) { return UNKNOWN_ERROR;//未知错误,-3
FRLogger.getLogger().error(e.getMessage());
} }
}else {
return NET_FAILED;
} }
}catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
} }
return false; return UNKNOWN_ERROR;
} }
} }

2
designer_base/src/com/fr/design/extra/LoginWebPane.java

@ -31,7 +31,7 @@ public class LoginWebPane extends JFXPanel {
LoginWebPane.this.setScene(scene); LoginWebPane.this.setScene(scene);
WebView webView = new WebView(); WebView webView = new WebView();
webEngine = webView.getEngine(); webEngine = webView.getEngine();
webEngine.load("file:///" + installHome + "/scripts/store/web/login.html"); webEngine.load("file:///" + installHome + "/scripts/qqLogin/web/login.html");
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() { webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override @Override
public void handle(WebEvent<String> event) { public void handle(WebEvent<String> event) {

47
designer_base/src/com/fr/design/extra/PluginHelper.java

@ -3,11 +3,15 @@ package com.fr.design.extra;
import com.fr.base.Env; import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.plugindependence.DownLoadDependenceUI;
import com.fr.general.*; import com.fr.general.*;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.plugin.Plugin; import com.fr.plugin.Plugin;
import com.fr.plugin.PluginLoader; import com.fr.plugin.PluginLoader;
import com.fr.plugin.PluginManagerHelper; import com.fr.plugin.PluginManagerHelper;
import com.fr.plugin.dependence.PluginDependence;
import com.fr.plugin.dependence.PluginDependenceException;
import com.fr.plugin.dependence.PluginDependenceUnit;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -18,7 +22,9 @@ import javax.swing.*;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
/** /**
@ -29,6 +35,8 @@ import java.util.concurrent.ExecutionException;
public class PluginHelper { public class PluginHelper {
private static final String TEMP_PATH = System.getProperty("user.dir") + "/tmp"; private static final String TEMP_PATH = System.getProperty("user.dir") + "/tmp";
public static final String DOWNLOAD_PATH = System.getProperty("user.dir") + "/download"; public static final String DOWNLOAD_PATH = System.getProperty("user.dir") + "/download";
//插件依赖的下载位置
public static final String DEPENDENCE_DOWNLOAD_PATH = System.getProperty("user.dir") + "/download/dependence";
public static final String TEMP_FILE = "temp.zip"; public static final String TEMP_FILE = "temp.zip";
/** /**
@ -105,6 +113,8 @@ public class PluginHelper {
plugin = new Plugin(); plugin = new Plugin();
InputStream inputStream = plugin.readEncryptXml(new FileInputStream(f)); InputStream inputStream = plugin.readEncryptXml(new FileInputStream(f));
XMLTools.readInputStreamXML(plugin, inputStream); XMLTools.readInputStreamXML(plugin, inputStream);
//检查是否需要准备插件依赖环境
checkDependenceEnv(plugin);
if (!plugin.isValidate()) { if (!plugin.isValidate()) {
return null; return null;
} }
@ -117,6 +127,43 @@ public class PluginHelper {
return plugin; return plugin;
} }
//将所有未配置好的资源文件依赖准备好
private static void checkDependenceEnv(Plugin plugin) throws PluginDependenceException {
PluginDependence dependence = plugin.getDependence();
if (dependence == null){
return;
}
List<PluginDependenceUnit> needInstallDependence = new ArrayList<PluginDependenceUnit>();
String currentID = dependence.getCurrentPluginID();
List<PluginDependenceUnit> list = dependence.getDependPlugins();
for (int i = 0;list != null && i < list.size(); i++){
PluginDependenceUnit dependenceUnit = list.get(i);
if (!dependenceUnit.checkFileEnv()){
needInstallDependence.add(dependenceUnit);
}
}
if (needInstallDependence.isEmpty()){
return;
}
//安装插件依赖
installDependenceOnline(currentID, needInstallDependence);
}
/**
* 构造一个下载UI
* @param currentID
* @param list
* @throws PluginDependenceException
*/
private static void installDependenceOnline(String currentID, List<PluginDependenceUnit> list) throws PluginDependenceException{
DownLoadDependenceUI ui = new DownLoadDependenceUI(currentID, list);
ui.installOnline();
}
/** /**
* 从选中的压缩文件中安装插件 * 从选中的压缩文件中安装插件
* *

63
designer_base/src/com/fr/design/extra/PluginWebBridge.java

@ -1,9 +1,11 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.*; import com.fr.design.extra.exe.*;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
@ -41,6 +43,8 @@ public class PluginWebBridge {
private String KEYWORD = "keyword"; private String KEYWORD = "keyword";
private Map<String, Object> config; private Map<String, Object> config;
private UILabel uiLabel;
/** /**
* 动作枚举 * 动作枚举
*/ */
@ -394,10 +398,6 @@ public class PluginWebBridge {
}); });
} }
public void getUsername() {
}
/** /**
* 在本地浏览器里打开url * 在本地浏览器里打开url
* tips:重载的时候,需要给js调用的方法需要放在前面,否则可能不会被调用(此乃坑) * tips:重载的时候,需要给js调用的方法需要放在前面,否则可能不会被调用(此乃坑)
@ -490,4 +490,59 @@ public class PluginWebBridge {
JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} }
} }
/*-------------------------------登录部分的处理----------------------------------*/
/**
* 注册页面
*/
public void registerHref() {
try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.register")));
}catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
}
}
/**
* 忘记密码
*/
public void forgetHref() {
try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default")));
}catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
}
}
public void setUILabel(UILabel uiLabel) {
this.uiLabel = uiLabel;
}
/**
* 登录操作的回调
* @param username
* @param password
* @return
*/
public String defaultLogin(String username, String password) {
return LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel);
}
/**
* 弹出QQ授权页面
*/
public void showQQ() {
LoginWebBridge.getHelper().showQQ();
}
/**
* 清除用户信息
*/
public void clearUserInfo() {
DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY);
uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
}
} }

47
designer_base/src/com/fr/design/extra/QQLoginWebBridge.java

@ -3,10 +3,16 @@ package com.fr.design.extra;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRLogger;
import com.fr.general.SiteCenter;
import javafx.scene.web.WebEngine; import javafx.scene.web.WebEngine;
import org.json.JSONObject; import org.json.JSONObject;
import netscape.javascript.JSObject;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
/** /**
* Created by lp on 2016/8/10. * Created by lp on 2016/8/10.
@ -19,6 +25,7 @@ public class QQLoginWebBridge {
private static String LOGINFAILED = "failed"; private static String LOGINFAILED = "failed";
private UIDialog uiDialog; private UIDialog uiDialog;
private UILabel uiLabel; private UILabel uiLabel;
private UILabel pluginuiLabel;
private UIDialog qqDialog; private UIDialog qqDialog;
private String username; private String username;
@ -54,10 +61,16 @@ public class QQLoginWebBridge {
this.uiLabel = uiLabel; this.uiLabel = uiLabel;
} }
public void setUILabelInPlugin(UILabel uiLabel) {
this.pluginuiLabel = uiLabel;
}
public void setLoginlabel() { public void setLoginlabel() {
username = DesignerEnvManager.getEnvManager().getBBSName(); username = DesignerEnvManager.getEnvManager().getBBSName();
} }
private static JSObject window;
public static com.fr.design.extra.QQLoginWebBridge getHelper(WebEngine webEngine) { public static com.fr.design.extra.QQLoginWebBridge getHelper(WebEngine webEngine) {
getHelper(); getHelper();
helper.setEngine(webEngine); helper.setEngine(webEngine);
@ -93,13 +106,45 @@ public class QQLoginWebBridge {
String status = jo.get("status").toString(); String status = jo.get("status").toString();
if (status.equals(LOGINSUCCESS)) { if (status.equals(LOGINSUCCESS)) {
String username = jo.get("username").toString(); String username = jo.get("username").toString();
int uid = Integer.parseInt(jo.get("uid") == null ? "" : jo.get("uid").toString());
closeQQWindow(); closeQQWindow();
closeParentWindow(); closeParentWindow();
uiLabel.setText(username); pluginuiLabel.setText(username);
DesignerEnvManager.getEnvManager().setBBSName(username); DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setBbsUid(uid);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
}else if (status.equals(LOGINFAILED)){ }else if (status.equals(LOGINFAILED)){
//账号没有QQ授权 //账号没有QQ授权
closeQQWindow(); closeQQWindow();
try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default")));
}catch (Exception exp) {
}
}
}
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) {
if (url.indexOf("qqLogin.html") > 0) {
return;
}
if (Desktop.isDesktopSupported()) {
try {
//创建一个URI实例,注意不是URL
URI uri = URI.create(url);
//获取当前系统桌面扩展
Desktop desktop = Desktop.getDesktop();
//判断系统桌面是否支持要执行的功能
if (desktop.isSupported(Desktop.Action.BROWSE)) {
//获取系统默认浏览器打开链接
desktop.browse(uri);
}
} catch (NullPointerException e) {
//此为uri为空时抛出异常
FRLogger.getLogger().error(e.getMessage());
} catch (IOException e) {
//此为无法获取系统默认浏览器
FRLogger.getLogger().error(e.getMessage());
}
} }
} }
} }

167
designer_base/src/com/fr/design/extra/QQLoginWebPane.java

@ -1,16 +1,38 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.embed.swing.JFXPanel; import javafx.embed.swing.JFXPanel;
import javafx.event.ActionEvent;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.ButtonBuilder;
import javafx.scene.control.LabelBuilder;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBoxBuilder;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine; import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent; import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView; import javafx.scene.web.WebView;
import javafx.stage.*;
import javafx.util.Callback;
import netscape.javascript.JSObject; import netscape.javascript.JSObject;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
/** /**
* Created by zhaohehe on 16/7/28. * Created by zhaohehe on 16/7/28.
@ -19,6 +41,17 @@ public class QQLoginWebPane extends JFXPanel {
private WebEngine webEngine; private WebEngine webEngine;
private static JSObject window;
private static int DEFAULT_PRIMARYSTAGE_WIDTH = 100;
private static int DEFAULT_PRIMARYSTAGE_HEIGHT = 100;
private static int DEFAULT_CONFIRM_WIDTH = 450;
private static int DEFAULT_CONFIRM_HEIGHT = 160;
private static int DEFAULT_OFFEST = 20;
class Delta { double x, y; }
public QQLoginWebPane(final String installHome) { public QQLoginWebPane(final String installHome) {
Platform.setImplicitExit(false); Platform.setImplicitExit(false);
Platform.runLater(new Runnable() { Platform.runLater(new Runnable() {
@ -27,17 +60,61 @@ public class QQLoginWebPane extends JFXPanel {
BorderPane root = new BorderPane(); BorderPane root = new BorderPane();
Scene scene = new Scene(root); Scene scene = new Scene(root);
QQLoginWebPane.this.setScene(scene); QQLoginWebPane.this.setScene(scene);
WebView webView = new WebView(); final WebView webView = new WebView();
webEngine = webView.getEngine(); webEngine = webView.getEngine();
webEngine.load("file:///" + installHome + "/scripts/store/web/qqLogin.html"); webEngine.load("file:///" + installHome + "/scripts/qqLogin/web/qqLogin.html");
final Stage primaryStage = new Stage();
HBox layout = new HBox();
try {
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.setScene(new Scene(layout));
webView.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm());
primaryStage.initStyle(StageStyle.UTILITY);
primaryStage.setScene(new Scene(new Group(), DEFAULT_PRIMARYSTAGE_WIDTH, DEFAULT_PRIMARYSTAGE_HEIGHT));
primaryStage.setX(0);
primaryStage.setY(Screen.getPrimary().getBounds().getHeight() + DEFAULT_PRIMARYSTAGE_HEIGHT);
primaryStage.show();
}catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
}
webView.getEngine().setConfirmHandler(new Callback<String, Boolean>() {
@Override public Boolean call(String msg) {
Boolean confirmed = confirm(primaryStage, msg, installHome, webView);
return confirmed;
}
});
webEngine.locationProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, final String oldValue, String newValue) {
disableLink(webEngine);
// webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转
if (ComparatorUtils.equals(newValue, "file:///" + installHome + "/scripts/qqLogin/web/qqLogin.html") || ComparatorUtils.equals(newValue, SiteCenter.getInstance().acquireUrlByKind("bbs.mobile"))) {
return;
}
QQLoginWebBridge.getHelper().openUrlAtLocalWebBrowser(webEngine, newValue);
}
});
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() { webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override @Override
public void handle(WebEvent<String> event) { public void handle(WebEvent<String> event) {
showAlert(event.getData()); showAlert(event.getData());
} }
}); });
JSObject obj = (JSObject) webEngine.executeScript("window"); webEngine.getLoadWorker().stateProperty().addListener(
obj.setMember("QQLoginHelper", QQLoginWebBridge.getHelper(webEngine)); new ChangeListener<Worker.State>() {
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
if (newState == Worker.State.SUCCEEDED) {
window = (JSObject) webEngine.executeScript("window");
window.setMember("QQLoginHelper", QQLoginWebBridge.getHelper(webEngine));
}
}
}
);
webView.setContextMenuEnabled(false);//屏蔽右键 webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView); root.setCenter(webView);
} }
@ -52,4 +129,86 @@ public class QQLoginWebPane extends JFXPanel {
} }
}); });
} }
private void disableLink(final WebEngine eng) {
try {
// webView端不跳转 虽然webView可以指定本地浏览器打开某个链接,但是当本地浏览器跳转到指定链接的同时,webView也做了跳转,
// 为了避免出现在一个600*400的资讯框里加载整个网页的情况,webView不跳转到新网页
Platform.runLater(new Runnable() {
@Override
public void run() {
eng.executeScript("location.reload()");
QQLoginWebBridge.getHelper().closeQQWindow();
}
});
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
private Boolean confirm(final Stage parent, String msg, final String installHome,final WebView webView) {
final BooleanProperty confirmationResult = new SimpleBooleanProperty();
// initialize the confirmation dialog
final Stage dialog = new Stage(StageStyle.UTILITY);
dialog.setX(Toolkit.getDefaultToolkit().getScreenSize().getWidth()/2 - DEFAULT_CONFIRM_WIDTH / 2 + DEFAULT_OFFEST);
dialog.setY(Toolkit.getDefaultToolkit().getScreenSize().getHeight()/2 + DEFAULT_OFFEST);
dialog.setHeight(DEFAULT_CONFIRM_HEIGHT);
dialog.setWidth(DEFAULT_CONFIRM_WIDTH);
dialog.setIconified(false);
dialog.initOwner(parent);
dialog.initModality(Modality.WINDOW_MODAL);
dialog.setScene(
new Scene(
HBoxBuilder.create().styleClass("modal-dialog").children(
LabelBuilder.create().text(msg).build(),
ButtonBuilder.create().text(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account")).defaultButton(true).onAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
// take action and close the dialog.
confirmationResult.set(true);
webView.getEngine().reload();
dialog.close();
}
}).build(),
ButtonBuilder.create().text(Inter.getLocText("FR-Engine_Cancel")).cancelButton(true).onAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
// abort action and close the dialog.
confirmationResult.set(false);
dialog.close();
}
}).build()
).build()
, Color.TRANSPARENT
)
);
// allow the dialog to be dragged around.
final Node root = dialog.getScene().getRoot();
final Delta dragDelta = new Delta();
root.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent mouseEvent) {
// record a delta distance for the drag and drop operation.
dragDelta.x = dialog.getX() - mouseEvent.getScreenX();
dragDelta.y = dialog.getY() - mouseEvent.getScreenY();
}
});
root.setOnMouseDragged(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent mouseEvent) {
dialog.setX(mouseEvent.getScreenX() + dragDelta.x);
dialog.setY(mouseEvent.getScreenY() + dragDelta.y);
}
});
// style and show the dialog.
dialog.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm());
dialog.setOnCloseRequest(new EventHandler<WindowEvent>(){
@Override
public void handle(WindowEvent event){
event.consume();
dialog.close();
}
});
dialog.showAndWait();
return confirmationResult.get();
}
} }

6
designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java

@ -2,6 +2,7 @@ package com.fr.design.extra.exe;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.Process; import com.fr.design.extra.Process;
import com.fr.stable.StringUtils;
/** /**
* Created by lp on 2016/8/16. * Created by lp on 2016/8/16.
@ -26,9 +27,10 @@ public class GetLoginInfoExecutor implements Executor {
@Override @Override
public void run(Process<String> process) { public void run(Process<String> process) {
String username = DesignerEnvManager.getEnvManager().getBBSName(); String username = DesignerEnvManager.getEnvManager().getBBSName();
if (username == null) { String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName();
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) {
}else { }else {
result = username; result = StringUtils.isEmpty(inShowUsername) ? username : inShowUsername;
} }
} }
} }

4
designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java

@ -9,6 +9,7 @@ import com.fr.design.extra.PluginHelper;
import com.fr.design.extra.Process; import com.fr.design.extra.Process;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.plugin.PluginVerifyException; import com.fr.plugin.PluginVerifyException;
import com.fr.plugin.dependence.PluginDependenceException;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
@ -40,6 +41,7 @@ public class InstallOnlineExecutor implements Executor {
@Override @Override
public void run(final Process<String> process) { public void run(final Process<String> process) {
//下载插件
if(StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())){ if(StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())){
LoginCheckContext.fireLoginCheckListener(); LoginCheckContext.fireLoginCheckListener();
} }
@ -88,6 +90,8 @@ public class InstallOnlineExecutor implements Executor {
}); });
} catch (PluginVerifyException e) { } catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} catch (PluginDependenceException e){
JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {

36
designer_base/src/com/fr/design/extra/modal-dialog.css

@ -0,0 +1,36 @@
/**
* modal-dialog.css
* place in same directory as WebViewConfirm.java
* ensure your build system copies the file to your build output directory
*/
.root {
-fx-glass-color: white;
}
.modal-dialog {
-fx-padding: 20;
-fx-spacing: 10;
-fx-alignment: center;
-fx-font-size: 14;
-fx-background-color: linear-gradient(to bottom, derive(-fx-glass-color, 20%), -fx-glass-color);
-fx-border-color: derive(-fx-glass-color, -20%);
-fx-border-width: 5;
-fx-background-insets: 12;
-fx-border-insets: 10;
-fx-border-radius: 6;
-fx-background-radius: 6;
}
.modal-dialog:pressed {
-fx-cursor: move;
}
.modal-dialog .button:pressed {
-fx-cursor: default;
}
.confirmation-results {
-fx-background-color: cornsilk;
-fx-padding: 5;
}

271
designer_base/src/com/fr/design/extra/plugindependence/DownLoadDependenceUI.java

@ -0,0 +1,271 @@
package com.fr.design.extra.plugindependence;
import com.fr.base.FRContext;
import com.fr.design.extra.PluginConstants;
import com.fr.design.extra.PluginHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.plugin.dependence.PluginDependenceException;
import com.fr.plugin.dependence.PluginDependenceUnit;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.HttpURLConnection;
import java.util.List;
/**
* Created by hufan on 2016/9/5.
*/
public class DownLoadDependenceUI implements ActionListener {
//进度显示界面
private JDialog frame = null;
//进度条
private JProgressBar progressbar;
//进度信息
private JLabel label;
//进度条更新时钟
private Timer timer;
//是否继续下载
private boolean flag = true;
// 定义加载窗口大小
private final int LOAD_WIDTH = 455;
private final int LOAD_HEIGHT = 295;
//安装环境相关信息
private String currentID;
private List<PluginDependenceUnit> list = null;
//安装结果
private boolean result = false;
//链接服务器的客户端
private HttpClient httpClient;
//已读文件字节数
private int totalBytesRead = 0;
//文件总长度
private int totalSize = 0;
public DownLoadDependenceUI() {
}
public DownLoadDependenceUI(String currentID, List<PluginDependenceUnit> list) {
this.currentID = currentID;
this.list = list;
this.totalSize = getFileLength();
init();
}
private void init() {
// 创建标签,并在标签上放置一张图片
BufferedImage image = IOUtils.readImage("/com/fr/design/extra/plugindependence/image/background.png");
ImageIcon imageIcon = new ImageIcon(image);
label = new JLabel(imageIcon);
label.setBounds(0, 0, LOAD_WIDTH, LOAD_HEIGHT - 15);
progressbar = new JProgressBar();
// 显示当前进度值信息
progressbar.setStringPainted(true);
// 设置进度条边框不显示
progressbar.setBorderPainted(false);
// 设置进度条的前景色
progressbar.setForeground(new Color(0x38aef5));
// 设置进度条的背景色
progressbar.setBackground(new Color(188, 190, 194));
progressbar.setBounds(0, LOAD_HEIGHT - 15, LOAD_WIDTH, 15);
progressbar.setMinimum(0);
progressbar.setMaximum(totalSize);
progressbar.setValue(0);
timer = new Timer(100, this);
frame = new JDialog(DesignerContext.getDesignerFrame(), true);
frame.setTitle(Inter.getLocText("FR-Designer-Dependence_Install_Online"));
frame.setSize(LOAD_WIDTH, LOAD_HEIGHT);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation(screenSize.width / 2 - LOAD_WIDTH / 2, screenSize.height / 2 - LOAD_HEIGHT / 2);
frame.setResizable(false);
// 设置布局为空
frame.setLayout(new BorderLayout(0, 0));
frame.getContentPane().add(label, BorderLayout.CENTER);
frame.getContentPane().add(progressbar, BorderLayout.SOUTH);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
//取消下载
flag = false;
frame.dispose();
}
});
}
//是否可以连接服务器
private boolean connectToServer() {
for (int i = 0; i < list.size(); i++) {
PluginDependenceUnit dependenceUnit = list.get(i);
httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID()));
if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK){
return false;
}
}
return true;
}
//获取依赖文件大小
private int getFileLength(){
int size = 0;
for (int i = 0; i < list.size(); i++) {
PluginDependenceUnit dependenceUnit = list.get(i);
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID()));
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
size += httpClient.getContentLength();
}else {
return -1;
}
}
return size;
}
//安装
private boolean install() {
//开始时钟
timer.start();
//开始下载
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
installDependenceOnline();
}
});
thread.start();
frame.setVisible(true);
//等待下载线程处理结束
try {
thread.join();
} catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage());
return false;
}
//停止时钟
timer.stop();
return result;
}
/**
* 下载和安装不分开是因为本地如果只安装好了一个依赖下次就不需要重复下载了
* 如果下载依赖后不安装则后面的插件会把前面的插件覆盖故而下载好了一个安装一个
* @return
* @throws Exception
*/
private void downloadAndInstallPluginDependenceFile() throws Exception {
totalBytesRead = 0;
for (int i = 0; i < list.size(); i++) {
PluginDependenceUnit dependenceUnit = list.get(i);
httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(dependenceUnit.getDependenceID()));
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream reader = httpClient.getResponseStream();
String temp = StableUtils.pathJoin(PluginHelper.DEPENDENCE_DOWNLOAD_PATH, PluginHelper.TEMP_FILE);
StableUtils.makesureFileExist(new File(temp));
FileOutputStream writer = new FileOutputStream(temp);
byte[] buffer = new byte[PluginConstants.BYTES_NUM];
int bytesRead = 0;
while ((bytesRead = reader.read(buffer)) > 0 && flag) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[PluginConstants.BYTES_NUM];
totalBytesRead += bytesRead;
}
reader.close();
writer.flush();
writer.close();
//下载被取消
if (flag == false) {
result = false;
throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed"));
}
//安装文件
IOUtils.unZipFilesGBK(temp, FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir());
} else {
result = false;
throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed"));
}
}
//所有依赖都正常安装下载完毕,则结果为true
result = true;
}
public void installDependenceOnline() {
try {
//下载并安装文件
downloadAndInstallPluginDependenceFile();
} catch (Exception e) {
result = false;
FRContext.getLogger().error(e.getMessage());
}
}
//安装已经下载好的文件,如果是服务文件,则需要复制一份到安装目录下,
//以便切换远程时,使用本地的服务
//如果是服务器环境,则只会安装一份
private void installPluginDependenceFile(List<String> filePathList){
if (filePathList.isEmpty()){
result = false;
return;
}
for(int i = 0; i < filePathList.size(); i++) {
if (StringUtils.EMPTY.equals(filePathList.get(i))){
result = false;
return;
}
PluginDependenceUnit dependenceUnit = list.get(i);
IOUtils.unzip(new File(filePathList.get(i)), FRContext.getCurrentEnv().getPath() + dependenceUnit.getDependenceDir());
result = true;
}
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == timer) {
int value = progressbar.getValue();
if (value < totalSize) {
progressbar.setValue(totalBytesRead);
} else {
timer.stop();
frame.dispose();
}
}
}
public void installOnline()throws PluginDependenceException {
int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer-Plugin_Plugin") + Inter.getLocText("FR-Designer-Need") + Inter.getLocText("FR-Designer-Dependence") + Inter.getLocText("FR-Designer-Support") + "," + Inter.getLocText("FR-Designer-Dependence_Need_Install") + "(" + showFileLength() + " m)?", "install tooltip", JOptionPane.YES_NO_OPTION);
if (choose == 0) {//下载安装
if (!connectToServer()) {
throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Connect_Server_Error"));
}
//安装依赖环境
if (install()) {
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Dependence_Install_Succeed") + "!!");
} else {
throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed"));
}
}else {//不选择下载,则不安装图标插件
throw new PluginDependenceException(Inter.getLocText("FR-Designer-Dependence_Install_Failed"));
}
}
private String showFileLength() {
return totalSize == -1 ? "NAN" : totalSize / Math.pow(10, 6) + "";
}
}

BIN
designer_base/src/com/fr/design/extra/plugindependence/image/background.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

257
designer_base/src/com/fr/design/extra/ucenter/Client.java

@ -0,0 +1,257 @@
package com.fr.design.extra.ucenter;
import com.fr.base.FRContext;
import com.fr.general.SiteCenter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
/**
* Created by lp on 2016/9/9.
*/
public class Client extends PHPFunctions{
public static String UC_IP = "";
public static String UC_API = "";
public static String UC_CONNECT = "";
public static String UC_KEY = "Rc85U37411p4zdvcedm8D4t4D3l9Sa42H0kd98Gbd82aA99a61S2Z5LbQ9u430M0";
public static String UC_APPID = "4";
public static String UC_CLIENT_RELEASE = "20090212";
public static String UC_ROOT = "";
public static String UC_API_FUNC = UC_CONNECT.equals("mysql") ? "uc_api_mysql" : "uc_api_post";
public String uc_user_login(String username, String password) {
return uc_user_login(username, password, 0, 0);
}
public String uc_user_login(String username, String password, int isuid, int checkques) {
return uc_user_login(username, password, isuid, checkques, "", "");
}
/**
* 用户登录
* @param username 用户名
* @param password 密码
* @param isuid 是否为uid
* @param checkques 是否使用安全问题
* @param questionid 安全提问
* @param answer 安全提问答案
* @return array (uid/status, username, password, email)
*/
public String uc_user_login(String username, String password, int isuid, int checkques, String questionid, String answer) {
Map<String, Object> args = new HashMap<>();
args.put("username", username);
args.put("password", password);
args.put("isuid", isuid);
args.put("checkques", checkques);
args.put("questionid", questionid);
args.put("answer", answer);
String $return = call_user_func(UC_API_FUNC, "user", "login", args);
return UC_CONNECT.equals("mysql") ? $return : $return;
}
/**
* 拼接发送的post请求
* @param module 模块
* @param action 操作模式
* @param arg 参数
* @return 发送的请求加密内容
*/
public String uc_api_post(String module, String action, Map<String, Object> arg) {
StringBuffer str = new StringBuffer();
String sep = "";
for (String k : arg.keySet()) {
Object v = arg.get(k);
k = urlencode(k);
if (v.getClass().isAssignableFrom(Map.class)) {
String s2 = "";
String sep2 = "";
for (String k2 : ((Map<String, Object>) v).keySet()) {
Object v2 = ((Map<String, Object>) v).get(k2);
k2 = urlencode(k2);
s2 += sep2 + "{" + k + "}[" + k2 + "]=" + urlencode(String.valueOf(v2));
sep2 = "&";
}
str.append(sep).append(s2);
} else {
str.append(sep).append(k).append("=").append(urlencode(String.valueOf(v), "GBK"));
}
sep = "&";
}
String $postdata = uc_api_requestdata(module, action, str.toString(), "");
UC_API = SiteCenter.getInstance().acquireUrlByKind("bbs.ucapi");
UC_IP = SiteCenter.getInstance().acquireUrlByKind("bbs.ip");
return uc_fopen2(UC_API + "/index.php", 500000, $postdata, "", true, UC_IP, 20, true);
}
public String uc_api_mysql(String model, String action, Map args) {
return "";
}
public String uc_api_input(String data) {
String str = urlencode(uc_authcode(data + "&agent=" + md5("") + "&time=" + time(), "ENCODE", UC_KEY), "GBK");
return str;
}
protected String uc_api_requestdata(String module, String action, String arg, String extra) {
String input = uc_api_input(arg);
String post = "m=" + module + "&a=" + action + "&inajax=2&release=" + UC_CLIENT_RELEASE + "&input=" + input + "&appid=" + UC_APPID + extra;
return post;
}
public String uc_authcode(String string, String operation, String key) {
return uc_authcode(string, operation, key, 0);
}
/**
* 内容加密
* @param string 原文
* @param operation decode或者encode
* @param key 密钥
* @param expiry 密文有效时限
* @return 加密之后的原文
*/
public String uc_authcode(String string, String operation, String key, int expiry) {
int ckey_length = 4;
key = md5(key != null ? key : UC_KEY);
String keya = md5(substr(key, 0, 16));
String keyb = md5(substr(key, 16, 16));
String keyc = ckey_length > 0 ? (operation.equals("DECODE") ? substr(string, 0, ckey_length) : substr(md5(microtime()), - ckey_length)) : "";
String cryptkey = keya + md5(keya + keyc);
int key_length = cryptkey.length();
string = operation.equals("DECODE") ? base64_decode(substr(string, ckey_length)) : sprintf("%010d", expiry > 0 ? expiry + time() : 0) + substr(md5(string + keyb), 0, 16) + string;
int string_length = string.length();
StringBuffer result1 = new StringBuffer();
int[] box = new int[256];
for (int i = 0; i < 256; i++) {
box[i] = i;
}
int[] rndkey = new int[256];
for (int i = 0; i <= 255; i++) {
rndkey[i] = (int) cryptkey.charAt(i % key_length);
}
int j = 0;
for (int i = 0; i < 256; i++) {
j = (j + box[i] + rndkey[i]) % 256;
int tmp = box[i];
box[i] = box[j];
box[j] = tmp;
}
j = 0;
int a = 0;
for (int i = 0; i < string_length; i++) {
a = (a + 1) % 256;
j = (j + box[a]) % 256;
int tmp = box[a];
box[a] = box[j];
box[j] = tmp;
result1.append((char) (((int) string.charAt(i)) ^ (box[(box[a] + box[j]) % 256])));
}
if (operation.equals("DECODE")) {
String result = result1.toString();
try {
result = new String(result.getBytes("iso-8859-1"), "gbk");
} catch (Exception e) {
result = result1.substring(0, result1.length());
}
if ((Integer.parseInt(substr(result.toString(), 0, 10)) == 0 || Long.parseLong(substr(result.toString(), 0, 10)) - time() > 0) && substr(result.toString(), 10, 16).equals(substr(md5(substr(result.toString(), 26) + keyb), 0, 16))) {
return substr(result.toString(), 26);
} else {
return "";
}
} else {
return keyc + base64_encode(result1.toString()).replaceAll("=", "");
}
}
protected String uc_fopen2(String url, int limit, String post, String cookie, boolean bysocket, String ip, int timeout, boolean block) {
url += url.indexOf("?") > 0 ? "&" : "?" + "__times__=1";
return uc_fopen(url, limit, post, cookie, bysocket, ip, timeout, block);
}
/**
* 本地模网络请求取数据
* @param url 打开的url
* @param limit 取返回的数据的长度
* @param post 要发送的 POST 数据如uid=1&password=1234
* @param cookie 要模拟的 COOKIE 数据如uid=123&auth=a2323sd2323
* @param bysocket TRUE/FALSE 是否通过SOCKET打开
* @param ip IP地址
* @param timeout 连接超时时间
* @param block 是否为阻塞模式 defaul valuet:true
* @return 取到的字符串
*/
protected String uc_fopen(String url, int limit, String post, String cookie, boolean bysocket, String ip, int timeout, boolean block) {
String result = "";
URL matches;
String host = "";
String path = "";
int port = 80;
try {
matches = new URL(url);
host = matches.getHost();
path = matches.getPath() != null ? matches.getPath() + (matches.getQuery() != null ? "?" + matches.getQuery() : "") : "/";
if (matches.getPort() > 0) port = matches.getPort();
} catch (Exception e1) {
FRContext.getLogger().info(e1.getMessage());
}
StringBuffer out = new StringBuffer();
if (post != null && post.length() > 0) {
out.append("POST ").append(path).append(" HTTP/1.0\r\n");
out.append("Accept: */*\r\n");
out.append("Accept-Language: zh-cn\r\n");
out.append("Content-Type: application/x-www-form-urlencoded\r\n");
out.append("User-Agent: \r\n");
out.append("Host: ").append(host).append("\r\n");
out.append("Content-Length: ").append(post.length()).append("\r\n");
out.append("Connection: Close\r\n");
out.append("Cache-Control: no-cache\r\n");
out.append("Cookie: \r\n\r\n");
out.append(post);
} else {
out.append("GET $path HTTP/1.0\r\n");
out.append("Accept: */*\r\n");
out.append("Accept-Language: zh-cn\r\n");
out.append("User-Agent: Java/1.5.0_01\r\n");
out.append("Host: $host\r\n");
out.append("Connection: Close\r\n");
out.append("Cookie: $cookie\r\n\r\n");
}
try {
Socket fp = new Socket(ip != null && ip.length() > 10 ? ip : host, port);
if (!fp.isConnected()) {
return "";
} else {
OutputStream os = fp.getOutputStream();
os.write(out.toString().getBytes());
InputStream ins = fp.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(ins, "iso-8859-1"));
while (true) {
String header = reader.readLine();
if (header == null || header.equals("") || header == "\r\n" || header == "\n") {
break;
}
}
while (true) {
String data = reader.readLine();
if (data == null || data.equals("")) {
break;
} else {
result += data;
}
}
fp.close();
}
} catch (IOException e) {
FRContext.getLogger().info(e.getMessage());
}
return result;
}
}

113
designer_base/src/com/fr/design/extra/ucenter/PHPFunctions.java

@ -0,0 +1,113 @@
package com.fr.design.extra.ucenter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import com.fr.base.Base64;
import com.fr.base.FRContext;
/**
* Created by lp on 2016/9/9.
*/
public abstract class PHPFunctions {
protected String urlencode(String value){
return URLEncoder.encode(value);
}
protected String md5(String input){
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
return byte2hex(md.digest(input.getBytes()));
}
protected String md5(long input){
return md5(String.valueOf(input));
}
protected String base64_decode(String input){
try {
return new String(Base64.decode(input));
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
}
protected String base64_encode(String input){
try {
return new String(Base64.encode(input.getBytes("iso-8859-1")));
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
}
protected String byte2hex(byte[] b) {
StringBuffer hs = new StringBuffer();
String stmp = "";
for (int n = 0; n < b.length; n++) {
stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
if (stmp.length() == 1)
hs.append("0").append(stmp);
else
hs.append(stmp);
}
return hs.toString();
}
protected String substr(String input,int begin, int length){
return input.substring(begin, begin+length);
}
protected String substr(String input,int begin){
if(begin > 0){
return input.substring(begin);
}else{
return input.substring(input.length()+ begin);
}
}
protected long microtime(){
return System.currentTimeMillis();
}
protected long time(){
return System.currentTimeMillis()/1000;
}
protected String sprintf(String format, long input){
String temp = "0000000000"+input;
return temp.substring(temp.length()-10);
}
protected String call_user_func(String function, String model, String action, Map<String,Object> args){
if("uc_api_mysql".equals(function)){
return this.uc_api_mysql(model, action, args);
}
if("uc_api_post".equals(function)){
return this.uc_api_post(model, action, args);
}
return "";
}
public abstract String uc_api_post(String $module, String $action, Map<String,Object> $arg );
public abstract String uc_api_mysql(String $model, String $action, Map $args);
protected String urlencode(String value,String code){
try {
return URLEncoder.encode(value,code);
} catch (UnsupportedEncodingException e) {
FRContext.getLogger().info(e.getMessage());
}
return "";
}
}

39
designer_base/src/com/fr/design/extra/ucenter/XMLHelper.java

@ -0,0 +1,39 @@
package com.fr.design.extra.ucenter;
import com.fr.base.FRContext;
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.StringReader;
import java.util.LinkedList;
/**
* Created by lp on 2016/9/9.
*/
public class XMLHelper {
public static LinkedList<String> uc_unserialize(String input){
LinkedList<String> result = new LinkedList<String>();
DOMParser parser = new DOMParser();
try {
parser.parse(new InputSource(new StringReader(input)));
Document doc = parser.getDocument();
NodeList nl = doc.getChildNodes().item(0).getChildNodes();
int length = nl.getLength();
for(int i=0;i<length;i++){
if(nl.item(i).getNodeType()==Document.ELEMENT_NODE)
result.add(nl.item(i).getTextContent());
}
} catch (SAXException e) {
FRContext.getLogger().info(e.getMessage());
} catch (IOException e1) {
FRContext.getLogger().info(e1.getLocalizedMessage());
}
return result;
}
}

5
designer_base/src/com/fr/design/formula/FunctionConstants.java

@ -122,7 +122,10 @@ public abstract class FunctionConstants {
String[] arr = filePath.split("!/"); String[] arr = filePath.split("!/");
String jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符 String jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符
String classPath = arr[1]; String classPath = arr[1];
if (OperatingSystem.isMacOS()){ if(classPath.endsWith("/")){
classPath = classPath.substring(0, classPath.length() - 1);
}
if (!OperatingSystem.isWindows()){
//windows里substring后是d:\123\456, mac下substring后是Application/123/456 //windows里substring后是d:\123\456, mac下substring后是Application/123/456
jarPath = StringUtils.perfectStart(jarPath, "/"); jarPath = StringUtils.perfectStart(jarPath, "/");
} }

2
designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java

@ -15,7 +15,7 @@ public class UIScrollPane extends JScrollPane {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public UIScrollPane(Component c) { public UIScrollPane(Component c) {
super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
this.setHorizontalScrollBar(createHorizontalScrollBar()); this.setHorizontalScrollBar(createHorizontalScrollBar());
this.getVerticalScrollBar().setUnitIncrement(30); this.getVerticalScrollBar().setUnitIncrement(30);
this.getVerticalScrollBar().setBlockIncrement(30); this.getVerticalScrollBar().setBlockIncrement(30);

68
designer_base/src/com/fr/design/gui/itableeditorpane/UIArrayFormulaTableModel.java

@ -0,0 +1,68 @@
package com.fr.design.gui.itableeditorpane;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.table.TableCellEditor;
import java.awt.*;
/**
* 全部是公式编辑的model
* Coder: zack
* Date: 2016/8/31
* Time: 18:58
*/
public class UIArrayFormulaTableModel extends UIArrayTableModel {
public UIArrayFormulaTableModel(String[] s, int[] array) {
super(s, array);
setDefaultEditors();
}
public void setDefaultEditors() {
for (int i = 0; i < getColumnCount(); i++) {
setDefaultEditor(Object.class, new FormulaValueEditor());
}
}
private class FormulaValueEditor extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = 1L;
private ValueEditorPane editor;
public FormulaValueEditor() {
editor = ValueEditorPaneFactory.createFormulaValueEditorPane();
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1 || table.getSelectedColumn() == -1) {
return;
}
Object[] para = getList().get(table.getSelectedRow());
para[table.getSelectedColumn()] = getCellEditorValue();
fireTableDataChanged();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
editor.clearComponentsData();
editor.populate(value == null ? "" : value);
return editor;
}
@Override
public Object getCellEditorValue() {
return editor.update();
}
}
}

23
designer_base/src/com/fr/env/RemoteEnv.java vendored

@ -31,6 +31,8 @@ import com.fr.plugin.Plugin;
import com.fr.plugin.PluginLicense; import com.fr.plugin.PluginLicense;
import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.PluginLicenseManager;
import com.fr.plugin.PluginLoader; import com.fr.plugin.PluginLoader;
import com.fr.plugin.dependence.PluginServiceCreator;
import com.fr.plugin.dependence.PluginServiceManager;
import com.fr.stable.*; import com.fr.stable.*;
import com.fr.stable.file.XMLFileManagerProvider; import com.fr.stable.file.XMLFileManagerProvider;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -2079,7 +2081,28 @@ public class RemoteEnv implements Env {
} }
} }
@Override
public String pluginServiceAction(String serviceID, String req) throws Exception {
HashMap<String, String> para = new HashMap<String, String>();
para.put("op", "fr_remote_design");
para.put("cmd", "design_get_plugin_service_data");
para.put("serviceID", serviceID);
para.put("req", req);
HttpClient client = createHttpMethod(para); //jim :加上user,远程设计点击预览时传递用户角色信息
InputStream inputStream = execute4InputStream(client);
return IOUtils.inputStream2String(inputStream);
}
/**
* 远程不启动使用虚拟服务
* @param serviceID
*/
@Override
public void pluginServiceStart(String serviceID){
}
@Override @Override
public void checkAndRegisterLic(FileNode node, Plugin plugin) throws Exception { public void checkAndRegisterLic(FileNode node, Plugin plugin) throws Exception {
} }
} }

12
designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java

@ -94,6 +94,10 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
if(rowChart == null) { if(rowChart == null) {
continue; continue;
} }
//初始化图表模型图片
initChartsDemoImage(rowChart);
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID);
Icon icon = IOUtils.readIcon(iconPath); Icon icon = IOUtils.readIcon(iconPath);
child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]);
@ -101,6 +105,14 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
return child; return child;
} }
private static void initChartsDemoImage(Chart[] rowChart) {
int rowChartsCount = rowChart.length;
for (int j = 0; j < rowChartsCount; j++) {
//此时,为图片生成模型数据
rowChart[j].createSlotImage();
}
}
private synchronized static void envChanged() { private synchronized static void envChanged() {
classManager = null; classManager = null;
} }

2
designer_chart/src/com/fr/design/chart/gui/ChartComponent.java

@ -316,7 +316,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
//不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单 //不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单
//其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边 //其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边
Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution()); Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution());
g2d.drawImage(chartImage, 0, 0, chartWidth, chartHeight, null); g2d.drawImage(chartImage, 0, 0, null);
} }
} }

36
designer_form/src/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java

@ -1,38 +1,31 @@
package com.fr.design.designer.beans.adapters.component; package com.fr.design.designer.beans.adapters.component;
import java.awt.AlphaComposite;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.gui.xtable.PropertyGroupModel;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.actions.ChangeNameAction; import com.fr.design.designer.beans.actions.ChangeNameAction;
import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.xtable.PropertyGroupModel;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Button; import com.fr.form.ui.Button;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
public class CompositeComponentAdapter implements ComponentAdapter { public class CompositeComponentAdapter implements ComponentAdapter {
@ -81,7 +74,8 @@ public class CompositeComponentAdapter implements ComponentAdapter {
} }
//底层布局或者是自适应布局都不能删除 //底层布局或者是自适应布局都不能删除
boolean isRootComponent = ComponentUtils.isRootComponent(xCreator) || designer.isRoot(xCreator); boolean isRootComponent = ComponentUtils.isRootComponent(xCreator) || designer.isRoot(xCreator);
changeVarNameAction.setEnabled(!isRootComponent); //bug103155 有的布局的重命名(tab布局)涉及到其他非子节点的属性修改,支持起来比较麻烦,先屏蔽了控件树面板的修改,强制使用属性面板修改
changeVarNameAction.setEnabled(!isRootComponent && xCreator.supportRenameInWidgetTree());
popupMenu.add(changeVarNameAction); popupMenu.add(changeVarNameAction);
Action[] actions = designer.getActions(); Action[] actions = designer.getActions();

3
designer_form/src/com/fr/design/designer/beans/painters/FRFitLayoutPainter.java

@ -107,10 +107,9 @@ public class FRFitLayoutPainter extends AbstractPainter{
// 下边缘 // 下边缘
Rectangle bottomEdge = new Rectangle(containerX, bottomY, containerWidth, BORDER_PROPORTION); Rectangle bottomEdge = new Rectangle(containerX, bottomY, containerWidth, BORDER_PROPORTION);
if(bottomEdge.intersects(currentXY)){ if(bottomEdge.intersects(currentXY)){
hotspot_bounds.y -= WCardMainBorderLayout.TAB_HEIGHT/2; hotspot_bounds.y += (container.getHeight() - WCardMainBorderLayout.TAB_HEIGHT)/2;
hot_rec[WIDTH] = container.getWidth(); hot_rec[WIDTH] = container.getWidth();
hot_rec[HEIGHT] = (container.getHeight() + WCardMainBorderLayout.TAB_HEIGHT)/2; hot_rec[HEIGHT] = (container.getHeight() + WCardMainBorderLayout.TAB_HEIGHT)/2;
accept = false;
} }
//左右边缘的高度 -10*2 是为了不和上下边缘重合 //左右边缘的高度 -10*2 是为了不和上下边缘重合

9
designer_form/src/com/fr/design/designer/creator/XCreator.java

@ -544,4 +544,13 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[0]; return new WidgetPropertyUIProvider[0];
} }
/**
* 控件树面板中是否支持重命名选项
*
* @return 控件树面板中是否支持重命名选项
*/
public boolean supportRenameInWidgetTree() {
return true;
}
} }

2
designer_form/src/com/fr/design/designer/creator/XWFitLayout.java

@ -53,6 +53,8 @@ public class XWFitLayout extends XLayoutContainer {
super(widget, initSize); super(widget, initSize);
initPercent(); initPercent();
widget.setResolutionScaling(containerPercent);
} }
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90% //根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%

30
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -3,33 +3,17 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ContainerEvent;
import java.beans.IntrospectionException;
import javax.swing.border.Border;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRCardLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRCardLayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.CRPropertyDescriptor; 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.XWidgetCreator;
import com.fr.design.form.layout.FRCardLayout; import com.fr.design.form.layout.FRCardLayout;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.widget.editors.CardTagWLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.editors.CardTagWLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer;
import com.fr.form.ui.CardAddButton; import com.fr.form.ui.*;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
@ -41,6 +25,11 @@ import com.fr.general.Inter;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.ContainerEvent;
import java.beans.IntrospectionException;
/** /**
* @author richer * @author richer
* @since 6.5.3 * @since 6.5.3
@ -379,4 +368,9 @@ public class XWCardLayout extends XLayoutContainer {
public XLayoutContainer getTopLayout() { public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout(); return this.getBackupParent().getTopLayout();
} }
@Override
public boolean supportRenameInWidgetTree() {
return false;
}
} }
Loading…
Cancel
Save