kerry 8 years ago
parent
commit
ee4e1c77c1
  1. 56
      designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java
  2. 9
      designer_base/src/com/fr/design/actions/server/PluginManagerAction.java
  3. 53
      designer_base/src/com/fr/design/actions/server/ReuseManagerAction.java
  4. 5
      designer_base/src/com/fr/design/data/datapane/connect/JDBCDefPane.java
  5. 3
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  6. 4
      designer_base/src/com/fr/design/extra/PluginWebPane.java
  7. 36
      designer_base/src/com/fr/design/extra/ReuseWebBridge.java
  8. 54
      designer_base/src/com/fr/design/extra/ReuseWebPane.java
  9. 10
      designer_base/src/com/fr/design/extra/ShopDialog.java
  10. 56
      designer_base/src/com/fr/design/extra/ShopManagerPane.java
  11. 24
      designer_base/src/com/fr/design/extra/ShopPaneConfig.java
  12. 99
      designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java
  13. 51
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  14. 9
      designer_base/src/com/fr/start/BaseDesigner.java

56
designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java

@ -10,9 +10,10 @@ import javax.swing.event.ChangeListener;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.PluginManagerPane;
import com.fr.design.extra.PluginShopDialog;
import com.fr.design.extra.ShopManagerPane;
import com.fr.design.extra.ShopDialog;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.WebManagerPaneFactory;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
@ -65,7 +66,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
/**
* 重复标题行
*/
private JPanel initRowStartPane(){
private JPanel initRowStartPane() {
JPanel soverlapRowStartPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
useRepeatTitleRCheckBox = new UICheckBox();
soverlapRowStartPane.add(useRepeatTitleRCheckBox);
@ -79,7 +80,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
/**
* 重复标题列
*/
private JPanel initColStartPane(){
private JPanel initColStartPane() {
// 重复打印标题的起始列
JPanel soverlapColStartPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
useRepeatTitleCCheckBox = new UICheckBox();
@ -95,7 +96,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
/**
* 重复结尾行
*/
private JPanel initFootRowStarPane(){
private JPanel initFootRowStarPane() {
// 重复打印结尾的起始行
JPanel foverlapRowStartPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
useRepeatFinisRCheckBox = new UICheckBox();
@ -110,7 +111,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
/**
* 重复结尾列
*/
private JPanel initFootColStartPane(){
private JPanel initFootColStartPane() {
// 重复打印结尾的起始列
JPanel foverlapColStartPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
useRepeatFinisCCheckBox = new UICheckBox();
@ -126,19 +127,16 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
* 获取分页冻结的标题(表单中不需要写分页二字)
*
* @return 分页冻结的标题
*
*
* @date 2014-11-14-下午1:32:08
*
*/
protected String getPageFrozenTitle(){
protected String getPageFrozenTitle() {
return Inter.getLocText("FR-Engine_Page-Frozen");
}
/**
* 分页冻结Pane
*/
private JPanel initPageFrozenPane(){
private JPanel initPageFrozenPane() {
JPanel pagePanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 分页冻结
UILabel pageLabel = new UILabel(getPageFrozenTitle());
@ -166,7 +164,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
/**
* 分页冻结列
*/
private void addPageFrozenCol(JPanel pagecon){
private void addPageFrozenCol(JPanel pagecon) {
// 显示列冻结信息的panel
freezePageColPane = new FreezePagePane(false);
JPanel pageColGridPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -178,7 +176,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
/**
* 填报冻结Pane
*/
private JPanel initWriteFrozenPane(){
private JPanel initWriteFrozenPane() {
JPanel writePanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 填报冻结
UILabel writeLabel = new UILabel(Inter.getLocText(new String[]{"Face_Write", "Frozen"}) + ":");
@ -248,14 +246,14 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
initWriteListener();
}
protected void initWriteListener(){
protected void initWriteListener() {
// 填报重复冻结行
useWriteFrozenCCheckBox.addChangeListener(useWriteFrozenCListener);
// 填报重复冻结列
useWriteFrozenRCheckBox.addChangeListener(useWriteFrozenRListener);
}
private void initPageRwoListener(){
private void initPageRwoListener() {
repeatTitleRowPane.addListener(freezePageRowListener);
// 分页重复冻结行
usePageFrozenRCheckBox.addChangeListener(usePageFrozenRListener);
@ -265,7 +263,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
useRepeatFinisRCheckBox.addChangeListener(useRepeatFinisRListener);
}
protected void initPageColListener(){
protected void initPageColListener() {
repeatTitleColPane.addListener(freezePageColListener);
// 分页重复冻结列
usePageFrozenCCheckBox.addChangeListener(usePageFrozenCListener);
@ -279,11 +277,11 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
freezePanel.add(initWriteFrozenPane(), BorderLayout.CENTER);
}
protected void addFootColStart(JPanel repeatPanel){
protected void addFootColStart(JPanel repeatPanel) {
repeatPanel.add(initFootColStartPane());
}
protected void addColStart(JPanel repeatPanel){
protected void addColStart(JPanel repeatPanel) {
repeatPanel.add(initColStartPane());
}
@ -390,9 +388,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
/**
* 窗口标题
*
*
* @date 2014-11-14-下午2:30:58
*
*/
protected String title4PopupWindow() {
return Inter.getLocText("FR-Engine_Repeat-Freeze");
@ -408,7 +404,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
populateRowPane(attribute, defaultFT);
}
protected void populateRowPane(ReportPageAttrProvider attribute, FT defaultFT){
protected void populateRowPane(ReportPageAttrProvider attribute, FT defaultFT) {
FT ft = new FT(new Integer(attribute.getRepeatHeaderRowFrom()), new Integer(attribute.getRepeatHeaderRowTo()));
if (isDefalut(ft)) {
this.repeatTitleRowPane.populateBean(defaultFT);
@ -433,7 +429,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
this.freezePageRowPane.setEnabled(attribute.isUsePageFrozenRow());
}
protected void populatColPane(ReportPageAttrProvider attribute, FT defaultFT){
protected void populatColPane(ReportPageAttrProvider attribute, FT defaultFT) {
FT ft = new FT(new Integer(attribute.getRepeatHeaderColumnFrom()), new Integer(attribute.getRepeatHeaderColumnTo()));
if (isDefalut(ft)) {
this.repeatTitleColPane.populateBean(defaultFT);
@ -466,10 +462,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
* 初始化填报冻结pane
*
* @param writeFrozenColumnRow 填报冻结格子
*
*
* @date 2014-11-14-下午2:30:15
*
*/
public void populateWriteFrozenColumnRow(ColumnRow writeFrozenColumnRow) {
if (writeFrozenColumnRow != null) {
@ -503,7 +496,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
return attribute;
}
protected void updateRowPane(ReportPageAttrProvider attribute){
protected void updateRowPane(ReportPageAttrProvider attribute) {
// 重复标题行
int titleFrom = valid(useRepeatTitleRCheckBox, this.repeatTitleRowPane.updateBean().getFrom());
int titleTo = valid(useRepeatTitleRCheckBox, this.repeatTitleRowPane.updateBean().getTo());
@ -518,11 +511,11 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
attribute.setUsePageFrozenRow(this.usePageFrozenRCheckBox.isSelected());
}
private int valid(UICheckBox checkBox, int num){
private int valid(UICheckBox checkBox, int num) {
return checkBox.isSelected() ? num : -1;
}
protected void updateColPane(ReportPageAttrProvider attribute){
protected void updateColPane(ReportPageAttrProvider attribute) {
int titleFrom = valid(useRepeatTitleCCheckBox, this.repeatTitleColPane.updateBean().getFrom());
int titleTo = valid(useRepeatTitleCCheckBox, this.repeatTitleColPane.updateBean().getTo());
attribute.setRepeatHeaderColumnFrom(titleFrom);
@ -540,10 +533,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
* 更新WriteFrozenColumnRow
*
* @return 行列
*
*
* @date 2014-11-14-下午2:29:45
*
*/
public ColumnRow updateWriteFrozenColumnRow() {
if (useWriteFrozenCCheckBox.isSelected() || useWriteFrozenRCheckBox.isSelected()) {
@ -562,8 +552,8 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
public void actionPerformed(ActionEvent e) {
try {
//Desktop.getDesktop().browse(new URI(url));
final PluginManagerPane managerPane = new PluginManagerPane();
UIDialog dlg = new PluginShopDialog(DesignerContext.getDesignerFrame(),managerPane);
BasicPane managerPane = new WebManagerPaneFactory().createPluginPane();
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
RepeatAndFreezeSettingPane.this.getTopLevelAncestor().setVisible(false);

9
designer_base/src/com/fr/design/actions/server/PluginManagerAction.java

@ -2,10 +2,11 @@ package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.PluginManagerPane;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.PluginShopDialog;
import com.fr.design.extra.ShopDialog;
import com.fr.design.extra.WebManagerPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
@ -29,8 +30,8 @@ public class PluginManagerAction extends UpdateAction {
@Override
public void actionPerformed(ActionEvent e) {
final PluginManagerPane managerPane = new PluginManagerPane();
UIDialog dlg = new PluginShopDialog(DesignerContext.getDesignerFrame(),managerPane);
BasicPane managerPane = new WebManagerPaneFactory().createPluginPane();
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
}

53
designer_base/src/com/fr/design/actions/server/ReuseManagerAction.java

@ -0,0 +1,53 @@
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.ShopDialog;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.WebManagerPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* Created by vito on 2016/9/27.
*/
public class ReuseManagerAction extends UpdateAction {
public ReuseManagerAction() {
this.setMenuKeySet(REUSE_MANAGER);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/server/plugin.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
BasicPane managerPane = new WebManagerPaneFactory().createReusePane();
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
}
public static final MenuKeySet REUSE_MANAGER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'R';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Designer-Reuse_Manager");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

5
designer_base/src/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -43,7 +43,8 @@ public class JDBCDefPane extends JPanel {
new DriverURLName("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:[PATH_TO_DB_FILES]"), new DriverURLName("com.inet.tds.TdsDriver", "jdbc:inetdae7:localhost:1433/"),
new DriverURLName("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"),
new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/")});
// jdbcMap.put("Hadoop Hive",new DriverURLName[]{new DriverURLName("org.apache.hadoop.hive.jdbc.HiveDriver","jdbc:hive://localhost:10000/default")});
jdbcMap.put("Inceptor",new DriverURLName[]{new DriverURLName("org.apache.hive.jdbc.HiveDriver","jdbc:inceptor2://localhost:10000/default"),
new DriverURLName("org.apache.hadoop.hive.jdbc.HiveDriver","jdbc:inceptor://localhost:10000/default")});
jdbcMap.put("Oracle", new DriverURLName[]{new DriverURLName("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@localhost:1521:databaseName")});
jdbcMap.put("DB2", new DriverURLName[]{new DriverURLName("com.ibm.db2.jcc.DB2Driver", "jdbc:db2://localhost:50000/")});
jdbcMap.put("SQL Server", new DriverURLName[]{new DriverURLName("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://localhost:1433;" + "databaseName=")});
@ -63,7 +64,7 @@ public class JDBCDefPane extends JPanel {
private UITextField userNameTextField;
private JPasswordField passwordTextField;
// 请不要改动dbtype,只应该最后添加
private final String[] dbtype = {"", "Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre","SQLite", "Others"};
private final String[] dbtype = {"", "Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre","SQLite","Inceptor", "Others"};
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();

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

@ -42,6 +42,7 @@ public class PluginWebBridge {
private String ACTION = "action";
private String KEYWORD = "keyword";
private Map<String, Object> config;
private WebEngine webEngine;
private UILabel uiLabel;
@ -79,8 +80,6 @@ public class PluginWebBridge {
return helper;
}
private WebEngine webEngine;
private PluginWebBridge() {
}

4
designer_base/src/com/fr/design/extra/PluginWebPane.java

@ -19,7 +19,7 @@ public class PluginWebPane extends JFXPanel {
private WebEngine webEngine;
public PluginWebPane(final String installHome) {
public PluginWebPane(final String mainJs) {
Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
@Override
@ -29,7 +29,7 @@ public class PluginWebPane extends JFXPanel {
PluginWebPane.this.setScene(scene);
WebView webView = new WebView();
webEngine = webView.getEngine();
webEngine.load("file:///" + installHome + "/scripts/store/web/index.html");
webEngine.load("file:///" + mainJs);
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> event) {

36
designer_base/src/com/fr/design/extra/ReuseWebBridge.java

@ -0,0 +1,36 @@
package com.fr.design.extra;
import javafx.scene.web.WebEngine;
/**
* Created by vito on 2016/9/28.
*/
public class ReuseWebBridge {
public static ReuseWebBridge helper;
private WebEngine webEngine;
public static ReuseWebBridge getHelper() {
if (helper != null) {
return helper;
}
synchronized (ReuseWebBridge.class) {
if (helper == null) {
helper = new ReuseWebBridge();
}
return helper;
}
}
public static ReuseWebBridge getHelper(WebEngine webEngine) {
getHelper();
helper.setEngine(webEngine);
return helper;
}
private ReuseWebBridge() {
}
public void setEngine(WebEngine webEngine) {
this.webEngine = webEngine;
}
}

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

@ -0,0 +1,54 @@
package com.fr.design.extra;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import netscape.javascript.JSObject;
import javax.swing.*;
/**
* Created by vito on 2016/9/28.
*/
public class ReuseWebPane extends JFXPanel {
private WebEngine webEngine;
public ReuseWebPane(final String mainJs) {
Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
@Override
public void run() {
BorderPane root = new BorderPane();
Scene scene = new Scene(root);
ReuseWebPane.this.setScene(scene);
WebView webView = new WebView();
webEngine = webView.getEngine();
webEngine.load("file:///" + mainJs);
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> event) {
showAlert(event.getData());
}
});
JSObject obj = (JSObject) webEngine.executeScript("window");
obj.setMember("ReuseHelper", ReuseWebBridge.getHelper(webEngine));
webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView);
}
});
}
private void showAlert(final String message) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(ReuseWebPane.this, message);
}
});
}
}

10
designer_base/src/com/fr/design/extra/PluginShopDialog.java → designer_base/src/com/fr/design/extra/ShopDialog.java

@ -3,8 +3,7 @@ package com.fr.design.extra;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import javafx.embed.swing.JFXPanel;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
@ -12,19 +11,20 @@ import java.awt.*;
/**
* Created by vito on 16/4/18.
*/
public class PluginShopDialog extends UIDialog {
public class ShopDialog extends UIDialog {
private static final Dimension DEFAULT_SHOP = new Dimension(900, 700);
public PluginShopDialog(Frame frame, BasicPane pane) {
public ShopDialog(Frame frame, BasicPane pane) {
super(frame);
if (StableUtils.getMajorJavaVersion() == 8) {
setUndecorated(true);
}
JPanel panel = (JPanel) getContentPane();
panel.setLayout(new BorderLayout());
add(pane, BorderLayout.CENTER);
setSize(DEFAULT_SHOP);
GUICoreUtils.centerWindow(this);
setResizable(false);
setTitle(Inter.getLocText("FR-Designer-Plugin_Manager"));
}
@Override

56
designer_base/src/com/fr/design/extra/PluginManagerPane.java → designer_base/src/com/fr/design/extra/ShopManagerPane.java

@ -4,7 +4,6 @@ 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;
@ -12,12 +11,12 @@ import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.plugin.PluginVerifyException;
import com.fr.stable.StableUtils;
import javafx.embed.swing.JFXPanel;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.ExecutionException;
/**
@ -31,21 +30,18 @@ import java.util.concurrent.ExecutionException;
* 因为如果直接嵌入WebView,和设计器的交互就需要预先设定好,这样灵活性会差很多,而如果使用JavaScript引擎,
* 就可以直接在JavaScript中和WebView组件做交互,而同时JavaScript中可以调用任何的设计器API.
*/
public class PluginManagerPane extends BasicPane {
public class ShopManagerPane extends BasicPane {
private static final String LATEST = "latest";
private ShopPaneConfig shopPaneConfig;
public PluginManagerPane() {
public ShopManagerPane(ShopPaneConfig shopPaneConfig) {
this.shopPaneConfig = shopPaneConfig;
setLayout(new BorderLayout());
if (StableUtils.getMajorJavaVersion() == 8) {
String installHome;
if (StableUtils.isDebug()) {
URL url = ClassLoader.getSystemResource("");
installHome = url.getPath();
addPane(installHome);
addPane();
} else {
installHome = StableUtils.getInstallHome();
File file = new File(StableUtils.pathJoin(installHome, "scripts"));
File file = new File(shopPaneConfig.getMainJS());
if (!file.exists()) {
int rv = JOptionPane.showConfirmDialog(
this,
@ -58,55 +54,31 @@ public class PluginManagerPane extends BasicPane {
downloadShopScripts();
}
} else {
addPane(installHome);
addPane();
updateShopScripts();
}
}
} else {
initTraditionalStore();
}
}
/**
* 以关键词打开设计器商店
*
* @param keyword 关键词
*/
public PluginManagerPane(String keyword) {
this();
PluginWebBridge.getHelper().openWithSearch(keyword);
}
private void addPane(String installHome) {
PluginWebPane webPane = new PluginWebPane(new File(installHome).getAbsolutePath());
private void addPane() {
JFXPanel webPane = shopPaneConfig.getWebPane();
add(webPane, BorderLayout.CENTER);
}
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));
}
private void downloadShopScripts() {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
String id = "shop_scripts";
String username = DesignerEnvManager.getEnvManager().getBBSName();
String password = DesignerEnvManager.getEnvManager().getBBSPassword();
try {
PluginHelper.downloadPluginFile(id, username, password, new Process<Double>() {
PluginHelper.downloadPluginFile(shopPaneConfig.getScriptsId(), username, password, new Process<Double>() {
@Override
public void process(Double integer) {
}
});
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(PluginManagerPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(ShopManagerPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
@ -122,7 +94,7 @@ public class PluginManagerPane extends BasicPane {
if (get()) {
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome());
int rv = JOptionPane.showOptionDialog(
PluginManagerPane.this,
ShopManagerPane.this,
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.YES_NO_OPTION,
@ -151,7 +123,7 @@ public class PluginManagerPane extends BasicPane {
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) {
int rv = JOptionPane.showConfirmDialog(
PluginManagerPane.this,
ShopManagerPane.this,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,

24
designer_base/src/com/fr/design/extra/ShopPaneConfig.java

@ -0,0 +1,24 @@
package com.fr.design.extra;
import javafx.embed.swing.JFXPanel;
/**
* Created by vito on 2016/9/28.
*/
public abstract class ShopPaneConfig {
private String mainJS;
private String scriptsId;
private JFXPanel webPane;
public ShopPaneConfig() {
this.mainJS = getMainJS();
this.scriptsId = getScriptsId();
this.webPane = getWebPane();
}
abstract String getMainJS();
abstract String getScriptsId();
abstract JFXPanel getWebPane();
}

99
designer_base/src/com/fr/design/extra/WebManagerPaneFactory.java

@ -0,0 +1,99 @@
package com.fr.design.extra;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.general.Inter;
import com.fr.stable.StableUtils;
import javafx.embed.swing.JFXPanel;
import java.awt.*;
import java.io.File;
import java.net.URL;
/**
* Created by vito on 2016/9/28.
*/
public class WebManagerPaneFactory {
private String installHome;
public WebManagerPaneFactory() {
if (StableUtils.isDebug()) {
URL url = ClassLoader.getSystemResource("");
this.installHome = url.getPath();
} else {
this.installHome = StableUtils.getInstallHome();
}
}
public BasicPane createPluginPane() {
if (StableUtils.getMajorJavaVersion() == 8) {
return new ShopManagerPane(new ShopPaneConfig() {
@Override
String getMainJS() {
String relativePath = "/scripts/store/web/index.html";
return StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath);
}
@Override
String getScriptsId() {
return "shop_scripts";
}
@Override
JFXPanel getWebPane() {
return new PluginWebPane(getMainJS());
}
});
} else {
BasicPane traditionalStorePane = new BasicPane() {
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Plugin_Manager");
}
};
traditionalStorePane.setLayout(new BorderLayout());
traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER);
return traditionalStorePane;
}
}
public BasicPane createReusePane() {
return new ShopManagerPane(new ShopPaneConfig() {
@Override
String getMainJS() {
String relativePath = "/scripts/store/reuse/index.html";
return StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath);
}
@Override
String getScriptsId() {
return "reuse_scripts";
}
@Override
JFXPanel getWebPane() {
return new ReuseWebPane(getMainJS());
}
});
}
/**
* 以关键词打开设计器商店
*
* @param keyword 关键词
*/
public BasicPane createPluginPane(String keyword) {
PluginWebBridge.getHelper().openWithSearch(keyword);
return createPluginPane();
}
private Component initTraditionalStore() {
UITabbedPane tabbedPane = new UITabbedPane();
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));
return tabbedPane;
}
}

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

@ -146,13 +146,13 @@ public abstract class ToolBarMenuDock {
// 给菜单加插件入口
for (MenuDef m : menuDefs) {
switch (m.getAnchor()) {
case MenuHandler.TEMPLATE :
case MenuHandler.TEMPLATE:
insertMenu(m, MenuHandler.TEMPLATE, new TemplateTargetAction(plus));
break;
case MenuHandler.INSERT :
case MenuHandler.INSERT:
insertMenu(m, MenuHandler.INSERT);
break;
case MenuHandler.CELL :
case MenuHandler.CELL:
insertMenu(m, MenuHandler.CELL);
break;
default:
@ -199,7 +199,7 @@ public abstract class ToolBarMenuDock {
addSwitchExistEnvAction(menuDef);
menuDef.addShortCut( new ExitDesignerAction());
menuDef.addShortCut(new ExitDesignerAction());
insertMenu(menuDef, MenuHandler.FILE);
return menuDef;
@ -221,7 +221,7 @@ public abstract class ToolBarMenuDock {
menuDef.addShortCut(new SwitchExistEnv());
}
protected ShortCut openTemplateAction(){
protected ShortCut openTemplateAction() {
return new OpenTemplateAction();
}
@ -236,9 +236,8 @@ public abstract class ToolBarMenuDock {
* 创建论坛登录面板, chart那边不需要
*
* @return 面板组件
*
*/
public Component createBBSLoginPane(){
public Component createBBSLoginPane() {
return new UILabel();
}
@ -264,9 +263,10 @@ public abstract class ToolBarMenuDock {
);
if (!BaseUtils.isAuthorityEditing()) {
if (shouldShowPlugin()){
if (shouldShowPlugin()) {
menuDef.addShortCut(
new PluginManagerAction()
new PluginManagerAction(),
new ReuseManagerAction()
);
}
menuDef.addShortCut(
@ -290,6 +290,7 @@ public abstract class ToolBarMenuDock {
/**
* 创建帮助子菜单
*
* @return 帮组菜单的子菜单
*/
public ShortCut[] createHelpShortCuts() {
@ -298,7 +299,7 @@ public abstract class ToolBarMenuDock {
shortCuts.add(SeparatorDef.DEFAULT);
//shortCuts.add(new TutorialAction());
shortCuts.add(SeparatorDef.DEFAULT);
if (ComparatorUtils.equals(ProductConstants.APP_NAME,FINEREPORT)) {
if (ComparatorUtils.equals(ProductConstants.APP_NAME, FINEREPORT)) {
shortCuts.add(new FeedBackAction());
shortCuts.add(SeparatorDef.DEFAULT);
shortCuts.add(SeparatorDef.DEFAULT);
@ -312,6 +313,7 @@ public abstract class ToolBarMenuDock {
/**
* 创建社区子菜单
*
* @return 社区菜单的子菜单
*/
public ShortCut[] createCommunityShortCuts() {
@ -346,6 +348,7 @@ public abstract class ToolBarMenuDock {
insertMenu(menuDef, MenuHandler.BBS);
return menuDef;
}
/**
* 生成工具栏
*
@ -470,7 +473,8 @@ public abstract class ToolBarMenuDock {
public int getMenuState() {
return DesignState.WORK_SHEET;
}
public int getToolBarHeight(){
public int getToolBarHeight() {
return PANLE_HEIGNT;
}
@ -479,13 +483,13 @@ public abstract class ToolBarMenuDock {
*
* @return 子菜单
*/
public ShortCut[] shortcut4ExportMenu(){
public ShortCut[] shortcut4ExportMenu() {
return new ShortCut[0];
}
};
public NewTemplatePane getNewTemplatePane(){
public NewTemplatePane getNewTemplatePane() {
return new NewTemplatePane() {
@Override
public Icon getNew() {
@ -521,7 +525,7 @@ public abstract class ToolBarMenuDock {
for (MenuHandler handler : target) {
int insertPosition = handler.insertPosition(menuDef.getShortCutCount());
ShortCut shortCut = action.methodAction(handler);
if (shortCut == null){
if (shortCut == null) {
continue;
}
@ -534,10 +538,10 @@ public abstract class ToolBarMenuDock {
menuDef.insertShortCut(insertPosition, shortCut);
if (handler.insertSeparatorBefore()) {
menuDef.insertShortCut(insertPosition, SeparatorDef.DEFAULT);
insertPosition ++;
insertPosition++;
}
if (handler.insertSeparatorAfter()) {
insertPosition ++;
insertPosition++;
menuDef.insertShortCut(insertPosition, SeparatorDef.DEFAULT);
}
}
@ -546,36 +550,35 @@ public abstract class ToolBarMenuDock {
/**
* 设计器退出时, 做的一些操作.
*
*/
public void shutDown(){
public void shutDown() {
}
private interface ShortCutMethodAction{
private interface ShortCutMethodAction {
public ShortCut methodAction(MenuHandler handler);
}
private abstract class AbstractShortCutMethodAction implements ShortCutMethodAction{
private abstract class AbstractShortCutMethodAction implements ShortCutMethodAction {
public ShortCut methodAction(MenuHandler handler){
public ShortCut methodAction(MenuHandler handler) {
return handler.shortcut();
}
}
//不需要编辑对象的菜单, 比如文件, 服务器, 关于
private class NoTargetAction extends AbstractShortCutMethodAction{
private class NoTargetAction extends AbstractShortCutMethodAction {
}
//模板为对象的菜单, 比如模板, 后续如果单元格也要, 直接加个CellTargetAction即可.
//在methodAction中做handler.shortcut(cell), 不需要修改handler中原有接口, 加个shortcut(cell).
private class TemplateTargetAction extends AbstractShortCutMethodAction{
private class TemplateTargetAction extends AbstractShortCutMethodAction {
private ToolBarMenuDockPlus plus;
public TemplateTargetAction(ToolBarMenuDockPlus plus){
public TemplateTargetAction(ToolBarMenuDockPlus plus) {
this.plus = plus;
}

9
designer_base/src/com/fr/start/BaseDesigner.java

@ -7,10 +7,11 @@ import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.PluginManagerPane;
import com.fr.design.extra.PluginShopDialog;
import com.fr.design.extra.ShopDialog;
import com.fr.design.extra.PluginWebBridge;
import com.fr.design.extra.WebManagerPaneFactory;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.TemplateTreePane;
@ -130,8 +131,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
String text = StableUtils.join(plugins, ",") + Inter.getLocText("FR-Designer_Plugin_Should_Update");
int r = JOptionPane.showConfirmDialog(null, text, Inter.getLocText("FR-Designer_Plugin_Should_Update_Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (r == JOptionPane.OK_OPTION) {
final PluginManagerPane managerPane = new PluginManagerPane();
UIDialog dlg = new PluginShopDialog(DesignerContext.getDesignerFrame(),managerPane);
BasicPane managerPane = new WebManagerPaneFactory().createPluginPane();
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
}

Loading…
Cancel
Save