Browse Source

Merge branch 'dev' of ssh://www.finedevelop.com:7999/~loy/design_fr into dev

master
loy 8 years ago
parent
commit
88dc3a8fe7
  1. 2
      designer/src/com/fr/design/mainframe/bbs/LoginDialog.java
  2. 24
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  3. 11
      designer/src/com/fr/design/report/ValueVerifierEditPane.java
  4. 13
      designer_base/src/com/fr/design/extra/LoginPane.java
  5. 26
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  6. 2
      designer_base/src/com/fr/design/extra/LoginWebPane.java
  7. 67
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  8. 41
      designer_base/src/com/fr/design/extra/QQLoginWebBridge.java
  9. 34
      designer_base/src/com/fr/design/extra/QQLoginWebPane.java
  10. 5
      designer_base/src/com/fr/design/extra/exe/GetLoginInfoExecutor.java
  11. 68
      designer_base/src/com/fr/design/gui/itableeditorpane/UIArrayFormulaTableModel.java
  12. 8
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.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.
*/
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) {
super(frame);

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

@ -54,7 +54,7 @@ public class UserInfoLabel extends UILabel{
private UserInfoPane userInfoPane;
private BBSLoginDialog bbsLoginDialog;
public UserInfoPane getUserInfoPane() {
return userInfoPane;
}
@ -92,6 +92,9 @@ public class UserInfoLabel extends UILabel{
}
});
PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
QQLoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this);
UserLoginContext.addLoginContextListener(new LoginContextListener() {
@Override
public void showLoginContext() {
@ -101,9 +104,19 @@ public class UserInfoLabel extends UILabel{
LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
QQLoginWebBridge.getHelper().setLoginlabel();
qqdlg.setVisible(true);
clearLoginInformation();
updateInfoPane();
}
});
}
private void clearLoginInformation(){
DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY);
DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY);
}
private void updateInfoPane(){
userInfoPane.markUnSignIn();
}
/**
@ -117,9 +130,7 @@ public class UserInfoLabel extends UILabel{
if(!FRContext.isChineseEnv()){
return;
}
String lastBBSNewsTime = DesignerEnvManager.getEnvManager().getLastShowBBSNewsTime();
try {
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
if (ComparatorUtils.equals(lastBBSNewsTime, today)) {
@ -129,25 +140,20 @@ public class UserInfoLabel extends UILabel{
} catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage());
}
HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.popup"));
if (!hc.isServerAlive()){
return;
}
String res = hc.getResponseText();
if (res.indexOf(BBSConstants.UPDATE_KEY) == -1){
return;
}
try {
BBSDialog bbsLabel = new BBSDialog(DesignerContext.getDesignerFrame());
bbsLabel.showWindow(SiteCenter.getInstance().acquireUrlByKind("bbs.popup"));
DesignerEnvManager.getEnvManager().setLastShowBBSNewsTime(DateUtils.DATEFORMAT2.format(new Date()));
} catch (Throwable e) {
}
}
});
showBBSThread.start();
@ -259,6 +265,7 @@ public class UserInfoLabel extends UILabel{
@Override
public void mouseClicked(MouseEvent e) {
userName = DesignerEnvManager.getEnvManager().getBBSName();
if(StringUtils.isNotEmpty(userName)) {
UIPopupMenu menu = new UIPopupMenu();
menu.setOnlyText(true);
@ -295,5 +302,4 @@ public class UserInfoLabel extends UILabel{
}
}
};
}

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.data.VerifyItem;
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.layout.FRGUIPaneFactory;
import com.fr.general.GeneralUtils;
import com.fr.general.Inter;
import com.fr.report.write.ValueVerifier;
import com.fr.stable.FormulaProvider;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
@ -23,7 +24,7 @@ public class ValueVerifierEditPane extends JPanel {
public ValueVerifierEditPane() {
// ben:UITableEditorPane;
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.MOVEUPSTYLE, ActionStyle.MOVEDOWNSTYLE}));
this.add(tableEditorPane, BorderLayout.CENTER);
@ -45,7 +46,11 @@ public class ValueVerifierEditPane extends JPanel {
if (formula == null) {
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);
}

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.RestartHelper;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
@ -53,6 +54,7 @@ public class LoginPane extends BasicPane {
}
}
} else {
initTraditionalStore();
}
}
@ -91,7 +93,6 @@ public class LoginPane extends BasicPane {
@Override
protected void done() {
try {
if (get()) {
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) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
@ -140,4 +140,13 @@ public class LoginPane extends BasicPane {
}
}.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));
}
}

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

@ -28,7 +28,7 @@ public class LoginWebBridge {
private static final String LOGININ = "0";
private static final String LOGIN_INFO_EMPTY = "-1";
private static final String DISCONNECTED = "-2";
private static final String UNKNOWN_ERROR = "-3";
private static final String LOGININFO_ERROR = "-3";
private static final int TIME_OUT = 10000;
private static com.fr.design.extra.LoginWebBridge helper;
@ -80,7 +80,7 @@ public class LoginWebBridge {
*/
public void registerHref() {
try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default")));
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.register")));
}catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
}
@ -115,7 +115,26 @@ public class LoginWebBridge {
loginSuccess(username);
return LOGININ;
}else {
return UNKNOWN_ERROR;
return LOGININFO_ERROR;
}
}
/*
插件管理那边的登录
*/
public String pluginManageLogin(String username, String password, UILabel uiLabel) {
if (!StringUtils.isNotBlank(username) && !StringUtils.isNotBlank(password)) {
return LOGIN_INFO_EMPTY;
}
if (!testConnection()) {
return DISCONNECTED;
}
if (login(username, password)) {
updateUserInfo(username, password);
uiLabel.setText(username);
return LOGININ;
}else {
return LOGININFO_ERROR;
}
}
@ -126,6 +145,7 @@ public class LoginWebBridge {
if (uiDialog != null) {
uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
uiDialog.setVisible(false);
uiDialog.dispose();
}
}

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

