Browse Source

Merge pull request #1720 in BA/design from ~YAOH.WU/a_design_0811:release/9.0 to release/9.0

* commit '15a732e1480df8fd23f874470529c1eb1b010bba':
  REPORT-6973 模板短信事件 插件设计器接口
superman 7 years ago
parent
commit
8d50617e5b
  1. 320
      designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java
  2. 2
      designer/src/com/fr/start/Designer.java
  3. 17
      designer_base/src/com/fr/design/extra/LoginDialog.java
  4. 53
      designer_base/src/com/fr/design/extra/WebViewDlgHelper.java

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

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package com.fr.design.mainframe.bbs; package com.fr.design.mainframe.bbs;
@ -27,157 +27,175 @@ import java.util.Date;
/** /**
* @author neil * @author neil
*
* @date: 2015-3-5-上午11:19:50 * @date: 2015-3-5-上午11:19:50
*/ */
public class UserInfoPane extends BasicPane{ public class UserInfoPane extends BasicPane {
//默认未登录颜色 /**
private static final Color UN_LOGIN_BACKGROUND = UIConstants.TEMPLATE_TAB_PANE_BACKGROUND; * 默认未登录颜色
private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242); */
private static final int WIDTH = 104; private static final Color UN_LOGIN_BACKGROUND = UIConstants.TEMPLATE_TAB_PANE_BACKGROUND;
private static final int HEIGHT = 24; private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242);
private static final int WIDTH = 104;
//登录成功 private static final int HEIGHT = 24;
private static final String LOGININ = "0";
/**
// 登录框弹出间隔时间 * 登录成功
private static final int LOGIN_DIFF_DAY = 7; */
// 等待国际化等相关初始化工作完成之后再弹出登录框 private static final String LOGININ = "0";
private static final int WAIT_TIME = 10000;
/**
private UserInfoLabel userInfoLabel; * 登录框弹出间隔时间
*/
private static final int LOGIN_DIFF_DAY = 7;
public UserInfoLabel getUserInfoLabel() { /**
return userInfoLabel; * 等待国际化等相关初始化工作完成之后再弹出登录框
} */
private static final int WAIT_TIME = 10000;
public void setUserInfoLabel(UserInfoLabel userInfoLabel) {
this.userInfoLabel = userInfoLabel; private UserInfoLabel userInfoLabel;
}
private static UserInfoPane instance = new UserInfoPane();
/**
* 构造函数
*/ public static UserInfoPane getInstance() {
public UserInfoPane() { return instance;
this.setPreferredSize(new Dimension(WIDTH,HEIGHT)); }
this.setLayout(new BorderLayout());
/**
this.userInfoLabel = new UserInfoLabel(this); * 构造函数
*/
this.markUnSignIn(); private UserInfoPane() {
addEnvChangedListener(); this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
autoPushLoginDialog(); this.setLayout(new BorderLayout());
this.add(userInfoLabel, BorderLayout.CENTER); this.userInfoLabel = new UserInfoLabel(this);
}
this.markUnSignIn();
private void addEnvChangedListener(){ addEnvChangedListener();
GeneralContext.addEnvChangedListener(new EnvChangedListener() { autoPushLoginDialog();
@Override
public void envChanged() { this.add(userInfoLabel, BorderLayout.CENTER);
String username = ConfigManager.getProviderInstance().getBbsUsername(); }
if (StringUtils.isEmpty(username)){
markUnSignIn(); public UserInfoLabel getUserInfoLabel() {
} else { return userInfoLabel;
markSignIn(username); }
}
} public void setUserInfoLabel(UserInfoLabel userInfoLabel) {
}); this.userInfoLabel = userInfoLabel;
} }
// 计算xml保存的上次弹框时间和当前时间的时间差 /**
private int getDiffFromLastLogin(){ * 标志未登录状态, 面板设置为灰色
String lastBBSTime = DesignerEnvManager.getEnvManager().getLastShowBBSTime(); */
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); public void markUnSignIn() {
Date lastBBSDate = null; this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
try { this.userInfoLabel.setOpaque(true);
if(lastBBSTime != null){ this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND);
synchronized (this) { this.userInfoLabel.resetUserName();
lastBBSDate = sdf.parse(lastBBSTime); }
}
Calendar calender = Calendar.getInstance(); /**
calender.setTime(lastBBSDate); * 标志登陆状态, 面包设置为蓝色
int dayOld = calender.get(Calendar.DAY_OF_YEAR); *
calender.setTime(new Date()); * @param userName 用户名
int dayNew = calender.get(Calendar.DAY_OF_YEAR); */
return dayNew - dayOld; public void markSignIn(String userName) {
} this.userInfoLabel.setText(userName);
} catch (ParseException e) { this.userInfoLabel.setUserName(userName);
FRLogger.getLogger().error(e.getMessage()); this.userInfoLabel.setOpaque(true);
} this.userInfoLabel.setBackground(LOGIN_BACKGROUND);
return 1; }
}
@Override
private void autoPushLoginDialog(){ protected String title4PopupWindow() {
Thread showBBSThread = new Thread(new Runnable() { return StringUtils.EMPTY;
}
@Override
public void run() { private void addEnvChangedListener() {
try { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
// 等国际化等加载完毕再启动线程弹出登录框 @Override
Thread.sleep(WAIT_TIME); public void envChanged() {
if(!FRContext.isChineseEnv()){ String username = ConfigManager.getProviderInstance().getBbsUsername();
return; if (StringUtils.isEmpty(username)) {
} markUnSignIn();
} else {
//七天弹一次, 如果xml中和当前时间相差小于7天, 就不弹了 markSignIn(username);
if(getDiffFromLastLogin() < LOGIN_DIFF_DAY){ }
return; }
} });
}
} catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage());
} /**
* 计算xml保存的上次弹框时间和当前时间的时间差
String userName = ConfigManager.getProviderInstance().getBbsUsername(); *
if(StringUtils.isNotEmpty(userName)){ * @return 时间差
return; */
} private int getDiffFromLastLogin() {
String lastBBSTime = DesignerEnvManager.getEnvManager().getLastShowBBSTime();
BBSLoginDialog bbsLoginDialog = userInfoLabel.getBbsLoginDialog(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if(bbsLoginDialog == null){ Date lastBBSDate;
bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(),userInfoLabel); try {
userInfoLabel.setBbsLoginDialog(bbsLoginDialog); if (lastBBSTime != null) {
} synchronized (this) {
lastBBSDate = sdf.parse(lastBBSTime);
bbsLoginDialog.showWindow(); }
DesignerEnvManager.getEnvManager().setLastShowBBSTime(DateUtils.DATEFORMAT2.format(new Date())); Calendar calender = Calendar.getInstance();
} calender.setTime(lastBBSDate);
int dayOld = calender.get(Calendar.DAY_OF_YEAR);
}); calender.setTime(new Date());
showBBSThread.start(); int dayNew = calender.get(Calendar.DAY_OF_YEAR);
} return dayNew - dayOld;
}
/** } catch (ParseException e) {
* 标志未登录状态, 面板设置为灰色 FRLogger.getLogger().error(e.getMessage());
* }
*/ return 1;
public void markUnSignIn(){ }
this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
this.userInfoLabel.setOpaque(true); private void autoPushLoginDialog() {
this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND); Thread showBBSThread = new Thread(new Runnable() {
this.userInfoLabel.resetUserName();
} @Override
public void run() {
/** try {
* 标志登陆状态, 面包设置为蓝色 // 等国际化等加载完毕再启动线程弹出登录框
* @param userName 用户名 Thread.sleep(WAIT_TIME);
* if (!FRContext.isChineseEnv()) {
*/ return;
public void markSignIn(String userName){ }
this.userInfoLabel.setText(userName);
this.userInfoLabel.setUserName(userName); //七天弹一次, 如果xml中和当前时间相差小于7天, 就不弹了
this.userInfoLabel.setOpaque(true); if (getDiffFromLastLogin() < LOGIN_DIFF_DAY) {
this.userInfoLabel.setBackground(LOGIN_BACKGROUND); return;
} }
@Override } catch (InterruptedException e) {
protected String title4PopupWindow() { FRContext.getLogger().error(e.getMessage());
return StringUtils.EMPTY; }
}
String userName = ConfigManager.getProviderInstance().getBbsUsername();
if (StringUtils.isNotEmpty(userName)) {
return;
}
BBSLoginDialog bbsLoginDialog = userInfoLabel.getBbsLoginDialog();
if (bbsLoginDialog == null) {
bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(), userInfoLabel);
userInfoLabel.setBbsLoginDialog(bbsLoginDialog);
}
bbsLoginDialog.showWindow();
DesignerEnvManager.getEnvManager().setLastShowBBSTime(DateUtils.DATEFORMAT2.format(new Date()));
}
});
showBBSThread.start();
}
} }

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

@ -364,7 +364,7 @@ public class Designer extends BaseDesigner {
@Override @Override
public Component createBBSLoginPane() { public Component createBBSLoginPane() {
if (userInfoPane == null) { if (userInfoPane == null) {
userInfoPane = new UserInfoPane(); userInfoPane = UserInfoPane.getInstance();
} }
return userInfoPane; return userInfoPane;
} }

17
designer_base/src/com/fr/design/extra/LoginDialog.java

@ -4,8 +4,12 @@ import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import javax.swing.*; import javax.swing.JPanel;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
/** /**
* Created by vito on 2017/5/5. * Created by vito on 2017/5/5.
@ -15,6 +19,15 @@ public class LoginDialog extends UIDialog {
public LoginDialog(Frame frame, Component pane) { public LoginDialog(Frame frame, Component pane) {
super(frame); super(frame);
init(pane);
}
public LoginDialog(Dialog dialog, Component pane) {
super(dialog);
init(pane);
}
private void init(Component pane) {
if (StableUtils.getMajorJavaVersion() == 8) { if (StableUtils.getMajorJavaVersion() == 8) {
setUndecorated(true); setUndecorated(true);
} }

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

@ -22,6 +22,9 @@ import javax.swing.JOptionPane;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -133,18 +136,22 @@ public class WebViewDlgHelper {
if (StableUtils.getMajorJavaVersion() == VERSION_8) { if (StableUtils.getMajorJavaVersion() == VERSION_8) {
File file = new File(StableUtils.pathJoin(installHome, "scripts")); File file = new File(StableUtils.pathJoin(installHome, "scripts"));
if (!file.exists()) { if (!file.exists()) {
int rv = JOptionPane.showConfirmDialog( confirmDownLoadShopJS();
null,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts(SHOP_SCRIPTS);
}
} else { } else {
showLoginDlg(); showLoginDlg(DesignerContext.getDesignerFrame());
updateShopScripts(SHOP_SCRIPTS);
}
}
}
public static void createLoginDialog(Window parent) {
if (StableUtils.getMajorJavaVersion() == VERSION_8) {
File file = new File(StableUtils.pathJoin(installHome, "scripts"));
if (!file.exists()) {
confirmDownLoadShopJS();
} else {
showLoginDlg(parent);
updateShopScripts(SHOP_SCRIPTS); updateShopScripts(SHOP_SCRIPTS);
} }
} }
@ -164,6 +171,20 @@ public class WebViewDlgHelper {
} }
} }
private static void confirmDownLoadShopJS() {
int rv = JOptionPane.showConfirmDialog(
null,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts(SHOP_SCRIPTS);
}
}
private static void showPluginDlg(String mainJsPath) { private static void showPluginDlg(String mainJsPath) {
try { try {
Class<?> clazz = Class.forName("com.fr.design.extra.PluginWebPane"); Class<?> clazz = Class.forName("com.fr.design.extra.PluginWebPane");
@ -179,13 +200,17 @@ public class WebViewDlgHelper {
} }
} }
private static void showLoginDlg() { private static void showLoginDlg(Window window) {
try { try {
Class<?> clazz = Class.forName("com.fr.design.extra.LoginWebPane"); Class<?> clazz = Class.forName("com.fr.design.extra.LoginWebPane");
Constructor constructor = clazz.getConstructor(String.class); Constructor constructor = clazz.getConstructor(String.class);
Component webPane = (Component) constructor.newInstance(installHome); Component webPane = (Component) constructor.newInstance(installHome);
UIDialog qqdlg;
UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), webPane); if (window instanceof Dialog) {
qqdlg = new LoginDialog((Dialog) window, webPane);
} else {
qqdlg = new LoginDialog((Frame) window, webPane);
}
LoginWebBridge.getHelper().setDialogHandle(qqdlg); LoginWebBridge.getHelper().setDialogHandle(qqdlg);
qqdlg.setVisible(true); qqdlg.setVisible(true);
} catch (Throwable ignored) { } catch (Throwable ignored) {

Loading…
Cancel
Save