@ -31,7 +31,7 @@ public class LoginWebPane extends JFXPanel {
LoginWebPane.this.setScene(scene);
WebView webView = new WebView();
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>>() {
@Override
public void handle(WebEvent<String> event) {

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

@ -1,9 +1,11 @@
package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.*;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
@ -41,6 +43,13 @@ public class PluginWebBridge {
private String KEYWORD = "keyword";
private Map<String, Object> config;
private static final String LOGININ = "0";
private static final String LOGIN_INFO_EMPTY = "-1";
private static final String DISCONNECTED = "-2";
private static final String LOGININFO_ERROR = "-3";
private UILabel uiLabel;
/**
* 动作枚举
*/
@ -394,10 +403,6 @@ public class PluginWebBridge {
});
}
public void getUsername() {
}
/**
* 在本地浏览器里打开url
* tips:重载的时候,需要给js调用的方法需要放在前面,否则可能不会被调用(此乃坑)
@ -490,4 +495,58 @@ public class PluginWebBridge {
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);
uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn"));
}
}

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

@ -3,10 +3,15 @@ package com.fr.design.extra;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRLogger;
import com.fr.general.SiteCenter;
import javafx.scene.web.WebEngine;
import org.json.JSONObject;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
/**
* Created by lp on 2016/8/10.
@ -19,6 +24,7 @@ public class QQLoginWebBridge {
private static String LOGINFAILED = "failed";
private UIDialog uiDialog;
private UILabel uiLabel;
private UILabel pluginuiLabel;
private UIDialog qqDialog;
private String username;
@ -54,6 +60,10 @@ public class QQLoginWebBridge {
this.uiLabel = uiLabel;
}
public void setUILabelInPlugin(UILabel uiLabel) {
this.pluginuiLabel = uiLabel;
}
public void setLoginlabel() {
username = DesignerEnvManager.getEnvManager().getBBSName();
}
@ -95,11 +105,40 @@ public class QQLoginWebBridge {
String username = jo.get("username").toString();
closeQQWindow();
closeParentWindow();
uiLabel.setText(username);
pluginuiLabel.setText(username);
DesignerEnvManager.getEnvManager().setBBSName(username);
}else if (status.equals(LOGINFAILED)){
//账号没有QQ授权
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());
}
}
}
}

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

@ -1,6 +1,11 @@
package com.fr.design.extra;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.SiteCenter;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Scene;
@ -29,7 +34,18 @@ public class QQLoginWebPane extends JFXPanel {
QQLoginWebPane.this.setScene(scene);
WebView webView = new WebView();
webEngine = webView.getEngine();
webEngine.load("file:///" + installHome + "/scripts/store/web/qqLogin.html");
webEngine.load("file:///" + installHome + "/scripts/qqLogin/web/qqLogin.html");
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>>() {
@Override
public void handle(WebEvent<String> event) {
@ -52,4 +68,20 @@ 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());
}
}
}

5
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.extra.Process;
import com.fr.stable.StringUtils;
/**
* Created by lp on 2016/8/16.
@ -26,7 +27,7 @@ public class GetLoginInfoExecutor implements Executor {
@Override
public void run(Process<String> process) {
String username = DesignerEnvManager.getEnvManager().getBBSName();
if (username == null) {
if (StringUtils.isEmpty(username)) {
}else {
result = username;
}
@ -34,4 +35,4 @@ public class GetLoginInfoExecutor implements Executor {
}
};
}
}
}

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

8
designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -284,7 +284,7 @@ public abstract class ToolBarMenuDock {
return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction();
}
private boolean shouldShowPlugin() {
protected boolean shouldShowPlugin() {
return FRContext.isChineseEnv() || ComparatorUtils.equals(GeneralContext.getLocale(), Locale.TAIWAN);
}
@ -326,7 +326,8 @@ public abstract class ToolBarMenuDock {
shortCuts.add(new SignAction());
return shortCuts.toArray(new ShortCut[shortCuts.size()]);
}
private MenuDef createHelpMenuDef() {
public MenuDef createHelpMenuDef() {
MenuDef menuDef = new MenuDef(Inter.getLocText("FR-Designer_Help"), 'H');
ShortCut[] otherHelpShortCuts = createHelpShortCuts();
for (ShortCut shortCut : otherHelpShortCuts) {
@ -335,7 +336,8 @@ public abstract class ToolBarMenuDock {
insertMenu(menuDef, MenuHandler.HELP);
return menuDef;
}
private MenuDef createCommunityMenuDef() {
public MenuDef createCommunityMenuDef() {
MenuDef menuDef = new MenuDef(Inter.getLocText("FR-Designer_COMMUNITY"), 'C');
ShortCut[] otherCommunityShortCuts = createCommunityShortCuts();
for (ShortCut shortCut : otherCommunityShortCuts) {

Loading…
Cancel
Save