From cbbf0bf07c5466298fbd67d5edce8a079fb583f6 Mon Sep 17 00:00:00 2001 From: vito Date: Fri, 8 Apr 2016 23:08:57 +0800 Subject: [PATCH 01/19] =?UTF-8?q?1=E3=80=81=E6=9B=B4=E6=94=B9=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=AA=97=E5=8F=A3=E4=BB=A5=E9=80=82=E9=85=8D=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=95=86=E5=BA=97=E5=B8=83=E5=B1=80=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=202=E3=80=81=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=96=B0=E7=9A=84=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/server/PluginManagerAction.java | 3 +- .../src/com/fr/design/dialog/BasicDialog.java | 1 + .../src/com/fr/design/dialog/BasicPane.java | 766 +++++++++--------- .../com/fr/design/extra/PluginWebBridge.java | 25 + .../com/fr/design/extra/PluginWebPane.java | 5 +- 5 files changed, 430 insertions(+), 370 deletions(-) diff --git a/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java b/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java index 91b4eb810d..646eb479aa 100644 --- a/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java +++ b/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java @@ -28,8 +28,7 @@ public class PluginManagerAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { final PluginManagerPane managerPane = new PluginManagerPane(); - BasicDialog dlg = managerPane.showLargeWindow(DesignerContext.getDesignerFrame(),null); - + BasicDialog dlg = managerPane.showCustomSizeWindow(DesignerContext.getDesignerFrame(), null, BasicDialog.LARGE_SHOP); dlg.setVisible(true); } diff --git a/designer_base/src/com/fr/design/dialog/BasicDialog.java b/designer_base/src/com/fr/design/dialog/BasicDialog.java index 703b192055..a1f2785cfd 100644 --- a/designer_base/src/com/fr/design/dialog/BasicDialog.java +++ b/designer_base/src/com/fr/design/dialog/BasicDialog.java @@ -10,6 +10,7 @@ public abstract class BasicDialog extends UIDialog { public static final Dimension MEDIUM = new Dimension(600, 400); public static final Dimension DEFAULT = new Dimension(660, 600); public static final Dimension LARGE = new Dimension(900, 600); + public static final Dimension LARGE_SHOP = new Dimension(900, 760); public static final Dimension CHART = new Dimension(760, 560); public static final Dimension MAP_SIZE = new Dimension(760, 450); public static final Dimension UPDATE_ONLINE_SIZE = new Dimension(600,300); diff --git a/designer_base/src/com/fr/design/dialog/BasicPane.java b/designer_base/src/com/fr/design/dialog/BasicPane.java index c94c246bf4..09190f20fb 100644 --- a/designer_base/src/com/fr/design/dialog/BasicPane.java +++ b/designer_base/src/com/fr/design/dialog/BasicPane.java @@ -16,380 +16,414 @@ import java.awt.*; */ public abstract class BasicPane extends JPanel { - /** - *显示窗口 - * @param window 窗口 - * @return 对话框 - */ - public BasicDialog showWindow(Window window) { - return this.showWindow(window, null); - } - - - /** - * 显示窗口 - * @param window 窗口 - * @param l 对话框监听器 - * @return 对话框 - */ - public BasicDialog showWindow(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - - dg.setBasicDialogSize(BasicDialog.DEFAULT); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - /** - * 显示窗口 - * @param window 窗口 - * @param isNeedButtonsPane 是否需要确定删除按钮 - * @return 对话框 - */ - public BasicDialog showWindow(Window window, boolean isNeedButtonsPane) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window, isNeedButtonsPane); - } else { - dg = new DIALOG((Dialog) window, isNeedButtonsPane); - } - dg.setBasicDialogSize(BasicDialog.DEFAULT); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - - - /** - * 图表类型选择时 弹出的按钮大小, 不适合用最大最小, 因为图表大小 默认是规定好的, 那么界面大小也是必须配合. - * 并且包括 条件显示中 多个条件的大小 - * @param window 窗口 - * @param l 监听器 - * @return 对话框 - */ - public BasicDialog showWindow4ChartType(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - - dg.setBasicDialogSize(BasicDialog.CHART); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - /** - * 显示窗口 - * @param window 窗口 - * @param l 对话框监听器 - * @return 对话框 - */ - public BasicDialog showSmallWindow(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - dg.setBasicDialogSize(BasicDialog.SMALL); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - /** - * 显示窗口 - * @param window 窗口 - * @param l 对话框监听器 - * @return 对话框 - */ - public BasicDialog showMediumWindow(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - dg.setBasicDialogSize(BasicDialog.MEDIUM); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - /** - * 显示窗口 - * @param window 窗口 - * @param l 对话框监听器 - * @return 对话框 - */ - public BasicDialog showLargeWindow(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - dg.setBasicDialogSize(BasicDialog.LARGE); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - /** - * 显示窗口 - * @param window 窗口 - * @param l 对话框监听器 - * @return 对话框 - */ - public UIDialog showUnsizedWindow(Window window, DialogActionListener l) { - UIDialog dg; - if (window instanceof Frame) { - dg = new UnsizedDialog((Frame) window); - } else { - dg = new UnsizedDialog((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - /** - * 显示窗口 - * @param window 窗口 - * @param l 对话框监听器 - * @return 对话框 - */ - public BasicDialog showWindow4ChartMapArray(Window window,DialogActionListener l){ - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - dg.setBasicDialogSize(BasicDialog.MAP_SIZE); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - - /** - * 显示窗口 - * @param window 窗口 - * @return 对话框 - */ - public BasicDialog showWindow4UpdateOnline(Window window){ - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window,false); - } else { - dg = new DIALOG((Dialog) window,false); - } - dg.setBasicDialogSize(BasicDialog.UPDATE_ONLINE_SIZE); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - - protected abstract String title4PopupWindow(); - - public String getTitle(){ - return title4PopupWindow(); - } - - /** - * 作为名字面板 - * @return 面板 - */ - public NamePane asNamePane() { - return new NamePane(this); - } - - /** - * 检查是否符合规范 + /** + * 显示窗口 * - * @throws Exception 异常 - */ - public void checkValid() throws Exception { - } - - public static final class NamePane extends BasicPane { - private UITextField nameTextField; - private BasicPane centerPane; - private UILabel showfield; - private PropertyChangeAdapter changeListener; - - private NamePane(BasicPane bPane) { - this.setLayout(new BorderLayout(4, 4)); - - nameTextField = new UITextField(30); - JPanel northPane = new JPanel(new BorderLayout(4, 4)); - northPane.add(new UILabel(Inter.getLocText("FR-Designer-Hyperlink_Name") + ":"), BorderLayout.WEST); - northPane.add(nameTextField, BorderLayout.CENTER); - northPane.add(showfield = new UILabel(" "), BorderLayout.EAST); - showfield.setForeground(new Color(204, 0, 1)); - showfield.setPreferredSize(new Dimension(220, showfield.getPreferredSize().height)); - this.add(northPane, BorderLayout.NORTH); - this.centerPane = bPane; - this.add(bPane, BorderLayout.CENTER); - this.nameTextField.getDocument().addDocumentListener(new javax.swing.event.DocumentListener() { - - @Override - public void insertUpdate(DocumentEvent e) { - doTextChanged(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - doTextChanged(); - } - - @Override - public void changedUpdate(DocumentEvent e) { - doTextChanged(); - } - - }); - } - - private void doTextChanged() { - if (changeListener != null) { - changeListener.propertyChange(); - } - } - - public String getObjectName() { - return this.nameTextField.getText().trim(); - } - - public void setObjectName(String name) { - this.nameTextField.setText(name); - } - - public void setShowText(String name) { - this.showfield.setText(name); - } - - @Override - protected String title4PopupWindow() { - return centerPane.title4PopupWindow(); - } - - /** - * 检查是否符合规范 - * - * @throws Exception 异常 - */ - public void checkValid() throws Exception { - super.checkValid(); - - this.centerPane.checkValid(); - } - - /** - * 添加属性改变的监听器 - * @param listener 监听器 - */ - public void addPropertyChangeListener(PropertyChangeAdapter listener) { - this.changeListener = listener; - } - } - - private class DIALOG extends BasicDialog { - public DIALOG(Frame parent) { - super(parent, BasicPane.this); - this.setTitle(BasicPane.this.title4PopupWindow()); - } - - public DIALOG(Dialog parent) { - super(parent, BasicPane.this); - this.setTitle(BasicPane.this.title4PopupWindow()); - } - - - public DIALOG(Frame parent, boolean isNeedButtonPane) { - super(parent, BasicPane.this, isNeedButtonPane); - this.setTitle(BasicPane.this.title4PopupWindow()); - } - - - public DIALOG(Dialog parent, boolean isNeedButtonPane) { - super(parent, BasicPane.this, isNeedButtonPane); - this.setTitle(BasicPane.this.title4PopupWindow()); - } - - - - /** - * init Components - */ - - - /** - * Check valid. - */ - public void checkValid() throws Exception { - BasicPane.this.checkValid(); - } + * @param window 窗口 + * @return 对话框 + */ + public BasicDialog showWindow(Window window) { + return this.showWindow(window, null); + } - } - private class UnsizedDialog extends UIDialog { + /** + * 显示窗口 + * + * @param window 窗口 + * @param l 对话框监听器 + * @return 对话框 + */ + public BasicDialog showWindow(Window window, DialogActionListener l) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window); + } else { + dg = new DIALOG((Dialog) window); + } + + if (l != null) { + dg.addDialogActionListener(l); + } + + dg.setBasicDialogSize(BasicDialog.DEFAULT); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + /** + * 显示窗口 + * + * @param window 窗口 + * @param isNeedButtonsPane 是否需要确定删除按钮 + * @return 对话框 + */ + public BasicDialog showWindow(Window window, boolean isNeedButtonsPane) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window, isNeedButtonsPane); + } else { + dg = new DIALOG((Dialog) window, isNeedButtonsPane); + } + dg.setBasicDialogSize(BasicDialog.DEFAULT); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + + /** + * 图表类型选择时 弹出的按钮大小, 不适合用最大最小, 因为图表大小 默认是规定好的, 那么界面大小也是必须配合. + * 并且包括 条件显示中 多个条件的大小 + * + * @param window 窗口 + * @param l 监听器 + * @return 对话框 + */ + public BasicDialog showWindow4ChartType(Window window, DialogActionListener l) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window); + } else { + dg = new DIALOG((Dialog) window); + } + + if (l != null) { + dg.addDialogActionListener(l); + } + + dg.setBasicDialogSize(BasicDialog.CHART); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + /** + * 显示窗口 + * + * @param window 窗口 + * @param l 对话框监听器 + * @return 对话框 + */ + public BasicDialog showSmallWindow(Window window, DialogActionListener l) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window); + } else { + dg = new DIALOG((Dialog) window); + } + + if (l != null) { + dg.addDialogActionListener(l); + } + dg.setBasicDialogSize(BasicDialog.SMALL); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + /** + * 显示窗口 + * + * @param window 窗口 + * @param l 对话框监听器 + * @return 对话框 + */ + public BasicDialog showMediumWindow(Window window, DialogActionListener l) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window); + } else { + dg = new DIALOG((Dialog) window); + } + + if (l != null) { + dg.addDialogActionListener(l); + } + dg.setBasicDialogSize(BasicDialog.MEDIUM); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + /** + * 显示窗口 + * + * @param window 窗口 + * @param l 对话框监听器 + * @return 对话框 + */ + public BasicDialog showLargeWindow(Window window, DialogActionListener l) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window); + } else { + dg = new DIALOG((Dialog) window); + } + + if (l != null) { + dg.addDialogActionListener(l); + } + dg.setBasicDialogSize(BasicDialog.LARGE); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + /** + * 显示自定义大小的窗口 + * + * @param window 窗口 + * @param l 对话框监听器 + * @param dimension 窗口大小 + * @return 对话框 + */ + public BasicDialog showCustomSizeWindow(Window window, DialogActionListener l, Dimension dimension) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window); + } else { + dg = new DIALOG((Dialog) window); + } + if (l != null) { + dg.addDialogActionListener(l); + } + dg.setBasicDialogSize(dimension); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + /** + * 显示窗口 + * + * @param window 窗口 + * @param l 对话框监听器 + * @return 对话框 + */ + public UIDialog showUnsizedWindow(Window window, DialogActionListener l) { + UIDialog dg; + if (window instanceof Frame) { + dg = new UnsizedDialog((Frame) window); + } else { + dg = new UnsizedDialog((Dialog) window); + } + + if (l != null) { + dg.addDialogActionListener(l); + } + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + /** + * 显示窗口 + * + * @param window 窗口 + * @param l 对话框监听器 + * @return 对话框 + */ + public BasicDialog showWindow4ChartMapArray(Window window, DialogActionListener l) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window); + } else { + dg = new DIALOG((Dialog) window); + } + + if (l != null) { + dg.addDialogActionListener(l); + } + dg.setBasicDialogSize(BasicDialog.MAP_SIZE); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + + /** + * 显示窗口 + * + * @param window 窗口 + * @return 对话框 + */ + public BasicDialog showWindow4UpdateOnline(Window window) { + BasicDialog dg; + if (window instanceof Frame) { + dg = new DIALOG((Frame) window, false); + } else { + dg = new DIALOG((Dialog) window, false); + } + dg.setBasicDialogSize(BasicDialog.UPDATE_ONLINE_SIZE); + GUICoreUtils.centerWindow(dg); + dg.setResizable(false); + return dg; + } + + protected abstract String title4PopupWindow(); + + public String getTitle() { + return title4PopupWindow(); + } + + /** + * 作为名字面板 + * + * @return 面板 + */ + public NamePane asNamePane() { + return new NamePane(this); + } - public UnsizedDialog(Frame parent) { - super(parent, BasicPane.this); - this.setTitle(BasicPane.this.title4PopupWindow()); - } + /** + * 检查是否符合规范 + * + * @throws Exception 异常 + */ + public void checkValid() throws Exception { + } + + public static final class NamePane extends BasicPane { + private UITextField nameTextField; + private BasicPane centerPane; + private UILabel showfield; + private PropertyChangeAdapter changeListener; + + private NamePane(BasicPane bPane) { + this.setLayout(new BorderLayout(4, 4)); + + nameTextField = new UITextField(30); + JPanel northPane = new JPanel(new BorderLayout(4, 4)); + northPane.add(new UILabel(Inter.getLocText("FR-Designer-Hyperlink_Name") + ":"), BorderLayout.WEST); + northPane.add(nameTextField, BorderLayout.CENTER); + northPane.add(showfield = new UILabel(" "), BorderLayout.EAST); + showfield.setForeground(new Color(204, 0, 1)); + showfield.setPreferredSize(new Dimension(220, showfield.getPreferredSize().height)); + this.add(northPane, BorderLayout.NORTH); + this.centerPane = bPane; + this.add(bPane, BorderLayout.CENTER); + this.nameTextField.getDocument().addDocumentListener(new javax.swing.event.DocumentListener() { + + @Override + public void insertUpdate(DocumentEvent e) { + doTextChanged(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + doTextChanged(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + doTextChanged(); + } + + }); + } + + private void doTextChanged() { + if (changeListener != null) { + changeListener.propertyChange(); + } + } + + public String getObjectName() { + return this.nameTextField.getText().trim(); + } + + public void setObjectName(String name) { + this.nameTextField.setText(name); + } + + public void setShowText(String name) { + this.showfield.setText(name); + } + + @Override + protected String title4PopupWindow() { + return centerPane.title4PopupWindow(); + } + + /** + * 检查是否符合规范 + * + * @throws Exception 异常 + */ + public void checkValid() throws Exception { + super.checkValid(); + + this.centerPane.checkValid(); + } + + /** + * 添加属性改变的监听器 + * + * @param listener 监听器 + */ + public void addPropertyChangeListener(PropertyChangeAdapter listener) { + this.changeListener = listener; + } + } + + private class DIALOG extends BasicDialog { + public DIALOG(Frame parent) { + super(parent, BasicPane.this); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + public DIALOG(Dialog parent) { + super(parent, BasicPane.this); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + + public DIALOG(Frame parent, boolean isNeedButtonPane) { + super(parent, BasicPane.this, isNeedButtonPane); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + + public DIALOG(Dialog parent, boolean isNeedButtonPane) { + super(parent, BasicPane.this, isNeedButtonPane); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + + /** + * init Components + */ + + + /** + * Check valid. + */ + public void checkValid() throws Exception { + BasicPane.this.checkValid(); + } + + } - public UnsizedDialog(Dialog parent) { - super(parent, BasicPane.this); - this.setTitle(BasicPane.this.title4PopupWindow()); - } + private class UnsizedDialog extends UIDialog { + + public UnsizedDialog(Frame parent) { + super(parent, BasicPane.this); + this.setTitle(BasicPane.this.title4PopupWindow()); + } + + public UnsizedDialog(Dialog parent) { + super(parent, BasicPane.this); + this.setTitle(BasicPane.this.title4PopupWindow()); + } - public void checkValid() throws Exception { - BasicPane.this.checkValid(); - } + public void checkValid() throws Exception { + BasicPane.this.checkValid(); + } - } + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index b4eb6e9e1c..b32dcdd406 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -1,6 +1,8 @@ package com.fr.design.extra; import com.fr.design.extra.exe.*; +import com.fr.general.FRLogger; +import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.plugin.Plugin; @@ -157,6 +159,7 @@ public class PluginWebBridge { /** * 获取已经安装的插件的数组 + * * @return 已安装的插件组成的数组 */ public Plugin[] getInstalledPlugins() { @@ -174,4 +177,26 @@ public class PluginWebBridge { } return list.toArray(new String[len]); } + + public String getPluginFromStore(String category, String seller, String fee) { + + StringBuilder url = new StringBuilder("http://127.0.0.1:8080/ShopServer?pg=plist"); + if(StringUtils.isNotBlank(category)){ + url.append("&cid=").append(category.split("-")[1]); + } + if(StringUtils.isNotBlank(seller)){ + url.append("&seller=").append(seller.split("-")[1]); + } + if(StringUtils.isNotBlank(fee)){ + url.append("&fee=").append(fee.split("-")[1]); + } + String resText = null; + try { + HttpClient httpClient = new HttpClient(url.toString()); + resText = httpClient.getResponseText(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + return resText == null ? StringUtils.EMPTY : resText; + } } diff --git a/designer_base/src/com/fr/design/extra/PluginWebPane.java b/designer_base/src/com/fr/design/extra/PluginWebPane.java index 8b899220fb..54c882bdde 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebPane.java +++ b/designer_base/src/com/fr/design/extra/PluginWebPane.java @@ -5,6 +5,7 @@ import javafx.embed.swing.JFXPanel; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; import javafx.scene.web.WebEngine; import javafx.scene.web.WebEvent; import javafx.scene.web.WebView; @@ -24,7 +25,7 @@ public class PluginWebPane extends JFXPanel { Platform.runLater(new Runnable() { @Override public void run() { - Group root = new Group(); + BorderPane root = new BorderPane(); Scene scene = new Scene(root); PluginWebPane.this.setScene(scene); WebView webView = new WebView(); @@ -38,7 +39,7 @@ public class PluginWebPane extends JFXPanel { }); JSObject obj = (JSObject) webEngine.executeScript("window"); obj.setMember("PluginHelper", PluginWebBridge.getHelper(webEngine)); - root.getChildren().add(webView); + root.setCenter(webView); } }); } From 69455f31fa77ab0f494cace53f993968a2f5cfd3 Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 12 Apr 2016 18:51:04 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/server/PluginManagerAction.java | 4 ++ .../com/fr/design/extra/PluginWebBridge.java | 39 +++++++++++++++---- .../com/fr/design/extra/PluginWebPane.java | 1 - 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java b/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java index 646eb479aa..4225f0c4f3 100644 --- a/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java +++ b/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java @@ -3,7 +3,9 @@ package com.fr.design.actions.server; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.UIDialog; import com.fr.design.extra.PluginManagerPane; +import com.fr.design.extra.PluginWebBridge; import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; @@ -28,7 +30,9 @@ public class PluginManagerAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { final PluginManagerPane managerPane = new PluginManagerPane(); + //// TODO: 16/4/11 重新写下这个界面窗口. BasicDialog dlg = managerPane.showCustomSizeWindow(DesignerContext.getDesignerFrame(), null, BasicDialog.LARGE_SHOP); + PluginWebBridge.getHelper().setDialogHandle(dlg); dlg.setVisible(true); } diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index b32dcdd406..6a1ad0f281 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -1,10 +1,10 @@ package com.fr.design.extra; +import com.fr.design.actions.server.PluginManagerAction; +import com.fr.design.dialog.UIDialog; import com.fr.design.extra.exe.*; import com.fr.general.FRLogger; import com.fr.general.http.HttpClient; -import com.fr.json.JSONArray; -import com.fr.json.JSONObject; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLoader; import com.fr.stable.ArrayUtils; @@ -15,6 +15,7 @@ import javafx.stage.FileChooser; import javafx.stage.Stage; import netscape.javascript.JSObject; +import javax.swing.*; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -26,24 +27,38 @@ public class PluginWebBridge { private static PluginWebBridge helper; - public static PluginWebBridge getHelper(WebEngine webEngine) { + private UIDialog uiDialog; + + public static PluginWebBridge getHelper() { if (helper != null) { return helper; } synchronized (PluginWebBridge.class) { if (helper == null) { - helper = new PluginWebBridge(webEngine); + helper = new PluginWebBridge(); } return helper; } } + public static PluginWebBridge getHelper(WebEngine webEngine) { + getHelper(); + helper.setEngine(webEngine); + return helper; + } + private WebEngine webEngine; - private PluginWebBridge(WebEngine webEngine) { + private PluginWebBridge() { + } + + public void setEngine(WebEngine webEngine){ this.webEngine = webEngine; } + public void setDialogHandle(UIDialog uiDialog){ + this.uiDialog = uiDialog; + } /** * 从插件服务器上安装插件 * @@ -181,13 +196,13 @@ public class PluginWebBridge { public String getPluginFromStore(String category, String seller, String fee) { StringBuilder url = new StringBuilder("http://127.0.0.1:8080/ShopServer?pg=plist"); - if(StringUtils.isNotBlank(category)){ + if (StringUtils.isNotBlank(category)) { url.append("&cid=").append(category.split("-")[1]); } - if(StringUtils.isNotBlank(seller)){ + if (StringUtils.isNotBlank(seller)) { url.append("&seller=").append(seller.split("-")[1]); } - if(StringUtils.isNotBlank(fee)){ + if (StringUtils.isNotBlank(fee)) { url.append("&fee=").append(fee.split("-")[1]); } String resText = null; @@ -199,4 +214,12 @@ public class PluginWebBridge { } return resText == null ? StringUtils.EMPTY : resText; } + + public void closeWindow() { + if (uiDialog != null) { + uiDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + uiDialog.setVisible(false); + uiDialog.dispose(); + } + } } diff --git a/designer_base/src/com/fr/design/extra/PluginWebPane.java b/designer_base/src/com/fr/design/extra/PluginWebPane.java index 54c882bdde..7a864bdcb8 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebPane.java +++ b/designer_base/src/com/fr/design/extra/PluginWebPane.java @@ -3,7 +3,6 @@ package com.fr.design.extra; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.event.EventHandler; -import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.scene.web.WebEngine; From 36b48b30dc4c340b5d98d26ff44cc1d9eaf9c151 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 14 Apr 2016 10:38:27 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginWebBridge.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 6a1ad0f281..0f5122f3e3 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -1,6 +1,5 @@ package com.fr.design.extra; -import com.fr.design.actions.server.PluginManagerAction; import com.fr.design.dialog.UIDialog; import com.fr.design.extra.exe.*; import com.fr.general.FRLogger; @@ -114,10 +113,9 @@ public class PluginWebBridge { * 修改选中的插件的活跃状态 * * @param pluginID 插件ID - * @param active 如果要把插件修改为激活状态,则为true,否则为false */ - public void setPluginActive(String pluginID, boolean active, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new ModifyStatusExecutor(pluginID, active)); + public void setPluginActive(String pluginID, final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new ModifyStatusExecutor(pluginID)); new Thread(task).start(); } @@ -195,7 +193,7 @@ public class PluginWebBridge { public String getPluginFromStore(String category, String seller, String fee) { - StringBuilder url = new StringBuilder("http://127.0.0.1:8080/ShopServer?pg=plist"); + StringBuilder url = new StringBuilder("http://192.168.101.20/ShopServer?pg=plist"); if (StringUtils.isNotBlank(category)) { url.append("&cid=").append(category.split("-")[1]); } @@ -208,6 +206,7 @@ public class PluginWebBridge { String resText = null; try { HttpClient httpClient = new HttpClient(url.toString()); + //httpClient.setTimeout(5000); resText = httpClient.getResponseText(); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); @@ -217,9 +216,8 @@ public class PluginWebBridge { public void closeWindow() { if (uiDialog != null) { - uiDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); uiDialog.setVisible(false); - uiDialog.dispose(); } } } From 97140c177cbd03777b1bd70300175d78d2204c97 Mon Sep 17 00:00:00 2001 From: vito Date: Sat, 16 Apr 2016 02:03:28 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=95=86=E5=BA=97API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/bbs/BBSDialog.java | 3 +- .../com/fr/design/extra/PluginWebBridge.java | 80 +++++++++++++++++-- .../extra/exe/InstallFromDiskExecutor.java | 28 +++++-- .../extra/exe/InstallOnlineExecutor.java | 33 +++++++- .../extra/exe/ModifyStatusExecutor.java | 34 +++++++- .../design/extra/exe/UninstallExecutor.java | 50 +++++++++++- .../extra/exe/UpdateFromDiskExecutor.java | 20 ++++- 7 files changed, 222 insertions(+), 26 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java index 8dbdd0acf2..856e9264a1 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java @@ -143,9 +143,8 @@ public class BBSDialog extends UIDialog { * 提供给web页面调用的关闭窗口 */ public void closeWindow() { - this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setVisible(false); - this.dispose(); } /** * 略 diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 0f5122f3e3..ce6dd8fba3 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -1,8 +1,11 @@ package com.fr.design.extra; +import com.fr.base.FRContext; +import com.fr.design.RestartHelper; import com.fr.design.dialog.UIDialog; import com.fr.design.extra.exe.*; import com.fr.general.FRLogger; +import com.fr.general.Inter; import com.fr.general.http.HttpClient; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLoader; @@ -92,10 +95,10 @@ public class PluginWebBridge { /** * 从插件服务器上更新选中的插件 * - * @param pluginID 插件的ID + * @param pluginIDs 插件集合 */ - public void updatePluginOnline(String pluginID, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new UpdateOnlineExecutor(pluginID)); + public void updatePluginOnline(JSObject pluginIDs, final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new UpdateOnlineExecutor(jsObjectToStringArray(pluginIDs))); new Thread(task).start(); } @@ -193,7 +196,7 @@ public class PluginWebBridge { public String getPluginFromStore(String category, String seller, String fee) { - StringBuilder url = new StringBuilder("http://192.168.101.20/ShopServer?pg=plist"); + StringBuilder url = new StringBuilder("http://127.0.0.1:8080/ShopServer?pg=plist"); if (StringUtils.isNotBlank(category)) { url.append("&cid=").append(category.split("-")[1]); } @@ -206,7 +209,7 @@ public class PluginWebBridge { String resText = null; try { HttpClient httpClient = new HttpClient(url.toString()); - //httpClient.setTimeout(5000); + httpClient.setTimeout(3000); resText = httpClient.getResponseText(); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); @@ -214,10 +217,77 @@ public class PluginWebBridge { return resText == null ? StringUtils.EMPTY : resText; } + + public void showRestartMessage(String message){ + int rv = JOptionPane.showOptionDialog( + null, + message, + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")}, + null + ); + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + } + public void closeWindow() { if (uiDialog != null) { uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); uiDialog.setVisible(false); } } + + public void updateFileFromDisk(File fileOnDisk){ + try { + Plugin plugin = PluginHelper.readPlugin(fileOnDisk); + if (plugin == null) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + return; + } + Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); + if (oldPlugin != null) { + // 说明安装了同ID的插件,再比较两个插件的版本 + if (PluginHelper.isNewThan(plugin, oldPlugin)) { + // 说明是新的插件,删除老的然后安装新的 + final String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); + PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { + @Override + public void done() { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText("FR-Designer-Plugin_Update_Successful"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), + Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") + }, + null + ); + + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + + // 如果不是立即重启,就把要删除的文件存放起来 + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + RestartHelper.saveFilesWhichToDelete(files); + } + } + }); + } else { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Version_Is_Lower_Than_Current"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } else { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } } diff --git a/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java b/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java index 098a91c029..cb803f3141 100644 --- a/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java @@ -1,5 +1,16 @@ package com.fr.design.extra.exe; +import com.fr.design.RestartHelper; +import com.fr.design.extra.After; +import com.fr.design.extra.PluginHelper; +import com.fr.design.extra.PluginWebBridge; +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import org.apache.poi.poifs.crypt.AgileDecryptor; + +import javax.swing.*; +import java.io.File; + /** * Created by richie on 16/3/19. */ @@ -27,11 +38,6 @@ public class InstallFromDiskExecutor implements Executor { @Override public void run() { - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } } }, new Command() { @@ -43,9 +49,15 @@ public class InstallFromDiskExecutor implements Executor { @Override public void run() { try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); + PluginHelper.installPluginFromDisk(new File(filePath), new After() { + @Override + public void done() { + FRLogger.getLogger().info("插件安装成功"); + PluginWebBridge.getHelper().showRestartMessage(Inter.getLocText("FR-Designer-Plugin_Install_Successful")); + } + }); + } catch (Exception e1) { + FRLogger.getLogger().error(e1.getMessage()); } } } diff --git a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java index 7baf378fd2..348898877f 100644 --- a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java @@ -1,5 +1,16 @@ package com.fr.design.extra.exe; +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; +import com.fr.design.extra.After; +import com.fr.design.extra.PluginHelper; +import com.fr.design.extra.PluginWebBridge; +import com.fr.design.extra.Process; +import com.fr.general.Inter; + +import javax.swing.*; + /** * Created by richie on 16/3/19. */ @@ -27,10 +38,17 @@ public class InstallOnlineExecutor implements Executor { @Override public void run() { + String username = DesignerEnvManager.getEnvManager().getBBSName(); + String password = DesignerEnvManager.getEnvManager().getBBSPassword(); try { - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); + PluginHelper.downloadPluginFile(pluginID,username,password, new Process() { + @Override + public void process(Double integer) { + + } + }); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); } } }, @@ -43,9 +61,16 @@ public class InstallOnlineExecutor implements Executor { @Override public void run() { try { - Thread.sleep(3000); + PluginHelper.installPluginFromDisk(PluginHelper.getDownloadTempFile(), new After() { + @Override + public void done() { + PluginWebBridge.getHelper().showRestartMessage(Inter.getLocText("FR-Designer-Plugin_Update_Successful")); + } + }); } catch (InterruptedException e) { e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } } } diff --git a/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java b/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java index ff5d82bd5f..2d5b0f8c70 100644 --- a/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java @@ -1,5 +1,12 @@ package com.fr.design.extra.exe; +import com.fr.base.FRContext; +import com.fr.design.extra.PluginWebBridge; +import com.fr.general.Inter; +import com.fr.plugin.Plugin; +import com.fr.plugin.PluginLoader; +import com.fr.stable.StringUtils; + /** * Created by richie on 16/3/19. */ @@ -7,19 +14,38 @@ public class ModifyStatusExecutor implements Executor { private String pluginID; private boolean active; + private Plugin plugin; - public ModifyStatusExecutor(String pluginID, boolean active) { + public ModifyStatusExecutor(String pluginID) { this.pluginID = pluginID; - this.active = active; } @Override public String getTaskFinishMessage() { - return "插件" + pluginID + "已更改为可用状态:" + active; + return plugin.isActive() ? Inter.getLocText("FR-Designer-Plugin_Has_Been_Actived") : Inter.getLocText("FR-Designer-Plugin_Has_Been_Disabled"); } @Override public Command[] getCommands() { - return new Command[0]; + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return StringUtils.EMPTY; + } + @Override + public void run() { + plugin = PluginLoader.getLoader().getPluginById(pluginID); + active = !plugin.isActive(); + plugin.setActive(active); + try { + FRContext.getCurrentEnv().writePlugin(plugin); + PluginWebBridge.getHelper().showRestartMessage(plugin.isActive() ? Inter.getLocText("FR-Designer-Plugin_Has_Been_Actived") : Inter.getLocText("FR-Designer-Plugin_Has_Been_Disabled")); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage()); + } + } + } + }; } } diff --git a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java index 5138c1a58a..56b1c5304c 100644 --- a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java @@ -1,5 +1,14 @@ package com.fr.design.extra.exe; +import com.fr.base.FRContext; +import com.fr.design.RestartHelper; +import com.fr.design.extra.PluginHelper; +import com.fr.general.Inter; +import com.fr.plugin.Plugin; +import com.fr.plugin.PluginLoader; + +import javax.swing.*; + /** * Created by richie on 16/3/19. */ @@ -18,6 +27,45 @@ public class UninstallExecutor implements Executor { @Override public Command[] getCommands() { - return new Command[0]; + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return "删除成功"; + } + + @Override + public void run() { + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText("FR-Designer-Plugin_Will_Be_Delete"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), + Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later"), + Inter.getLocText("FR-Designer-Basic_Cancel") + }, + null + ); + if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { + return; + } + for (String pluginID : pluginIDs) { + try { + Plugin plugin = PluginLoader.getLoader().getPluginById(pluginID); + String[] filesToBeDelete = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), plugin); + RestartHelper.saveFilesWhichToDelete(filesToBeDelete); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + } + } + }; } } diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java index cfc0ab222a..26615b9b30 100644 --- a/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java @@ -1,5 +1,9 @@ package com.fr.design.extra.exe; +import com.fr.design.extra.PluginWebBridge; + +import java.io.File; + /** * Created by richie on 16/3/19. */ @@ -13,11 +17,23 @@ public class UpdateFromDiskExecutor implements Executor { @Override public String getTaskFinishMessage() { - return "插件已更新完毕"; + return "插件更新操作结束"; } @Override public Command[] getCommands() { - return new Command[0]; + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return null; + } + + @Override + public void run() { + PluginWebBridge.getHelper().updateFileFromDisk(new File(filePath)); + } + } + }; } } From 1987927759d80c828bead3bf708b7b03a4c59c91 Mon Sep 17 00:00:00 2001 From: vito Date: Sun, 17 Apr 2016 02:04:46 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=95=86=E5=BA=97?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9Bjava=E6=95=B0=E6=8D=AEAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginTask.java | 15 ++- .../src/com/fr/design/extra/exe/Command.java | 4 +- .../extra/exe/InstallFromDiskExecutor.java | 15 +-- .../extra/exe/InstallOnlineExecutor.java | 14 +-- .../extra/exe/ModifyStatusExecutor.java | 3 +- .../design/extra/exe/UninstallExecutor.java | 3 +- .../extra/exe/UpdateFromDiskExecutor.java | 3 +- .../extra/exe/UpdateOnlineExecutor.java | 95 +++++++++++++++++-- 8 files changed, 128 insertions(+), 24 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index e67f4e426e..a86e088b30 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -2,6 +2,7 @@ package com.fr.design.extra; import com.fr.design.extra.exe.Executor; import com.fr.design.extra.exe.Command; +import com.fr.stable.StringUtils; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.concurrent.Task; @@ -10,6 +11,7 @@ import netscape.javascript.JSObject; /** * 插件安装,卸载,更新等任务 + * * @param */ public class PluginTask extends Task { @@ -40,8 +42,17 @@ public class PluginTask extends Task { Command[] commands = executor.getCommands(); for (Command command : commands) { String message = command.getExecuteMessage(); - updateMessage(message); - command.run(); + if (StringUtils.isNotBlank(message)) { + updateMessage(message); + } + command.run(new Process() { + @Override + public void process(String s) { + if (StringUtils.isNotBlank(s)) { + updateMessage(s); + } + } + }); } return null; } diff --git a/designer_base/src/com/fr/design/extra/exe/Command.java b/designer_base/src/com/fr/design/extra/exe/Command.java index 5b117586e5..c16b0c2886 100644 --- a/designer_base/src/com/fr/design/extra/exe/Command.java +++ b/designer_base/src/com/fr/design/extra/exe/Command.java @@ -1,5 +1,7 @@ package com.fr.design.extra.exe; +import com.fr.design.extra.Process; + /** * Created by richie on 16/3/19. */ @@ -7,5 +9,5 @@ public interface Command { String getExecuteMessage(); - void run(); + void run(Process process); } diff --git a/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java b/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java index cb803f3141..da5222f967 100644 --- a/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/InstallFromDiskExecutor.java @@ -1,12 +1,12 @@ package com.fr.design.extra.exe; -import com.fr.design.RestartHelper; import com.fr.design.extra.After; import com.fr.design.extra.PluginHelper; import com.fr.design.extra.PluginWebBridge; +import com.fr.design.extra.Process; import com.fr.general.FRLogger; import com.fr.general.Inter; -import org.apache.poi.poifs.crypt.AgileDecryptor; +import com.fr.plugin.PluginVerifyException; import javax.swing.*; import java.io.File; @@ -37,7 +37,8 @@ public class InstallFromDiskExecutor implements Executor { } @Override - public void run() { + public void run(Process process) { + } }, new Command() { @@ -47,7 +48,7 @@ public class InstallFromDiskExecutor implements Executor { } @Override - public void run() { + public void run(Process process) { try { PluginHelper.installPluginFromDisk(new File(filePath), new After() { @Override @@ -56,8 +57,10 @@ public class InstallFromDiskExecutor implements Executor { PluginWebBridge.getHelper().showRestartMessage(Inter.getLocText("FR-Designer-Plugin_Install_Successful")); } }); - } catch (Exception e1) { - FRLogger.getLogger().error(e1.getMessage()); + } catch (PluginVerifyException e) { + JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); } } } diff --git a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java index 348898877f..bd3711bd6a 100644 --- a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java @@ -2,12 +2,12 @@ package com.fr.design.extra.exe; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; -import com.fr.design.RestartHelper; import com.fr.design.extra.After; import com.fr.design.extra.PluginHelper; import com.fr.design.extra.PluginWebBridge; import com.fr.design.extra.Process; import com.fr.general.Inter; +import com.fr.plugin.PluginVerifyException; import javax.swing.*; @@ -24,7 +24,7 @@ public class InstallOnlineExecutor implements Executor { @Override public String getTaskFinishMessage() { - return "已成功安裝"; + return "task succeed"; } @Override @@ -37,14 +37,14 @@ public class InstallOnlineExecutor implements Executor { } @Override - public void run() { + public void run(final Process process) { String username = DesignerEnvManager.getEnvManager().getBBSName(); String password = DesignerEnvManager.getEnvManager().getBBSPassword(); try { - PluginHelper.downloadPluginFile(pluginID,username,password, new Process() { + PluginHelper.downloadPluginFile(pluginID, username, password, new Process() { @Override public void process(Double integer) { - + process.process(Math.round(integer * 100) + "%"); } }); } catch (Exception e) { @@ -59,7 +59,7 @@ public class InstallOnlineExecutor implements Executor { } @Override - public void run() { + public void run(Process process) { try { PluginHelper.installPluginFromDisk(PluginHelper.getDownloadTempFile(), new After() { @Override @@ -67,6 +67,8 @@ public class InstallOnlineExecutor implements Executor { PluginWebBridge.getHelper().showRestartMessage(Inter.getLocText("FR-Designer-Plugin_Update_Successful")); } }); + } catch (PluginVerifyException e) { + JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } catch (InterruptedException e) { e.printStackTrace(); } catch (Exception e) { diff --git a/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java b/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java index 2d5b0f8c70..c3fb432628 100644 --- a/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java @@ -2,6 +2,7 @@ package com.fr.design.extra.exe; import com.fr.base.FRContext; import com.fr.design.extra.PluginWebBridge; +import com.fr.design.extra.Process; import com.fr.general.Inter; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLoader; @@ -34,7 +35,7 @@ public class ModifyStatusExecutor implements Executor { return StringUtils.EMPTY; } @Override - public void run() { + public void run(Process process) { plugin = PluginLoader.getLoader().getPluginById(pluginID); active = !plugin.isActive(); plugin.setActive(active); diff --git a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java index 56b1c5304c..3f0845a7af 100644 --- a/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java @@ -3,6 +3,7 @@ package com.fr.design.extra.exe; import com.fr.base.FRContext; import com.fr.design.RestartHelper; import com.fr.design.extra.PluginHelper; +import com.fr.design.extra.Process; import com.fr.general.Inter; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLoader; @@ -35,7 +36,7 @@ public class UninstallExecutor implements Executor { } @Override - public void run() { + public void run(Process process) { int rv = JOptionPane.showOptionDialog( null, Inter.getLocText("FR-Designer-Plugin_Will_Be_Delete"), diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java index 26615b9b30..5c8c6e3615 100644 --- a/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UpdateFromDiskExecutor.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe; import com.fr.design.extra.PluginWebBridge; +import com.fr.design.extra.Process; import java.io.File; @@ -30,7 +31,7 @@ public class UpdateFromDiskExecutor implements Executor { } @Override - public void run() { + public void run(Process process) { PluginWebBridge.getHelper().updateFileFromDisk(new File(filePath)); } } diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java index a5f49ea6ea..4621dc3dbb 100644 --- a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java @@ -1,23 +1,106 @@ package com.fr.design.extra.exe; +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; +import com.fr.design.extra.After; +import com.fr.design.extra.PluginHelper; +import com.fr.design.extra.Process; +import com.fr.general.Inter; +import com.fr.plugin.Plugin; +import com.fr.plugin.PluginLoader; + +import javax.swing.*; +import java.io.File; + /** * Created by richie on 16/3/19. */ public class UpdateOnlineExecutor implements Executor { - private String pluginID; - - public UpdateOnlineExecutor(String pluginID) { - this.pluginID = pluginID; + private String[] pluginIDs; + private static final int PERCENT_100 = 100; + public UpdateOnlineExecutor(String[] pluginIDs) { + this.pluginIDs = pluginIDs; } + @Override public String getTaskFinishMessage() { - return "插件已更新完毕:" + pluginID; + return "task succeed"; } @Override public Command[] getCommands() { - return new Command[0]; + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return null; + } + + @Override + public void run(Process process) { + for (int i = 0; i < pluginIDs.length; i++) { + Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); + String id = null; + if (plugin != null) { + id = plugin.getId(); + } + String username = DesignerEnvManager.getEnvManager().getBBSName(); + String password = DesignerEnvManager.getEnvManager().getBBSPassword(); + try { + PluginHelper.downloadPluginFile(id, username, password, new Process() { + @Override + public void process(Double integer) { + } + }); + updateFileFromDisk(PluginHelper.getDownloadTempFile()); + process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + } + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText("FR-Designer-Plugin_Update_Successful"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), + Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") + }, + null + ); + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } + } + } + }; + } + + private void updateFileFromDisk(File fileOnDisk){ + try { + Plugin plugin = PluginHelper.readPlugin(fileOnDisk); + if (plugin == null) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + return; + } + Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); + if (oldPlugin != null) { + String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); + PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { + @Override + public void done() { + } + }); + } else { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + } } } From 805dc0695945a451ae27ec36403cd42601431751 Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 18 Apr 2016 02:06:22 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=95=86=E5=BA=97?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/server/PluginManagerAction.java | 4 +- .../src/com/fr/design/dialog/BasicDialog.java | 1 - .../src/com/fr/design/dialog/BasicPane.java | 24 ---------- .../com/fr/design/extra/PluginWebBridge.java | 18 +++++++- .../src/com/fr/design/extra/ShopDialog.java | 26 +++++++++++ .../fr/design/extra/exe/searchExecutor.java | 46 +++++++++++++++++++ 6 files changed, 91 insertions(+), 28 deletions(-) create mode 100644 designer_base/src/com/fr/design/extra/ShopDialog.java create mode 100644 designer_base/src/com/fr/design/extra/exe/searchExecutor.java diff --git a/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java b/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java index 4225f0c4f3..b6e3e25c08 100644 --- a/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java +++ b/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java @@ -6,6 +6,7 @@ import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.UIDialog; import com.fr.design.extra.PluginManagerPane; import com.fr.design.extra.PluginWebBridge; +import com.fr.design.extra.ShopDialog; import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; @@ -30,8 +31,7 @@ public class PluginManagerAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { final PluginManagerPane managerPane = new PluginManagerPane(); - //// TODO: 16/4/11 重新写下这个界面窗口. - BasicDialog dlg = managerPane.showCustomSizeWindow(DesignerContext.getDesignerFrame(), null, BasicDialog.LARGE_SHOP); + UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(),managerPane); PluginWebBridge.getHelper().setDialogHandle(dlg); dlg.setVisible(true); } diff --git a/designer_base/src/com/fr/design/dialog/BasicDialog.java b/designer_base/src/com/fr/design/dialog/BasicDialog.java index a1f2785cfd..703b192055 100644 --- a/designer_base/src/com/fr/design/dialog/BasicDialog.java +++ b/designer_base/src/com/fr/design/dialog/BasicDialog.java @@ -10,7 +10,6 @@ public abstract class BasicDialog extends UIDialog { public static final Dimension MEDIUM = new Dimension(600, 400); public static final Dimension DEFAULT = new Dimension(660, 600); public static final Dimension LARGE = new Dimension(900, 600); - public static final Dimension LARGE_SHOP = new Dimension(900, 760); public static final Dimension CHART = new Dimension(760, 560); public static final Dimension MAP_SIZE = new Dimension(760, 450); public static final Dimension UPDATE_ONLINE_SIZE = new Dimension(600,300); diff --git a/designer_base/src/com/fr/design/dialog/BasicPane.java b/designer_base/src/com/fr/design/dialog/BasicPane.java index 09190f20fb..9bc96f6439 100644 --- a/designer_base/src/com/fr/design/dialog/BasicPane.java +++ b/designer_base/src/com/fr/design/dialog/BasicPane.java @@ -171,30 +171,6 @@ public abstract class BasicPane extends JPanel { return dg; } - /** - * 显示自定义大小的窗口 - * - * @param window 窗口 - * @param l 对话框监听器 - * @param dimension 窗口大小 - * @return 对话框 - */ - public BasicDialog showCustomSizeWindow(Window window, DialogActionListener l, Dimension dimension) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - if (l != null) { - dg.addDialogActionListener(l); - } - dg.setBasicDialogSize(dimension); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; - } - /** * 显示窗口 * diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index ce6dd8fba3..378e904590 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -31,6 +31,8 @@ public class PluginWebBridge { private UIDialog uiDialog; + public static final String PLUGIN_SHOP = "http://127.0.0.1:8080/ShopServer?pg=plist"; + public static PluginWebBridge getHelper() { if (helper != null) { return helper; @@ -196,7 +198,7 @@ public class PluginWebBridge { public String getPluginFromStore(String category, String seller, String fee) { - StringBuilder url = new StringBuilder("http://127.0.0.1:8080/ShopServer?pg=plist"); + StringBuilder url = new StringBuilder(PLUGIN_SHOP); if (StringUtils.isNotBlank(category)) { url.append("&cid=").append(category.split("-")[1]); } @@ -217,6 +219,20 @@ public class PluginWebBridge { return resText == null ? StringUtils.EMPTY : resText; } + /** + * 搜索在线插件 + * + * @param keyword 关键字 + */ + public String searchPlugin(String keyword) { + try { + HttpClient httpClient = new HttpClient(PluginWebBridge.PLUGIN_SHOP + "&keyword=" + keyword); + return httpClient.getResponseText(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + return StringUtils.EMPTY; + } public void showRestartMessage(String message){ int rv = JOptionPane.showOptionDialog( diff --git a/designer_base/src/com/fr/design/extra/ShopDialog.java b/designer_base/src/com/fr/design/extra/ShopDialog.java new file mode 100644 index 0000000000..e394c0c1f5 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/ShopDialog.java @@ -0,0 +1,26 @@ +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 java.awt.*; + +/** + * Created by vito on 16/4/18. + */ +public class ShopDialog extends UIDialog{ + private static final Dimension DEFAULT_SHOP = new Dimension(900, 760); + + public ShopDialog(Frame frame, BasicPane pane) { + super(frame, pane,false); + setSize(DEFAULT_SHOP); + GUICoreUtils.centerWindow(this); + setResizable(false); + } + + @Override + public void checkValid() throws Exception { + + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/searchExecutor.java b/designer_base/src/com/fr/design/extra/exe/searchExecutor.java new file mode 100644 index 0000000000..afa4971d57 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/searchExecutor.java @@ -0,0 +1,46 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.PluginWebBridge; +import com.fr.design.extra.Process; +import com.fr.general.FRLogger; +import com.fr.general.http.HttpClient; +import com.fr.stable.StringUtils; + +/** + * Created by vito on 16/4/18. + */ +public class SearchExecutor implements Executor { + private String result; + private String keyword; + + public SearchExecutor(String keyword) { + this.keyword = keyword; + } + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return StringUtils.EMPTY; + } + + @Override + public void run(Process process) { + try { + HttpClient httpClient = new HttpClient(PluginWebBridge.PLUGIN_SHOP + "&keyword=" + keyword); + result = httpClient.getResponseText(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + } + }; + } +} From 31cc16f4c89417c0ccc4dfaf40916bc712317854 Mon Sep 17 00:00:00 2001 From: vito Date: Mon, 18 Apr 2016 19:47:57 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=95=86=E5=BA=97=E6=9B=B4=E6=96=B0=E5=92=8C=E6=90=9C?= =?UTF-8?q?=E7=B4=A2API=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/bbs/BBSDialog.java | 55 +++------ .../actions/server/PluginManagerAction.java | 5 +- .../fr/design/extra/PluginManagerPane.java | 13 --- ...{ShopDialog.java => PluginShopDialog.java} | 9 +- .../extra/PluginStatusCheckCompletePane.java | 4 +- .../src/com/fr/design/extra/PluginTask.java | 18 ++- .../com/fr/design/extra/PluginUpdatePane.java | 22 ++-- .../com/fr/design/extra/PluginWebBridge.java | 104 +++++++++++------- .../com/fr/design/extra/PluginWebPane.java | 27 ++++- .../extra/exe/GetPluginFromStoreExecutor.java | 61 ++++++++++ .../extra/exe/ModifyStatusExecutor.java | 1 + .../extra/exe/UpdateOnlineExecutor.java | 10 +- 12 files changed, 208 insertions(+), 121 deletions(-) rename designer_base/src/com/fr/design/extra/{ShopDialog.java => PluginShopDialog.java} (74%) create mode 100644 designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java index 856e9264a1..bedbc8d3c2 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.bbs; import com.fr.design.dialog.UIDialog; +import com.fr.design.extra.PluginWebBridge; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; @@ -19,8 +20,6 @@ import netscape.javascript.JSObject; import javax.swing.*; import java.awt.*; -import java.io.IOException; -import java.net.URI; /** * @author richie @@ -53,7 +52,7 @@ public class BBSDialog extends UIDialog { } private void disableLink(final WebEngine eng) { - try{ + try { // webView端不跳转 虽然webView可以指定本地浏览器打开某个链接,但是当本地浏览器跳转到指定链接的同时,webView也做了跳转, // 为了避免出现在一个600*400的资讯框里加载整个网页的情况,webView不跳转到新网页 Platform.runLater(new Runnable() { @@ -62,16 +61,17 @@ public class BBSDialog extends UIDialog { eng.executeScript("history.go(0)"); } }); - }catch(Exception e){ + } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } } /** * 打开资讯框 + * * @param url 资讯链接 */ - public void showWindow(final String url){ + public void showWindow(final String url) { GUICoreUtils.centerWindow(this); this.setResizable(false); Platform.runLater(new Runnable() { @@ -92,20 +92,19 @@ public class BBSDialog extends UIDialog { root.getChildren().add(view); eng.locationProperty().addListener(new ChangeListener() { @Override - public void changed(ObservableValue observable, final String oldValue, String newValue) - { - disableLink(eng); - // webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转 - if(ComparatorUtils.equals(newValue, url) || ComparatorUtils.equals(newValue, BBSConstants.BBS_MOBILE_MOD)){ - return; - } - openUrlAtLocalWebBrowser(eng,newValue); - } - }); + public void changed(ObservableValue observable, final String oldValue, String newValue) { + disableLink(eng); + // webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转 + if (ComparatorUtils.equals(newValue, url) || ComparatorUtils.equals(newValue, BBSConstants.BBS_MOBILE_MOD)) { + return; + } + PluginWebBridge.getHelper().openUrlAtLocalWebBrowser(eng, newValue); + } + }); eng.getLoadWorker().stateProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Worker.State oldValue, Worker.State newValue) { - if (newValue == Worker.State.SUCCEEDED){ + if (newValue == Worker.State.SUCCEEDED) { JSObject obj = (JSObject) eng.executeScript("window"); obj.setMember("BBSWebBridge", BBSDialog.this); setVisible(true); @@ -116,29 +115,6 @@ public class BBSDialog extends UIDialog { }); } - // 在本地浏览器里打开url - private void openUrlAtLocalWebBrowser(WebEngine eng,String url){ - 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()); - } - } - } - /** * 提供给web页面调用的关闭窗口 */ @@ -146,6 +122,7 @@ public class BBSDialog extends UIDialog { this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setVisible(false); } + /** * 略 */ diff --git a/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java b/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java index b6e3e25c08..d88fdf9929 100644 --- a/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java +++ b/designer_base/src/com/fr/design/actions/server/PluginManagerAction.java @@ -2,11 +2,10 @@ package com.fr.design.actions.server; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; -import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.UIDialog; import com.fr.design.extra.PluginManagerPane; import com.fr.design.extra.PluginWebBridge; -import com.fr.design.extra.ShopDialog; +import com.fr.design.extra.PluginShopDialog; import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; @@ -31,7 +30,7 @@ public class PluginManagerAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { final PluginManagerPane managerPane = new PluginManagerPane(); - UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(),managerPane); + UIDialog dlg = new PluginShopDialog(DesignerContext.getDesignerFrame(),managerPane); PluginWebBridge.getHelper().setDialogHandle(dlg); dlg.setVisible(true); } diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index d2e267ed07..f1209a6ead 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -2,23 +2,10 @@ package com.fr.design.extra; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UITabbedPane; -import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.StableUtils; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.concurrent.Worker; -import javafx.scene.web.WebEngine; -import javax.script.Bindings; -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.swing.*; import java.awt.*; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; import java.net.URL; /** diff --git a/designer_base/src/com/fr/design/extra/ShopDialog.java b/designer_base/src/com/fr/design/extra/PluginShopDialog.java similarity index 74% rename from designer_base/src/com/fr/design/extra/ShopDialog.java rename to designer_base/src/com/fr/design/extra/PluginShopDialog.java index e394c0c1f5..5d04401b29 100644 --- a/designer_base/src/com/fr/design/extra/ShopDialog.java +++ b/designer_base/src/com/fr/design/extra/PluginShopDialog.java @@ -9,11 +9,11 @@ import java.awt.*; /** * Created by vito on 16/4/18. */ -public class ShopDialog extends UIDialog{ - private static final Dimension DEFAULT_SHOP = new Dimension(900, 760); +public class PluginShopDialog extends UIDialog { + private static final Dimension DEFAULT_SHOP = new Dimension(900, 710); - public ShopDialog(Frame frame, BasicPane pane) { - super(frame, pane,false); + public PluginShopDialog(Frame frame, BasicPane pane) { + super(frame, pane, false); setSize(DEFAULT_SHOP); GUICoreUtils.centerWindow(this); setResizable(false); @@ -21,6 +21,5 @@ public class ShopDialog extends UIDialog{ @Override public void checkValid() throws Exception { - } } diff --git a/designer_base/src/com/fr/design/extra/PluginStatusCheckCompletePane.java b/designer_base/src/com/fr/design/extra/PluginStatusCheckCompletePane.java index cf772d5d66..46f55d40be 100644 --- a/designer_base/src/com/fr/design/extra/PluginStatusCheckCompletePane.java +++ b/designer_base/src/com/fr/design/extra/PluginStatusCheckCompletePane.java @@ -67,8 +67,8 @@ public abstract class PluginStatusCheckCompletePane extends PluginAbstractViewPa public void setProgress(double percent) { progressBar.setVisible(true); - progressBar.setValue((int)percent); - progressBar.setString((int)percent + "%"); + progressBar.setValue((int) percent); + progressBar.setString((int) percent + "%"); progressBar.repaint(); } diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index a86e088b30..5efcdd1d41 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -27,7 +27,7 @@ public class PluginTask extends Task { messageProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, String oldValue, String newValue) { - String fun = "(" + callback + ")('" + newValue + "')"; + String fun = "(" + callback + ")(\"" + newValue + "\")"; try { webEngine.executeScript(fun); } catch (Exception e) { @@ -49,7 +49,7 @@ public class PluginTask extends Task { @Override public void process(String s) { if (StringUtils.isNotBlank(s)) { - updateMessage(s); + updateMessage(changText(s)); } } }); @@ -59,6 +59,18 @@ public class PluginTask extends Task { @Override protected void done() { - updateMessage(executor.getTaskFinishMessage()); + updateMessage(changText(executor.getTaskFinishMessage())); + } + + /** + * 转换掉一些会造成错误的特殊字符 + * 1 ""中的""必须转义 + * 2 js字符串中的\n会导致js字符串变成多行,而js字符创不支持多行拼接 + * + * @param old 原始字符串 + * @return 处理之后的字符串 + */ + private String changText(String old) { + return old.replaceAll("\"", "\\\\\"").replaceAll("\n", ""); } } diff --git a/designer_base/src/com/fr/design/extra/PluginUpdatePane.java b/designer_base/src/com/fr/design/extra/PluginUpdatePane.java index 33d9763723..e0b3ada35d 100644 --- a/designer_base/src/com/fr/design/extra/PluginUpdatePane.java +++ b/designer_base/src/com/fr/design/extra/PluginUpdatePane.java @@ -25,7 +25,7 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane(){ + if (StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getBBSName())) { + new SwingWorker() { @Override protected Void doInBackground() throws Exception { @@ -181,7 +183,7 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane() { + PluginHelper.downloadPluginFile(id, username, password, new Process() { @Override public void process(Double integer) { publish(integer); @@ -264,12 +266,14 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane alert = new Dialog<>(); -// alert.getDialogPane().setContentText(message); -// alert.getDialogPane().getButtonTypes().add(ButtonType.OK); -// alert.showAndWait(); } } diff --git a/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java new file mode 100644 index 0000000000..030b22f216 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java @@ -0,0 +1,61 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.PluginWebBridge; +import com.fr.design.extra.Process; +import com.fr.general.FRLogger; +import com.fr.general.http.HttpClient; +import com.fr.stable.StringUtils; + +/** + * Created by vito on 16/4/18. + * 获取插件分类信息 + */ +public class GetPluginFromStoreExecutor implements Executor { + private String result = "[]"; + private String category; + private String seller; + private String fee; + + public GetPluginFromStoreExecutor(String category, String seller, String fee) { + this.category = category; + this.seller = seller; + this.fee = fee; + } + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return StringUtils.EMPTY; + } + + @Override + public void run(Process process) { + StringBuilder url = new StringBuilder(PluginWebBridge.PLUGIN_SHOP); + if (StringUtils.isNotBlank(category)) { + url.append("&cid=").append(category.split("-")[1]); + } + if (StringUtils.isNotBlank(seller)) { + url.append("&seller=").append(seller.split("-")[1]); + } + if (StringUtils.isNotBlank(fee)) { + url.append("&fee=").append(fee.split("-")[1]); + } + try { + HttpClient httpClient = new HttpClient(url.toString()); + result = httpClient.getResponseText(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + } + }; + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java b/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java index c3fb432628..c544858dd8 100644 --- a/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/ModifyStatusExecutor.java @@ -34,6 +34,7 @@ public class ModifyStatusExecutor implements Executor { public String getExecuteMessage() { return StringUtils.EMPTY; } + @Override public void run(Process process) { plugin = PluginLoader.getLoader().getPluginById(pluginID); diff --git a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java index 4621dc3dbb..f1c3b0f040 100644 --- a/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java @@ -81,7 +81,7 @@ public class UpdateOnlineExecutor implements Executor { }; } - private void updateFileFromDisk(File fileOnDisk){ + private void updateFileFromDisk(File fileOnDisk) { try { Plugin plugin = PluginHelper.readPlugin(fileOnDisk); if (plugin == null) { @@ -92,10 +92,10 @@ public class UpdateOnlineExecutor implements Executor { if (oldPlugin != null) { String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { - @Override - public void done() { - } - }); + @Override + public void done() { + } + }); } else { JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } From 3921be849ba08b3d4753a63857f896aebdd39094 Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 19 Apr 2016 09:30:33 +0800 Subject: [PATCH 08/19] =?UTF-8?q?jdk1.8=E6=89=93=E5=BC=80=E6=96=B0?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginManagerPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index f1209a6ead..bd4e50ec4f 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -24,7 +24,8 @@ public class PluginManagerPane extends BasicPane { public PluginManagerPane() { setLayout(new BorderLayout()); - if (StableUtils.isDebug()) { + if (System.getProperty("java.version").startsWith("1.8")) { + System.out.println(System.getProperty("java.version")); URL url = ClassLoader.getSystemResource(""); String installHome = url.getPath(); PluginWebPane webPane = new PluginWebPane(installHome); From ad4bc04cde88540e8d1f578b7ea6839c077af6ce Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 19 Apr 2016 09:30:59 +0800 Subject: [PATCH 09/19] =?UTF-8?q?dubug=E5=8E=BB=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginManagerPane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index bd4e50ec4f..ef008717d1 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -25,7 +25,6 @@ public class PluginManagerPane extends BasicPane { public PluginManagerPane() { setLayout(new BorderLayout()); if (System.getProperty("java.version").startsWith("1.8")) { - System.out.println(System.getProperty("java.version")); URL url = ClassLoader.getSystemResource(""); String installHome = url.getPath(); PluginWebPane webPane = new PluginWebPane(installHome); From ada306b10b5e51c87fd2d6392ce4aae8fd1095bd Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 19 Apr 2016 09:46:36 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E6=BC=8F=E6=8E=89=E4=B8=80=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ebfc6188b6..ec8c85a73c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ designer/bin designer_base/bin designer_chart/bin designer_form/bin +*.iml From 2a0c239ad137dea2977b7dde3d0b5ca60edea64c Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 19 Apr 2016 09:49:45 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginManagerPane.java | 1 - designer_base/src/com/fr/design/extra/PluginWebBridge.java | 2 +- .../exe/{searchExecutor.java => SearchOnlineExecutor.java} | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename designer_base/src/com/fr/design/extra/exe/{searchExecutor.java => SearchOnlineExecutor.java} (91%) diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index ef008717d1..3a63c685ba 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -3,7 +3,6 @@ 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 java.awt.*; import java.net.URL; diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 9086909667..65ef0c56d7 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -205,7 +205,7 @@ public class PluginWebBridge { * @param keyword 关键字 */ public void searchPlugin(String keyword, final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new SearchExecutor(keyword)); + Task task = new PluginTask<>(webEngine, callback, new SearchOnlineExecutor(keyword)); new Thread(task).start(); } diff --git a/designer_base/src/com/fr/design/extra/exe/searchExecutor.java b/designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java similarity index 91% rename from designer_base/src/com/fr/design/extra/exe/searchExecutor.java rename to designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java index afa4971d57..a94fcc5f20 100644 --- a/designer_base/src/com/fr/design/extra/exe/searchExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java @@ -9,11 +9,11 @@ import com.fr.stable.StringUtils; /** * Created by vito on 16/4/18. */ -public class SearchExecutor implements Executor { +public class SearchOnlineExecutor implements Executor { private String result; private String keyword; - public SearchExecutor(String keyword) { + public SearchOnlineExecutor(String keyword) { this.keyword = keyword; } @@ -36,6 +36,7 @@ public class SearchExecutor implements Executor { try { HttpClient httpClient = new HttpClient(PluginWebBridge.PLUGIN_SHOP + "&keyword=" + keyword); result = httpClient.getResponseText(); + } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } From 102e0cdf8332ee66621e41fadfa27f2275ff200a Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 19 Apr 2016 15:21:55 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=88=86?= =?UTF-8?q?=E7=BB=84=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/DesignModelAdapter.java | 16 ++++++-- .../fr/design/ExtraDesignClassManager.java | 12 ++++++ .../design/data/datapane/TableDataTree.java | 33 +++++++++++++++- .../data/datapane/TableDataTreePane.java | 36 ++++++++++++++---- .../fun/TableDataSourceManagerProcessor.java | 38 +++++++++++++++++++ .../AbstractTDSourceManagerProcessor.java | 15 ++++++++ 6 files changed, 137 insertions(+), 13 deletions(-) create mode 100644 designer_base/src/com/fr/design/fun/TableDataSourceManagerProcessor.java create mode 100644 designer_base/src/com/fr/design/fun/impl/AbstractTDSourceManagerProcessor.java diff --git a/designer_base/src/com/fr/design/DesignModelAdapter.java b/designer_base/src/com/fr/design/DesignModelAdapter.java index 7c2c718068..8e35dbf387 100644 --- a/designer_base/src/com/fr/design/DesignModelAdapter.java +++ b/designer_base/src/com/fr/design/DesignModelAdapter.java @@ -1,9 +1,5 @@ package com.fr.design; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import com.fr.base.Parameter; import com.fr.base.io.IOFile; import com.fr.data.TableDataSource; @@ -13,6 +9,10 @@ import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.stable.js.WidgetName; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + /** * 当前的设计器模式 * @@ -29,6 +29,14 @@ public abstract class DesignModelAdapter { treeModel.reload(root); } + /** + * @param nameOfNewNode 新添加的节点名字 + * @param insertMode 添加的节点的类型,模板、服务器、 存储过程、分组 + * @param tc + */ + public void insertNewNodeToSelectedNode(String nameOfNewNode, int insertMode, DesignModelAdapter tc){ + + } + + /** + * 删除选中节点 + * @param nodeName 节点名称 + * @param removeMode 删除模式 + * @param tc tc + */ + public void removeSelectedNode(String nodeName, int removeMode, DesignModelAdapter tc) { + + } + + /** + * 更新节点 + * @param newName 新名称 + * @param oldName 原名称 + * @param updateMode 更新模式 + * @param tc tc + */ + public void updateNameOfSelectedNode(String newName, String oldName, int updateMode, DesignModelAdapter tc){ + + } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java index a0b4fb3bf3..364be2131a 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java @@ -6,6 +6,7 @@ import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.DesignModelAdapter; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.ResponseDataSourceChange; @@ -18,6 +19,7 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.fun.TableDataSourceManagerProcessor; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; @@ -27,10 +29,7 @@ import com.fr.design.icon.IconPathConstants; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DockingView; -import com.fr.design.menu.LineSeparator; -import com.fr.design.menu.MenuDef; -import com.fr.design.menu.SeparatorDef; -import com.fr.design.menu.ToolBarDef; +import com.fr.design.menu.*; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; @@ -92,7 +91,7 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource private TableDataTreePane() { this.setLayout(new BorderLayout(4, 0)); this.setBorder(null); - dataTree = new TableDataTree(); + initTableDataTree(); ToolTipManager.sharedInstance().registerComponent(dataTree); ToolTipManager.sharedInstance().setDismissDelay(3000); ToolTipManager.sharedInstance().setInitialDelay(0); @@ -108,13 +107,21 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource createAddMenuDef(); } }); - + ToolBarDef toolbarDef = new ToolBarDef(); editAction = new EditAction(); removeAction = new RemoveAction(); previewTableDataAction = new PreviewTableDataAction(); connectionTableAction = new ConnectionTableAction(); - ToolBarDef toolbarDef = new ToolBarDef(); + ShortCut[] shortCuts = null; + TableDataSourceManagerProcessor opProcessor = ExtraDesignClassManager.getInstance().getTableDataSourceManagerProcessor(); + if (opProcessor != null) { + shortCuts = opProcessor.getShortCuts(dataTree); + } else { + shortCuts = new ShortCut[]{addMenuDef, SeparatorDef.DEFAULT, editAction, removeAction, SeparatorDef.DEFAULT, previewTableDataAction, connectionTableAction}; + } + toolbarDef.addShortCut(shortCuts); toolbarDef.addShortCut(addMenuDef, SeparatorDef.DEFAULT, editAction, removeAction, SeparatorDef.DEFAULT, previewTableDataAction, connectionTableAction); + UIToolbar toolBar = ToolBarDef.createJToolBar(); toolbarDef.updateToolBar(toolBar); @@ -147,6 +154,14 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource checkButtonEnabled(); } + private void initTableDataTree() { + TableDataSourceManagerProcessor opProcessor = ExtraDesignClassManager.getInstance().getTableDataSourceManagerProcessor(); + if (opProcessor != null) { + dataTree = opProcessor.createUserObjectJtree(); + } + dataTree = new TableDataTree(); + } + private KeyAdapter getTableTreeNodeListener() { return new KeyAdapter() { @@ -278,7 +293,12 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource * 刷新 */ public void refreshDockingView() { - populate(new TableDataSourceOP(tc)); + TableDataSourceOP tableDataSourceOP = null; + TableDataSourceManagerProcessor opProcessor = ExtraDesignClassManager.getInstance().getTableDataSourceManagerProcessor(); + if (opProcessor != null) { + tableDataSourceOP = opProcessor.createTableDataSourceOP(tc); + } + populate(tableDataSourceOP == null ? new TableDataSourceOP(tc) : tableDataSourceOP); this.checkButtonEnabled(); } diff --git a/designer_base/src/com/fr/design/fun/TableDataSourceManagerProcessor.java b/designer_base/src/com/fr/design/fun/TableDataSourceManagerProcessor.java new file mode 100644 index 0000000000..fbb8095a9c --- /dev/null +++ b/designer_base/src/com/fr/design/fun/TableDataSourceManagerProcessor.java @@ -0,0 +1,38 @@ +package com.fr.design.fun; + +import com.fr.design.DesignModelAdapter; +import com.fr.design.data.datapane.TableDataSourceOP; +import com.fr.design.data.datapane.TableDataTree; +import com.fr.design.menu.ShortCut; +import com.fr.stable.fun.Level; + +/** + * 自定义的模板(服务器)数据集的树样式接口 el:分组样式 + * Coder: zack + * Date: 2016/4/18 + * Time: 9:04 + */ +public interface TableDataSourceManagerProcessor extends Level { + String XML_TAG = "TableDataSourceManagerProcessor"; + + int CURRENT_LEVEL = 1; + /** + * 创建数据集的树操作 + * @param tc 设计模式 + * @return 数据集树操作 + */ + TableDataSourceOP createTableDataSourceOP(DesignModelAdapter tc); + + /** + * 创建相应的tabledatatree + * @return tabledatatree + */ + TableDataTree createUserObjectJtree(); + + /** + * 返回面板新增的action(el:GroupAction) + * @return (shortcut)action数组 + */ + ShortCut[] getShortCuts(TableDataTree dataTree); + +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractTDSourceManagerProcessor.java b/designer_base/src/com/fr/design/fun/impl/AbstractTDSourceManagerProcessor.java new file mode 100644 index 0000000000..4550023ea2 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractTDSourceManagerProcessor.java @@ -0,0 +1,15 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.TableDataSourceManagerProcessor; + +/** + * Coder: zack + * Date: 2016/4/18 + * Time: 10:30 + */ +public abstract class AbstractTDSourceManagerProcessor implements TableDataSourceManagerProcessor { + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} From 29cea2762cc9284135b10dc65dc2e47e90e9a04d Mon Sep 17 00:00:00 2001 From: zhouping Date: Tue, 19 Apr 2016 15:56:55 +0800 Subject: [PATCH 13/19] =?UTF-8?q?bug:89768=20tab=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E6=B2=A1=E6=B3=95=E5=9C=A8=E5=8F=B3=E8=BE=B9=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E6=96=B0=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/designer/beans/painters/FRFitLayoutPainter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer_form/src/com/fr/design/designer/beans/painters/FRFitLayoutPainter.java b/designer_form/src/com/fr/design/designer/beans/painters/FRFitLayoutPainter.java index 79f7356843..8634ae1722 100644 --- a/designer_form/src/com/fr/design/designer/beans/painters/FRFitLayoutPainter.java +++ b/designer_form/src/com/fr/design/designer/beans/painters/FRFitLayoutPainter.java @@ -93,6 +93,8 @@ public class FRFitLayoutPainter extends AbstractPainter{ int containerHeight = container.getHeight(); // 当前坐标点 Rectangle currentXY = new Rectangle(x, y, 1, 1); + hot_rec = new int[]{0, 0, 0, 0}; + // 上边缘 Rectangle upEdge = new Rectangle(containerX, containerY, containerWidth, BORDER_PROPORTION); if(upEdge.intersects(currentXY)){ From a7cd005363064cd0b24f82df6fd1ce227f6b57c1 Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 19 Apr 2016 16:45:19 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ExtraDesignClassManager.java | 12 +-- .../data/datapane/TableDataSourceOP.java | 18 ++-- .../design/data/datapane/TableDataTree.java | 36 +------- .../data/datapane/TableDataTreePane.java | 92 ++++++++++++------- .../fun/TableDataSourceManagerProcessor.java | 38 -------- .../fun/TableDataTreePaneProcessor.java | 22 +++++ ....java => AbstractTDTreePaneProcessor.java} | 4 +- .../mainframe/WestRegionContainerPane.java | 20 +++- 8 files changed, 115 insertions(+), 127 deletions(-) delete mode 100644 designer_base/src/com/fr/design/fun/TableDataSourceManagerProcessor.java create mode 100644 designer_base/src/com/fr/design/fun/TableDataTreePaneProcessor.java rename designer_base/src/com/fr/design/fun/impl/{AbstractTDSourceManagerProcessor.java => AbstractTDTreePaneProcessor.java} (52%) diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index e2cfbedc72..c761430e95 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -126,15 +126,15 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi private DesignerEnvProcessor envProcessor; - private TableDataSourceManagerProcessor tableDataSourceManagerProcessor; + private TableDataTreePaneProcessor tableDataTreePaneProcessor; - public TableDataSourceManagerProcessor getTableDataSourceManagerProcessor() { - return tableDataSourceManagerProcessor; + public TableDataTreePaneProcessor getTableDataTreePaneProcessor() { + return tableDataTreePaneProcessor; } public void setTableDataSourceOPProcessor(Level level, PluginSimplify simplify) { - validAPILevel(level, TableDataSourceManagerProcessor.CURRENT_LEVEL, simplify.getPluginName()); - tableDataSourceManagerProcessor = (TableDataSourceManagerProcessor) level; + validAPILevel(level, TableDataTreePaneProcessor.CURRENT_LEVEL, simplify.getPluginName()); + tableDataTreePaneProcessor = (TableDataTreePaneProcessor) level; } public DesignerEnvProcessor getEnvProcessor() { @@ -807,7 +807,7 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi addSupportDesignApps(impl, simplify); } else if (tagName.equals(DesignerEnvProcessor.XML_TAG)) { setEnvProcessor(impl, simplify); - } else if (tagName.equals(TableDataSourceManagerProcessor.XML_TAG)) { + } else if (tagName.equals(TableDataTreePaneProcessor.XML_TAG)) { setTableDataSourceOPProcessor(impl, simplify); } } catch (PluginInvalidLevelException e) { diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java b/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java index 03ed0dfbb6..fdb5695baa 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java @@ -1,26 +1,22 @@ package com.fr.design.data.datapane; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import com.fr.general.NameObject; import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; -import com.fr.design.data.DesignTableDataManager; import com.fr.data.TableDataSource; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedureConstants; +import com.fr.design.DesignModelAdapter; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper; import com.fr.design.data.tabledata.wrapper.StoreProcedureNameWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; -import com.fr.design.DesignModelAdapter; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.UserObjectOP; import com.fr.general.Inter; +import com.fr.general.NameObject; + +import java.util.*; +import java.util.Map.Entry; /** * 数据集树的操作 @@ -34,7 +30,7 @@ public class TableDataSourceOP implements UserObjectOP { public static final int STORE_PRECEDURE_DATA = 2; public static int dataMode = -1; - private DesignModelAdapter tc; + protected DesignModelAdapter tc; public TableDataSourceOP(DesignModelAdapter tc) { diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTree.java b/designer_base/src/com/fr/design/data/datapane/TableDataTree.java index cf400b735e..82663e4999 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTree.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTree.java @@ -1,7 +1,7 @@ package com.fr.design.data.datapane; import com.fr.base.BaseUtils; -import com.fr.design.DesignModelAdapter; +import com.fr.general.NameObject; import com.fr.design.constants.UIConstants; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.ilable.UILabel; @@ -9,7 +9,6 @@ import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree; import com.fr.design.icon.IconPathConstants; import com.fr.general.ComparatorUtils; -import com.fr.general.NameObject; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -32,9 +31,8 @@ public class TableDataTree extends UserObjectRefreshJTree { this.setCellRenderer(tableDataTreeCellRenderer); this.setEditable(false); } - // CellRenderer - private DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() { + protected DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() { private static final long serialVersionUID = 1L; @Override @@ -242,34 +240,4 @@ public class TableDataTree extends UserObjectRefreshJTree { treeModel.reload(root); } - /** - * @param nameOfNewNode 新添加的节点名字 - * @param insertMode 添加的节点的类型,模板、服务器、 存储过程、分组 - * @param tc - */ - public void insertNewNodeToSelectedNode(String nameOfNewNode, int insertMode, DesignModelAdapter tc){ - - } - - /** - * 删除选中节点 - * @param nodeName 节点名称 - * @param removeMode 删除模式 - * @param tc tc - */ - public void removeSelectedNode(String nodeName, int removeMode, DesignModelAdapter tc) { - - } - - /** - * 更新节点 - * @param newName 新名称 - * @param oldName 原名称 - * @param updateMode 更新模式 - * @param tc tc - */ - public void updateNameOfSelectedNode(String newName, String oldName, int updateMode, DesignModelAdapter tc){ - - } - } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java index 364be2131a..7cc9d20ba4 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java @@ -6,7 +6,6 @@ import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.DesignModelAdapter; -import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.ResponseDataSourceChange; @@ -19,7 +18,6 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.fun.TableDataSourceManagerProcessor; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; @@ -29,7 +27,10 @@ import com.fr.design.icon.IconPathConstants; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DockingView; -import com.fr.design.menu.*; +import com.fr.design.menu.LineSeparator; +import com.fr.design.menu.MenuDef; +import com.fr.design.menu.SeparatorDef; +import com.fr.design.menu.ToolBarDef; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; @@ -51,9 +52,9 @@ import java.util.Map; public class TableDataTreePane extends DockingView implements ResponseDataSourceChange { - private static final int PROCEDURE_NAME_INDEX = 4; - private static final int TEMPLATE_TABLE_DATA = 0; - private static final int SERVER_TABLE_DATA = 1; + protected static final int PROCEDURE_NAME_INDEX = 4; + protected static final int TEMPLATE_TABLE_DATA = 0; + protected static final int SERVER_TABLE_DATA = 1; private static final long serialVersionUID = -12168467370000617L; private static TableDataTreePane singleton = new TableDataTreePane(); private String type = ""; @@ -76,8 +77,8 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource return singleton; } - private static TableDataTree dataTree; - private TableDataSourceOP op; + protected static TableDataTree dataTree; + protected TableDataSourceOP op; private MenuDef addMenuDef; private EditAction editAction; @@ -91,7 +92,7 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource private TableDataTreePane() { this.setLayout(new BorderLayout(4, 0)); this.setBorder(null); - initTableDataTree(); + dataTree = new TableDataTree(); ToolTipManager.sharedInstance().registerComponent(dataTree); ToolTipManager.sharedInstance().setDismissDelay(3000); ToolTipManager.sharedInstance().setInitialDelay(0); @@ -107,21 +108,13 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource createAddMenuDef(); } }); - ToolBarDef toolbarDef = new ToolBarDef(); + editAction = new EditAction(); removeAction = new RemoveAction(); previewTableDataAction = new PreviewTableDataAction(); connectionTableAction = new ConnectionTableAction(); - ShortCut[] shortCuts = null; - TableDataSourceManagerProcessor opProcessor = ExtraDesignClassManager.getInstance().getTableDataSourceManagerProcessor(); - if (opProcessor != null) { - shortCuts = opProcessor.getShortCuts(dataTree); - } else { - shortCuts = new ShortCut[]{addMenuDef, SeparatorDef.DEFAULT, editAction, removeAction, SeparatorDef.DEFAULT, previewTableDataAction, connectionTableAction}; - } - toolbarDef.addShortCut(shortCuts); + ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(addMenuDef, SeparatorDef.DEFAULT, editAction, removeAction, SeparatorDef.DEFAULT, previewTableDataAction, connectionTableAction); - UIToolbar toolBar = ToolBarDef.createJToolBar(); toolbarDef.updateToolBar(toolBar); @@ -154,12 +147,52 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource checkButtonEnabled(); } - private void initTableDataTree() { - TableDataSourceManagerProcessor opProcessor = ExtraDesignClassManager.getInstance().getTableDataSourceManagerProcessor(); - if (opProcessor != null) { - dataTree = opProcessor.createUserObjectJtree(); - } - dataTree = new TableDataTree(); + public MenuDef getAddMenuDef() { + return addMenuDef; + } + + public void setAddMenuDef(MenuDef addMenuDef) { + this.addMenuDef = addMenuDef; + } + + public EditAction getEditAction() { + return editAction; + } + + public void setEditAction(EditAction editAction) { + this.editAction = editAction; + } + + public RemoveAction getRemoveAction() { + return removeAction; + } + + public void setRemoveAction(RemoveAction removeAction) { + this.removeAction = removeAction; + } + + public DesignModelAdapter getTc() { + return tc; + } + + public void setTc(DesignModelAdapter tc) { + this.tc = tc; + } + + public PreviewTableDataAction getPreviewTableDataAction() { + return previewTableDataAction; + } + + public void setPreviewTableDataAction(PreviewTableDataAction previewTableDataAction) { + this.previewTableDataAction = previewTableDataAction; + } + + public ConnectionTableAction getConnectionTableAction() { + return connectionTableAction; + } + + public void setConnectionTableAction(ConnectionTableAction connectionTableAction) { + this.connectionTableAction = connectionTableAction; } private KeyAdapter getTableTreeNodeListener() { @@ -246,7 +279,7 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource dataTree.refresh(); } - private void checkButtonEnabled() { + protected void checkButtonEnabled() { // august:BUG 9344 addMenuDef.setEnabled(true); connectionTableAction.setEnabled(FRContext.getCurrentEnv() != null && FRContext.getCurrentEnv().isRoot()); @@ -293,12 +326,7 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource * 刷新 */ public void refreshDockingView() { - TableDataSourceOP tableDataSourceOP = null; - TableDataSourceManagerProcessor opProcessor = ExtraDesignClassManager.getInstance().getTableDataSourceManagerProcessor(); - if (opProcessor != null) { - tableDataSourceOP = opProcessor.createTableDataSourceOP(tc); - } - populate(tableDataSourceOP == null ? new TableDataSourceOP(tc) : tableDataSourceOP); + populate(new TableDataSourceOP(tc)); this.checkButtonEnabled(); } diff --git a/designer_base/src/com/fr/design/fun/TableDataSourceManagerProcessor.java b/designer_base/src/com/fr/design/fun/TableDataSourceManagerProcessor.java deleted file mode 100644 index fbb8095a9c..0000000000 --- a/designer_base/src/com/fr/design/fun/TableDataSourceManagerProcessor.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.fr.design.fun; - -import com.fr.design.DesignModelAdapter; -import com.fr.design.data.datapane.TableDataSourceOP; -import com.fr.design.data.datapane.TableDataTree; -import com.fr.design.menu.ShortCut; -import com.fr.stable.fun.Level; - -/** - * 自定义的模板(服务器)数据集的树样式接口 el:分组样式 - * Coder: zack - * Date: 2016/4/18 - * Time: 9:04 - */ -public interface TableDataSourceManagerProcessor extends Level { - String XML_TAG = "TableDataSourceManagerProcessor"; - - int CURRENT_LEVEL = 1; - /** - * 创建数据集的树操作 - * @param tc 设计模式 - * @return 数据集树操作 - */ - TableDataSourceOP createTableDataSourceOP(DesignModelAdapter tc); - - /** - * 创建相应的tabledatatree - * @return tabledatatree - */ - TableDataTree createUserObjectJtree(); - - /** - * 返回面板新增的action(el:GroupAction) - * @return (shortcut)action数组 - */ - ShortCut[] getShortCuts(TableDataTree dataTree); - -} diff --git a/designer_base/src/com/fr/design/fun/TableDataTreePaneProcessor.java b/designer_base/src/com/fr/design/fun/TableDataTreePaneProcessor.java new file mode 100644 index 0000000000..066038568f --- /dev/null +++ b/designer_base/src/com/fr/design/fun/TableDataTreePaneProcessor.java @@ -0,0 +1,22 @@ +package com.fr.design.fun; + +import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.stable.fun.Level; + +/** + * 自定义的模板(服务器)数据集的树样式接口 el:分组样式 + * Coder: zack + * Date: 2016/4/18 + * Time: 9:04 + */ +public interface TableDataTreePaneProcessor extends Level { + String XML_TAG = "TableDataTreePaneProcessor"; + + int CURRENT_LEVEL = 1; + /** + * 创建数据集面板 + * @return 数据集面板 + */ + TableDataTreePane createTableDataTreePane(); + +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractTDSourceManagerProcessor.java b/designer_base/src/com/fr/design/fun/impl/AbstractTDTreePaneProcessor.java similarity index 52% rename from designer_base/src/com/fr/design/fun/impl/AbstractTDSourceManagerProcessor.java rename to designer_base/src/com/fr/design/fun/impl/AbstractTDTreePaneProcessor.java index 4550023ea2..635739a07b 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractTDSourceManagerProcessor.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractTDTreePaneProcessor.java @@ -1,13 +1,13 @@ package com.fr.design.fun.impl; -import com.fr.design.fun.TableDataSourceManagerProcessor; +import com.fr.design.fun.TableDataTreePaneProcessor; /** * Coder: zack * Date: 2016/4/18 * Time: 10:30 */ -public abstract class AbstractTDSourceManagerProcessor implements TableDataSourceManagerProcessor { +public abstract class AbstractTDTreePaneProcessor implements TableDataTreePaneProcessor { @Override public int currentAPILevel() { return CURRENT_LEVEL; diff --git a/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java index 36c2584d03..0ed5556c23 100644 --- a/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/WestRegionContainerPane.java @@ -1,11 +1,15 @@ package com.fr.design.mainframe; -import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.design.fun.TableDataTreePaneProcessor; import com.fr.design.gui.icontainer.UIResizableContainer; import com.fr.stable.Constants; +import javax.swing.*; + public class WestRegionContainerPane extends UIResizableContainer { private static WestRegionContainerPane THIS; @@ -16,15 +20,23 @@ public class WestRegionContainerPane extends UIResizableContainer { */ public static final WestRegionContainerPane getInstance() { if (THIS == null) { - THIS = new WestRegionContainerPane(); + TableDataTreePane tableDataTreePane = null; + TableDataTreePaneProcessor treePaneProcessor = ExtraDesignClassManager.getInstance().getTableDataTreePaneProcessor(); + if (treePaneProcessor != null) { + tableDataTreePane = treePaneProcessor.createTableDataTreePane(); + } else { + tableDataTreePane = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); + } + THIS = new WestRegionContainerPane(tableDataTreePane); THIS.setLastToolPaneY(DesignerEnvManager.getEnvManager().getLastWestRegionToolPaneY()); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth()); } return THIS; } - public WestRegionContainerPane() { - super(DesignerFrameFileDealerPane.getInstance(), TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()), Constants.RIGHT); + public WestRegionContainerPane(JComponent pane) { + super(DesignerFrameFileDealerPane.getInstance(), pane, Constants.RIGHT); setContainerWidth(165); } + } \ No newline at end of file From 222efe686bd83b79177afdca5ef3d90a88e94e65 Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 19 Apr 2016 18:32:54 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E5=B1=9E=E6=80=A7=E4=BF=9D=E6=8C=81priva?= =?UTF-8?q?te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/TableDataSourceOP.java | 10 ++++++- .../design/data/datapane/TableDataTree.java | 9 ++++++- .../data/datapane/TableDataTreePane.java | 26 ++++++++++++++++--- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java b/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java index fdb5695baa..10e46edd30 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java @@ -30,13 +30,21 @@ public class TableDataSourceOP implements UserObjectOP { public static final int STORE_PRECEDURE_DATA = 2; public static int dataMode = -1; - protected DesignModelAdapter tc; + private DesignModelAdapter tc; public TableDataSourceOP(DesignModelAdapter tc) { this.tc = tc; } + public DesignModelAdapter getTc() { + return tc; + } + + public void setTc(DesignModelAdapter tc) { + this.tc = tc; + } + /** * 初始化数据集的list * diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTree.java b/designer_base/src/com/fr/design/data/datapane/TableDataTree.java index 82663e4999..bb8553d308 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTree.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTree.java @@ -32,7 +32,7 @@ public class TableDataTree extends UserObjectRefreshJTree { this.setEditable(false); } // CellRenderer - protected DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() { + private DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() { private static final long serialVersionUID = 1L; @Override @@ -81,6 +81,13 @@ public class TableDataTree extends UserObjectRefreshJTree { } }; + public DefaultTreeCellRenderer getTableDataTreeCellRenderer() { + return tableDataTreeCellRenderer; + } + + public void setTableDataTreeCellRenderer(DefaultTreeCellRenderer tableDataTreeCellRenderer) { + this.tableDataTreeCellRenderer = tableDataTreeCellRenderer; + } protected void refreshTreeNode(ExpandMutableTreeNode eTreeNode, String childName) { if (interceptRefresh(eTreeNode)) { diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java index 7cc9d20ba4..84c56e7942 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java @@ -77,8 +77,8 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource return singleton; } - protected static TableDataTree dataTree; - protected TableDataSourceOP op; + private TableDataTree dataTree; + private TableDataSourceOP op; private MenuDef addMenuDef; private EditAction editAction; @@ -147,6 +147,26 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource checkButtonEnabled(); } + public void setDataTree(TableDataTree dataTree) { + this.dataTree = dataTree; + } + + public TableDataSourceOP getOp() { + return op; + } + + public void setOp(TableDataSourceOP op) { + this.op = op; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + public MenuDef getAddMenuDef() { return addMenuDef; } @@ -275,7 +295,7 @@ public class TableDataTreePane extends DockingView implements ResponseDataSource /** * 刷新 */ - public static void refresh() { + public void refresh() { dataTree.refresh(); } From b79066246268df749f89fc2f2d255c671be165f7 Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 19 Apr 2016 20:01:51 +0800 Subject: [PATCH 16/19] =?UTF-8?q?1=E3=80=81=E6=8F=92=E4=BB=B6=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=9B=B4=E6=96=B0=202=E3=80=81=E6=96=B0=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=89=93=E5=BC=80=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginWebBridge.java | 12 +++++ .../extra/exe/InstallOnlineExecutor.java | 16 +++++- .../extra/exe/ReadUpdateOnlineExecutor.java | 50 +++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 65ef0c56d7..90fcd2af07 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -127,6 +127,14 @@ public class PluginWebBridge { new Thread(task).start(); } + /** + * 已安装插件检查更新 + */ + public void readUpdateOnline(final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new ReadUpdateOnlineExecutor()); + new Thread(task).start(); + } + /** * 选择文件对话框 * @@ -281,6 +289,10 @@ public class PluginWebBridge { } } + public void openUrlAtLocalWebBrowser(String url) { + openUrlAtLocalWebBrowser(webEngine, url); + } + /** * 从硬盘升级 * diff --git a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java index bd3711bd6a..d343ec590c 100644 --- a/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/InstallOnlineExecutor.java @@ -2,9 +2,9 @@ package com.fr.design.extra.exe; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; import com.fr.design.extra.After; import com.fr.design.extra.PluginHelper; -import com.fr.design.extra.PluginWebBridge; import com.fr.design.extra.Process; import com.fr.general.Inter; import com.fr.plugin.PluginVerifyException; @@ -64,7 +64,19 @@ public class InstallOnlineExecutor implements Executor { PluginHelper.installPluginFromDisk(PluginHelper.getDownloadTempFile(), new After() { @Override public void done() { - PluginWebBridge.getHelper().showRestartMessage(Inter.getLocText("FR-Designer-Plugin_Update_Successful")); + int rv = JOptionPane.showOptionDialog( + null, + Inter.getLocText("FR-Designer-Plugin_Install_Successful"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")}, + null + ); + if (rv == JOptionPane.OK_OPTION) { + RestartHelper.restart(); + } } }); } catch (PluginVerifyException e) { diff --git a/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java new file mode 100644 index 0000000000..8120049e18 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java @@ -0,0 +1,50 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.PluginsReaderFromStore; +import com.fr.design.extra.Process; +import com.fr.general.FRLogger; +import com.fr.plugin.Plugin; +import com.fr.stable.StringUtils; + +/** + * Created by vito on 16/4/19. + */ +public class ReadUpdateOnlineExecutor implements Executor { + private Plugin[] plugins; + private String result; + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return StringUtils.EMPTY; + } + + @Override + public void run(Process process) { + try { + plugins = PluginsReaderFromStore.readPluginsForUpdate(); + StringBuilder sb = new StringBuilder(); + if (plugins != null) { + sb.append("["); + for (Plugin plugin : plugins) { + sb.append("{pluginid:'").append(plugin.getId()).append("'}"); + } + sb.append("]"); + } + result = sb.toString(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + } + }; + } +} From fcbb71a23eaae1f1fcf1f9bac06ba5c03781a410 Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 20 Apr 2016 09:06:26 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E5=91=BD=E5=90=8D=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/data/datapane/TableDataSourceOP.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java b/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java index 10e46edd30..da85a4241e 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataSourceOP.java @@ -37,11 +37,11 @@ public class TableDataSourceOP implements UserObjectOP { this.tc = tc; } - public DesignModelAdapter getTc() { + public DesignModelAdapter getDesignModelAdapter() { return tc; } - public void setTc(DesignModelAdapter tc) { + public void setDesignModelAdapter(DesignModelAdapter tc) { this.tc = tc; } From e26a87abf7248b905de0ca1570cff04582c5667f Mon Sep 17 00:00:00 2001 From: xiaxiang <1438003374@qq.com> Date: Wed, 20 Apr 2016 23:38:02 +0800 Subject: [PATCH 18/19] rt --- .../com/fr/design/mainframe/AuthorityEditToolBarPane.java | 2 +- .../src/com/fr/design/mainframe/AuthorityToolBarPane.java | 2 +- .../design/mainframe/ElementCasePaneAuthorityEditPane.java | 2 +- .../design/gui/itree/refreshabletree/RefreshableJTree.java | 7 +++++-- .../gui/itree/refreshabletree/UserObjectRefreshJTree.java | 2 +- .../src/com/fr/design/roleAuthority/RoleTree.java | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java index d0534f9f23..018ac9bc8f 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java @@ -1 +1 @@ -package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.webattr.ToolBarButton; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import javax.swing.*; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; /** * 用于在权限编辑状态对工具栏的元素进行权限编辑的面板 * Author : daisy * Date: 13-9-18 * Time: 下午2:15 */ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { private static final int TITLE_HEIGHT = 19; private AuthorityEditPane authorityEditPane = null; private AuthorityToolBarPane authorityToolBarPane; public AuthorityEditToolBarPane(List buttonlists) { super(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); this.setLayout(new BorderLayout()); this.setBorder(null); UILabel authorityTitle = new UILabel(Inter.getLocText(new String[]{"DashBoard-Potence", "Edit"})) { @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, TITLE_HEIGHT); } }; authorityTitle.setHorizontalAlignment(SwingConstants.CENTER); authorityTitle.setVerticalAlignment(SwingConstants.CENTER); JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); northPane.add(authorityTitle, BorderLayout.CENTER); northPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); this.add(northPane, BorderLayout.NORTH); authorityEditPane = new AuthorityEditPane(buttonlists); this.add(authorityEditPane, BorderLayout.CENTER); } public void setAuthorityToolBarPane(AuthorityToolBarPane authorityToolBarPane) { this.authorityToolBarPane = authorityToolBarPane; } public void populate() { authorityToolBarPane.populateAuthority(); signelSelection(); authorityEditPane.populateDetials(); } private void signelSelection() { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate.isJWorkBook()) { //清参数面板 jTemplate.removeParameterPaneSelection(); //清报表主体 jTemplate.removeTemplateSelection(); } } private class AuthorityEditPane extends JPanel { private static final int TOP_GAP = 11; private static final int LEFT_GAP = 8; private static final int ALIGNMENT_GAP = -3; private UILabel type = null; private UILabel name = null; private JPanel checkPane = null; private List buttonlists; private UICheckBox buttonVisible = new UICheckBox(Inter.getLocText("Widget-Visible")); private ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { String selectedRole = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRole, Inter.getLocText("Role"))) { return; } if (selectedRole == null) { return; } for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { buttonlists.get(i).changeAuthorityState(selectedRole, buttonVisible.isSelected()); authorityToolBarPane.repaint(); } } HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); UICheckBox checkbox = (UICheckBox) e.getSource(); List _buttonlists = AuthorityEditPane.this.buttonlists; for (int j = 0; j < _buttonlists.size(); j++) { if (_buttonlists.get(j).isSelected()) { //由引擎实现保存进模板报表 authorityToolBarPane.setAuthorityWebAttr(_buttonlists.get(j).getWidget(), checkbox.isSelected(), selectedRole); } } } }; public AuthorityEditPane(List buttonlists) { setLayout(new BorderLayout()); type = new UILabel(); name = new UILabel(); checkPane = new JPanel(); checkPane.setLayout(new BorderLayout()); this.add(layoutText(), BorderLayout.WEST); this.add(layoutPane(), BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder(TOP_GAP, LEFT_GAP, 0, 0)); this.buttonlists = buttonlists; buttonVisible.addItemListener(itemListener); } private JPanel layoutText() { double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("Type") + ":", SwingConstants.RIGHT)}, new Component[]{new UILabel(Inter.getLocText("WF-Name") + ":", SwingConstants.RIGHT)}, new Component[]{new UILabel(Inter.getLocText("DashBoard-Potence") + ":", SwingConstants.RIGHT)}, }; double[] rowSize = {p, p, p}; double[] columnSize = {p}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel layoutPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{type}, new Component[]{name}, new Component[]{checkPane}, }; double[] rowSize = {p, p, p}; double[] columnSize = {f}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } /** * 更新权限编辑面板的具体内容:类型、名称、权限面板 */ public void populateDetials() { populateName(); populateType(); populateCheckPane(); checkVisibleCheckBoxes(); } private void checkVisibleCheckBoxes() { buttonVisible.removeItemListener(itemListener); String selected = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (selected == null) { buttonVisible.setSelected(true); } for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { buttonVisible.setSelected(!buttonlists.get(i).isDoneAuthorityEdited(selected)); break; } } buttonVisible.addItemListener(itemListener); } public void populateType() { if (name.getText() == "") { type.setText(""); } else { type.setText(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "Form-Button"})); } } public void populateName() { String names = ""; for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { names += "," + buttonlists.get(i).getNameOption().optionName(); } } if (names != "") { names = names.substring(1); } name.setText(names); } public void populateCheckPane() { checkPane.removeAll(); if (name.getText() == "") { return; } double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("Form-Button"), SwingConstants.LEFT), buttonVisible}, }; double[] rowSize = {p, p}; double[] columnSize = {p, p, f}; int[][] rowCount = {{1, 1, 1}, {1, 1, 1}}; JPanel check = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); checkPane.add(check, BorderLayout.CENTER); checkPane.setBorder(BorderFactory.createEmptyBorder(ALIGNMENT_GAP, 0, 0, 0)); } } } \ No newline at end of file +package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.webattr.ToolBarButton; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; /** * 用于在权限编辑状态对工具栏的元素进行权限编辑的面板 * Author : daisy * Date: 13-9-18 * Time: 下午2:15 */ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { private static final int TITLE_HEIGHT = 19; private AuthorityEditPane authorityEditPane = null; private AuthorityToolBarPane authorityToolBarPane; private String[] selectedPathArray; public AuthorityEditToolBarPane(List buttonlists) { super(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); this.setLayout(new BorderLayout()); this.setBorder(null); UILabel authorityTitle = new UILabel(Inter.getLocText(new String[]{"DashBoard-Potence", "Edit"})) { @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, TITLE_HEIGHT); } }; authorityTitle.setHorizontalAlignment(SwingConstants.CENTER); authorityTitle.setVerticalAlignment(SwingConstants.CENTER); JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); northPane.add(authorityTitle, BorderLayout.CENTER); northPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); this.add(northPane, BorderLayout.NORTH); authorityEditPane = new AuthorityEditPane(buttonlists); this.add(authorityEditPane, BorderLayout.CENTER); } public void setAuthorityToolBarPane(AuthorityToolBarPane authorityToolBarPane) { this.authorityToolBarPane = authorityToolBarPane; } public void populate() { authorityToolBarPane.populateAuthority(); signelSelection(); authorityEditPane.populateDetials(); } private void signelSelection() { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate.isJWorkBook()) { //清参数面板 jTemplate.removeParameterPaneSelection(); //清报表主体 jTemplate.removeTemplateSelection(); } } private class AuthorityEditPane extends JPanel { private static final int TOP_GAP = 11; private static final int LEFT_GAP = 8; private static final int ALIGNMENT_GAP = -3; private UILabel type = null; private UILabel name = null; private JPanel checkPane = null; private List buttonlists; private UICheckBox buttonVisible = new UICheckBox(Inter.getLocText("Widget-Visible")); private ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { String selectedRole = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); initSelectedselectedPathArray(); if (ComparatorUtils.equals(selectedRole, Inter.getLocText("Role"))) { return; } if (selectedRole == null) { return; } if (selectedPathArray == null) { return; } for (int t = 0; t _buttonlists = AuthorityEditPane.this.buttonlists; for (int j = 0; j < _buttonlists.size(); j++) { if (_buttonlists.get(j).isSelected()) { //由引擎实现保存进模板报表 authorityToolBarPane.setAuthorityWebAttr(_buttonlists.get(j).getWidget(), checkbox.isSelected(), selectedPathArray[t]); } } } } }; private void initSelectedselectedPathArray () { TreePath[] selectionPaths = ReportAndFSManagePane.getInstance().getRoleTree().getCheckBoxTreeSelectionModel().getSelectionPaths(); if (selectionPaths.length == 1){ if(((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getChildCount() > 0){ ExpandMutableTreeNode node = (ExpandMutableTreeNode) ((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getLastChild(); selectedPathArray = new String[node.getChildCount()]; for (int y =0 ; y 0 && temp.charAt(0) == '[' && temp.endsWith("]"); if (isTrue) { temp = temp.substring(1, temp.length() - 1); String[] selectedRoles = temp.split(","); String role = selectedRoles[2].trim(); if(roles.isEmpty()){ roles = role; }else{ roles = roles + "," + role; } } } String[] selectedRole = roles.split(","); return selectedRole; } public AuthorityEditPane(List buttonlists) { setLayout(new BorderLayout()); type = new UILabel(); name = new UILabel(); checkPane = new JPanel(); checkPane.setLayout(new BorderLayout()); this.add(layoutText(), BorderLayout.WEST); this.add(layoutPane(), BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder(TOP_GAP, LEFT_GAP, 0, 0)); this.buttonlists = buttonlists; buttonVisible.addItemListener(itemListener); } private JPanel layoutText() { double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("Type") + ":", SwingConstants.RIGHT)}, new Component[]{new UILabel(Inter.getLocText("WF-Name") + ":", SwingConstants.RIGHT)}, new Component[]{new UILabel(Inter.getLocText("DashBoard-Potence") + ":", SwingConstants.RIGHT)}, }; double[] rowSize = {p, p, p}; double[] columnSize = {p}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel layoutPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{type}, new Component[]{name}, new Component[]{checkPane}, }; double[] rowSize = {p, p, p}; double[] columnSize = {f}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } /** * 更新权限编辑面板的具体内容:类型、名称、权限面板 */ public void populateDetials() { populateName(); populateType(); populateCheckPane(); checkVisibleCheckBoxes(); } private void checkVisibleCheckBoxes() { buttonVisible.removeItemListener(itemListener); String selected = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (selected == null) { buttonVisible.setSelected(true); } for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { buttonVisible.setSelected(!buttonlists.get(i).isDoneAuthorityEdited(selected)); break; } } buttonVisible.addItemListener(itemListener); } public void populateType() { if (name.getText() == "") { type.setText(""); } else { type.setText(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "Form-Button"})); } } public void populateName() { String names = ""; for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { names += "," + buttonlists.get(i).getNameOption().optionName(); } } if (names != "") { names = names.substring(1); } name.setText(names); } public void populateCheckPane() { checkPane.removeAll(); if (name.getText() == "") { return; } double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("Form-Button"), SwingConstants.LEFT), buttonVisible}, }; double[] rowSize = {p, p}; double[] columnSize = {p, p, f}; int[][] rowCount = {{1, 1, 1}, {1, 1, 1}}; JPanel check = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); checkPane.add(check, BorderLayout.CENTER); checkPane.setBorder(BorderFactory.createEmptyBorder(ALIGNMENT_GAP, 0, 0, 0)); } } } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java index 0cc1bfc6b4..27c2c1ec0c 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -1 +1 @@ -package com.fr.design.mainframe; import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.beans.BasicBeanPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.webattr.ReportWebWidgetConstants; import com.fr.design.webattr.ToolBarButton; import com.fr.design.webattr.ToolBarPane; import com.fr.form.ui.Button; import com.fr.form.ui.ToolBar; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.main.TemplateWorkBook; import com.fr.report.web.Location; import com.fr.report.web.ToolBarManager; import com.fr.report.web.WebContent; import com.fr.base.ConfigManagerProvider; import com.fr.stable.ArrayUtils; import com.fr.web.attr.ReportWebAttr; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.List; /** * Author : daisy * Date: 13-9-9 * Time: 下午4:58 */ public class AuthorityToolBarPane extends BasicBeanPane implements AuthorityEditToolBarComponent { private static final int SMALL_GAP = 13; private static final int GAP = 25; private static final int PRE_GAP = 9; private static final int COMBOX_WIDTH = 144; private static final String[] CHOOSEITEM = new String[]{Inter.getLocText("M-Page_Preview"), Inter.getLocText(new String[]{"Face_Write", "PageSetup-Page"}), Inter.getLocText("M-Data_Analysis")}; private UIComboBox choseComboBox; private ToolBarPane toolBarPane; private UICheckBox allSelectedCheckBox; private AuthorityEditToolBarPane authorityEditToolBarPane = null; private int selectedIndex = -1; private UILabel title = null; private MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (!toolBarPane.isEnabled()) { return; } java.util.List buttonlists = toolBarPane.getToolBarButtons(); int oldIndex = selectedIndex; selectedIndex = pressButtonIndex(e, buttonlists); //实现shift多选 if (e.isShiftDown()) { if (oldIndex == -1) { removeSelection(); ((ToolBarButton) e.getSource()).setSelected(true); } else { int max = oldIndex >= selectedIndex ? oldIndex : selectedIndex; int min = oldIndex <= selectedIndex ? oldIndex : selectedIndex; for (int i = min; i <= max; i++) { buttonlists.get(i).setSelected(true); } } } else if (!e.isControlDown()) { //实现单选 removeSelection(); if (selectedIndex != -1) { ((ToolBarButton) e.getSource()).setSelected(true); } } authorityEditToolBarPane.populate(); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); } }; private int pressButtonIndex(MouseEvent e, java.util.List buttonlists) { if (!(e.getSource() instanceof ToolBarButton)) { return -1; } ToolBarButton button = (ToolBarButton) e.getSource(); for (int i = 0; i < buttonlists.size(); i++) { if (ComparatorUtils.equals(button, buttonlists.get(i))) { return i; } } return -1; } /** * 去掉选择 */ public void removeSelection() { for (ToolBarButton button : toolBarPane.getToolBarButtons()) { button.setSelected(false); } } private ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.DESELECTED) { selectedIndex = -1; populateToolBarPane(); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); authorityEditToolBarPane.setAuthorityToolBarPane(AuthorityToolBarPane.this); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); } } }; public AuthorityToolBarPane() { this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 3)); this.setBorder(BorderFactory.createEmptyBorder(0, PRE_GAP, 0, 0)); title = new UILabel(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "Choose_Role"})); title.setHorizontalAlignment(SwingConstants.CENTER); this.add(title, 0); choseComboBox = new UIComboBox(CHOOSEITEM) { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.width = COMBOX_WIDTH; return dim; } }; choseComboBox.addItemListener(itemListener); //默认选择第一个 choseComboBox.setSelectedIndex(0); this.add(createGapPanel(SMALL_GAP)); this.add(choseComboBox); toolBarPane = new ToolBarPane(); toolBarPane.setBorder(null); toolBarPane.removeDefaultMouseListener(); this.add(createGapPanel(GAP)); this.add(toolBarPane); allSelectedCheckBox = new UICheckBox(Inter.getLocText("FR-Engine_Choose_All")); allSelectedCheckBox.setHorizontalAlignment(SwingConstants.CENTER); this.add(allSelectedCheckBox); allSelectedCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeSelection(); List toolBarButtons = toolBarPane.getToolBarButtons(); for (ToolBarButton button : toolBarButtons) { button.setSelected(allSelectedCheckBox.isSelected()); } authorityEditToolBarPane.populate(); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); } }); populateDefaultToolBarWidgets(); populateBean(getReportWebAttr()); toolBarPane.addAuthorityListener(mouseListener); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); authorityEditToolBarPane.setAuthorityToolBarPane(this); checkToolBarPaneEnable(); } private JPanel createGapPanel(final int gap) { return new JPanel() { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.width = gap; return dim; } }; } private void populateToolBarPane() { toolBarPane.removeAll(); populateDefaultToolBarWidgets(); populateBean(getReportWebAttr()); toolBarPane.addAuthorityListener(mouseListener); toolBarPane.repaint(); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); checkToolBarPaneEnable(); } /** * 使用普通用户远程设计时,如果工具栏使用的是“采用服务器设置”,则工具栏按钮为灰不可用 */ private void checkToolBarPaneEnable() { List toolBarButtons = toolBarPane.getToolBarButtons(); boolean isnotEnable = ComparatorUtils.equals(title.getText(), Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})) && !FRContext.getCurrentEnv().isRoot(); for (ToolBarButton button : toolBarButtons) { button.setEnabled(!isnotEnable); } toolBarPane.setEnabled(!isnotEnable); allSelectedCheckBox.setEnabled(!isnotEnable); } /** * 更新权限工具栏面板 */ public void populateAuthority() { toolBarPane.repaint(); } private ReportWebAttr getReportWebAttr() { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!editingTemplate.isJWorkBook()) { return null; } JWorkBook editingWorkBook = (JWorkBook) editingTemplate; TemplateWorkBook wbTpl = editingWorkBook.getTarget(); return wbTpl.getReportWebAttr(); } //将该报表的设置过权限的属性记录一下 public void setAuthorityWebAttr(Widget widget, boolean isSelected, String selectedRole) { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!editingTemplate.isJWorkBook()) { return; } JWorkBook editingWorkBook = (JWorkBook) editingTemplate; TemplateWorkBook wbTpl = editingWorkBook.getTarget(); ReportWebAttr rw = wbTpl.getReportWebAttr(); ConfigManagerProvider cm = ConfigManager.getProviderInstance(); ReportWebAttr webAttr = ((ReportWebAttr) cm.getGlobalAttribute(ReportWebAttr.class)); //wbTpl.clear先清空 //再将所有的保存进去 //看是存在服务器还存在模板里面 if (choseComboBox.getSelectedIndex() == 0) { //分页 if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebPage(), widget, isSelected, selectedRole); } } else if (choseComboBox.getSelectedIndex() == 1) { //填报 if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebWrite(), widget, isSelected, selectedRole); } } else { //view if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebView(), widget, isSelected, selectedRole); } } try { FRContext.getCurrentEnv().writeResource(cm); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } } private void dealWithWebContent(WebContent wc, Widget widget, boolean isSelected, String selectedRole) { ToolBarManager[] managers = wc.getToolBarManagers(); if (managers == null) { return; } for (int i = 0; i < managers.length; i++) { ToolBar tb = managers[i].getToolBar(); for (int j = 0; j < tb.getWidgetSize(); j++) { if (widget instanceof Button && tb.getWidget(j) instanceof Button) { if (ComparatorUtils.equals(((Button) widget).getIconName(), ((Button) tb.getWidget(j)).getIconName())) { if (!isSelected) { tb.getWidget(j).getWidgetPrivilegeControl().addInvisibleRole(selectedRole); } else { tb.getWidget(j).getWidgetPrivilegeControl().removeInvisibleRole(selectedRole); } } } } } wc.setToolBarManagers(managers); } public void populateBean(ReportWebAttr reportWebAttr) { this.remove(title); // 如果是空值就说明采用服务器配置了 if (reportWebAttr == null || this.getWebContent(reportWebAttr) == null) { title = new UILabel(Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})); populateServerSettings(); this.add(title, 0); return; } // 模板设置 T webContent = this.getWebContent(reportWebAttr); title = new UILabel(Inter.getLocText(new String[]{"the_template", "ReportServerP-Toolbar", "Choose_Role"})); this.add(title, 0); populate(webContent.getToolBarManagers()); } public ReportWebAttr updateBean() { return null; } public void populate(ToolBarManager[] toolBarManager) { if (ArrayUtils.isEmpty(toolBarManager)) { return; } if (toolBarManager.length == 0) { return; } for (int i = 0; i < toolBarManager.length; i++) { toolBarPane.populateBean(toolBarManager[i].getToolBar()); } } public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.height = ToolBarMenuDock.PANLE_HEIGNT; return dim; } public void populateBean(ToolBarManager[] toolBarManager) { if (ArrayUtils.isEmpty(toolBarManager)) { return; } for (int i = 0; i < toolBarManager.length; i++) { Location location = toolBarManager[i].getToolBarLocation(); if (location instanceof Location.Embed) { toolBarPane.populateBean(toolBarManager[i].getToolBar()); } } } private void populateServerSettings() { ConfigManagerProvider cm = ConfigManager.getProviderInstance(); ReportWebAttr webAttr = ((ReportWebAttr) cm.getGlobalAttribute(ReportWebAttr.class)); if (this.getWebContent(webAttr) != null) { populate(this.getWebContent(webAttr).getToolBarManagers()); } } protected String title4PopupWindow() { return null; } private T getWebContent(ReportWebAttr reportWebAttr) { if (choseComboBox.getSelectedIndex() == 0) { return reportWebAttr == null ? null : (T) reportWebAttr.getWebPage(); } else if (choseComboBox.getSelectedIndex() == 1) { return reportWebAttr == null ? null : (T) reportWebAttr.getWebWrite(); } else { return reportWebAttr == null ? null : (T) reportWebAttr.getWebView(); } } private void populateDefaultToolBarWidgets() { if (choseComboBox.getSelectedIndex() == 0) { ReportWebWidgetConstants.getPageToolBarInstance(); } else if (choseComboBox.getSelectedIndex() == 1) { ReportWebWidgetConstants.getWriteToolBarInstance(); } else { ReportWebWidgetConstants.getViewToolBarInstance(); } } private ToolBarManager getDefaultToolBarManager() { if (choseComboBox.getSelectedIndex() == 0) { return ToolBarManager.createDefaultToolBar(); } else if (choseComboBox.getSelectedIndex() == 1) { return ToolBarManager.createDefaultWriteToolBar(); } else { return ToolBarManager.createDefaultViewToolBar(); } } } \ No newline at end of file +package com.fr.design.mainframe; import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.beans.BasicBeanPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.webattr.ReportWebWidgetConstants; import com.fr.design.webattr.ToolBarButton; import com.fr.design.webattr.ToolBarPane; import com.fr.form.ui.Button; import com.fr.form.ui.ToolBar; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.main.TemplateWorkBook; import com.fr.report.web.Location; import com.fr.report.web.ToolBarManager; import com.fr.report.web.WebContent; import com.fr.base.ConfigManagerProvider; import com.fr.stable.ArrayUtils; import com.fr.web.attr.ReportWebAttr; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.List; /** * Author : daisy * Date: 13-9-9 * Time: 下午4:58 */ public class AuthorityToolBarPane extends BasicBeanPane implements AuthorityEditToolBarComponent { private static final int SMALL_GAP = 13; private static final int GAP = 25; private static final int PRE_GAP = 9; private static final int COMBOX_WIDTH = 144; private static final String[] CHOOSEITEM = new String[]{Inter.getLocText("M-Page_Preview"), Inter.getLocText(new String[]{"Face_Write", "PageSetup-Page"}), Inter.getLocText("M-Data_Analysis")}; private UIComboBox choseComboBox; private ToolBarPane toolBarPane; private AuthorityEditToolBarPane authorityEditToolBarPane = null; private int selectedIndex = -1; private UILabel title = null; private MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (!toolBarPane.isEnabled()) { return; } java.util.List buttonlists = toolBarPane.getToolBarButtons(); int oldIndex = selectedIndex; selectedIndex = pressButtonIndex(e, buttonlists); //实现shift多选 if (e.isShiftDown()) { if (oldIndex == -1) { removeSelection(); ((ToolBarButton) e.getSource()).setSelected(true); } else { int max = oldIndex >= selectedIndex ? oldIndex : selectedIndex; int min = oldIndex <= selectedIndex ? oldIndex : selectedIndex; for (int i = min; i <= max; i++) { buttonlists.get(i).setSelected(true); } } } else if (!e.isControlDown()) { //实现单选 removeSelection(); if (selectedIndex != -1) { ((ToolBarButton) e.getSource()).setSelected(true); } } authorityEditToolBarPane.populate(); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); } }; private int pressButtonIndex(MouseEvent e, java.util.List buttonlists) { if (!(e.getSource() instanceof ToolBarButton)) { return -1; } ToolBarButton button = (ToolBarButton) e.getSource(); for (int i = 0; i < buttonlists.size(); i++) { if (ComparatorUtils.equals(button, buttonlists.get(i))) { return i; } } return -1; } /** * 去掉选择 */ public void removeSelection() { for (ToolBarButton button : toolBarPane.getToolBarButtons()) { button.setSelected(false); } } private ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.DESELECTED) { selectedIndex = -1; populateToolBarPane(); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); authorityEditToolBarPane.setAuthorityToolBarPane(AuthorityToolBarPane.this); EastRegionContainerPane.getInstance().replaceUpPane(authorityEditToolBarPane); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); } } }; public AuthorityToolBarPane() { this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 3)); this.setBorder(BorderFactory.createEmptyBorder(0, PRE_GAP, 0, 0)); title = new UILabel(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "Choose_Role"})); title.setHorizontalAlignment(SwingConstants.CENTER); this.add(title, 0); choseComboBox = new UIComboBox(CHOOSEITEM) { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.width = COMBOX_WIDTH; return dim; } }; choseComboBox.addItemListener(itemListener); //默认选择第一个 choseComboBox.setSelectedIndex(0); this.add(createGapPanel(SMALL_GAP)); this.add(choseComboBox); toolBarPane = new ToolBarPane(); toolBarPane.setBorder(null); toolBarPane.removeDefaultMouseListener(); this.add(createGapPanel(GAP)); this.add(toolBarPane); populateDefaultToolBarWidgets(); populateBean(getReportWebAttr()); toolBarPane.addAuthorityListener(mouseListener); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); authorityEditToolBarPane.setAuthorityToolBarPane(this); checkToolBarPaneEnable(); } private JPanel createGapPanel(final int gap) { return new JPanel() { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.width = gap; return dim; } }; } private void populateToolBarPane() { toolBarPane.removeAll(); populateDefaultToolBarWidgets(); populateBean(getReportWebAttr()); toolBarPane.addAuthorityListener(mouseListener); toolBarPane.repaint(); authorityEditToolBarPane = new AuthorityEditToolBarPane(toolBarPane.getToolBarButtons()); checkToolBarPaneEnable(); } /** * 使用普通用户远程设计时,如果工具栏使用的是“采用服务器设置”,则工具栏按钮为灰不可用 */ private void checkToolBarPaneEnable() { List toolBarButtons = toolBarPane.getToolBarButtons(); boolean isnotEnable = ComparatorUtils.equals(title.getText(), Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})) && !FRContext.getCurrentEnv().isRoot(); for (ToolBarButton button : toolBarButtons) { button.setEnabled(!isnotEnable); } toolBarPane.setEnabled(!isnotEnable); } /** * 更新权限工具栏面板 */ public void populateAuthority() { toolBarPane.repaint(); } private ReportWebAttr getReportWebAttr() { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!editingTemplate.isJWorkBook()) { return null; } JWorkBook editingWorkBook = (JWorkBook) editingTemplate; TemplateWorkBook wbTpl = editingWorkBook.getTarget(); return wbTpl.getReportWebAttr(); } //将该报表的设置过权限的属性记录一下 public void setAuthorityWebAttr(Widget widget, boolean isSelected, String selectedRole) { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!editingTemplate.isJWorkBook()) { return; } JWorkBook editingWorkBook = (JWorkBook) editingTemplate; TemplateWorkBook wbTpl = editingWorkBook.getTarget(); ReportWebAttr rw = wbTpl.getReportWebAttr(); ConfigManagerProvider cm = ConfigManager.getProviderInstance(); ReportWebAttr webAttr = ((ReportWebAttr) cm.getGlobalAttribute(ReportWebAttr.class)); //wbTpl.clear先清空 //再将所有的保存进去 //看是存在服务器还存在模板里面 if (choseComboBox.getSelectedIndex() == 0) { //分页 if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebPage(), widget, isSelected, selectedRole); } } else if (choseComboBox.getSelectedIndex() == 1) { //填报 if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebWrite(), widget, isSelected, selectedRole); } } else { //view if (rw == null || rw.getWebPage() == null) { dealWithWebContent(webAttr.getWebView(), widget, isSelected, selectedRole); } } try { FRContext.getCurrentEnv().writeResource(cm); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } } private void dealWithWebContent(WebContent wc, Widget widget, boolean isSelected, String selectedRole) { ToolBarManager[] managers = wc.getToolBarManagers(); if (managers == null) { return; } for (int i = 0; i < managers.length; i++) { ToolBar tb = managers[i].getToolBar(); for (int j = 0; j < tb.getWidgetSize(); j++) { if (widget instanceof Button && tb.getWidget(j) instanceof Button) { if (ComparatorUtils.equals(((Button) widget).getIconName(), ((Button) tb.getWidget(j)).getIconName())) { if (!isSelected) { tb.getWidget(j).getWidgetPrivilegeControl().addInvisibleRole(selectedRole); } else { tb.getWidget(j).getWidgetPrivilegeControl().removeInvisibleRole(selectedRole); } } } } } wc.setToolBarManagers(managers); } public void populateBean(ReportWebAttr reportWebAttr) { this.remove(title); // 如果是空值就说明采用服务器配置了 if (reportWebAttr == null || this.getWebContent(reportWebAttr) == null) { title = new UILabel(Inter.getLocText(new String[]{"Server", "ReportServerP-Toolbar", "Choose_Role"})); populateServerSettings(); this.add(title, 0); return; } // 模板设置 T webContent = this.getWebContent(reportWebAttr); title = new UILabel(Inter.getLocText(new String[]{"the_template", "ReportServerP-Toolbar", "Choose_Role"})); this.add(title, 0); populate(webContent.getToolBarManagers()); } public ReportWebAttr updateBean() { return null; } public void populate(ToolBarManager[] toolBarManager) { if (ArrayUtils.isEmpty(toolBarManager)) { return; } if (toolBarManager.length == 0) { return; } for (int i = 0; i < toolBarManager.length; i++) { toolBarPane.populateBean(toolBarManager[i].getToolBar()); } } public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.height = ToolBarMenuDock.PANLE_HEIGNT; return dim; } public void populateBean(ToolBarManager[] toolBarManager) { if (ArrayUtils.isEmpty(toolBarManager)) { return; } for (int i = 0; i < toolBarManager.length; i++) { Location location = toolBarManager[i].getToolBarLocation(); if (location instanceof Location.Embed) { toolBarPane.populateBean(toolBarManager[i].getToolBar()); } } } private void populateServerSettings() { ConfigManagerProvider cm = ConfigManager.getProviderInstance(); ReportWebAttr webAttr = ((ReportWebAttr) cm.getGlobalAttribute(ReportWebAttr.class)); if (this.getWebContent(webAttr) != null) { populate(this.getWebContent(webAttr).getToolBarManagers()); } } protected String title4PopupWindow() { return null; } private T getWebContent(ReportWebAttr reportWebAttr) { if (choseComboBox.getSelectedIndex() == 0) { return reportWebAttr == null ? null : (T) reportWebAttr.getWebPage(); } else if (choseComboBox.getSelectedIndex() == 1) { return reportWebAttr == null ? null : (T) reportWebAttr.getWebWrite(); } else { return reportWebAttr == null ? null : (T) reportWebAttr.getWebView(); } } private void populateDefaultToolBarWidgets() { if (choseComboBox.getSelectedIndex() == 0) { ReportWebWidgetConstants.getPageToolBarInstance(); } else if (choseComboBox.getSelectedIndex() == 1) { ReportWebWidgetConstants.getWriteToolBarInstance(); } else { ReportWebWidgetConstants.getViewToolBarInstance(); } } private ToolBarManager getDefaultToolBarManager() { if (choseComboBox.getSelectedIndex() == 0) { return ToolBarManager.createDefaultToolBar(); } else if (choseComboBox.getSelectedIndex() == 1) { return ToolBarManager.createDefaultWriteToolBar(); } else { return ToolBarManager.createDefaultViewToolBar(); } } } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java b/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java index 9eb6303d52..6e59d01224 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java @@ -1 +1 @@ -package com.fr.design.mainframe; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Rectangle; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingConstants; import com.fr.design.constants.LayoutConstants; import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.js.NameJavaScriptGroup; import com.fr.report.cell.AbstractCellElement; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ColumnRow; /** * Author : daisy * Date: 13-9-4 * Time: 下午4:01 */ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { private static final int WIDGET_VISIBLE = 0; private static final int WIDGET_USABLE = 1; private static final int CELL = 2; private static final int HYPER_LINK = 3; private static final int FLOAT_SELECTION = 3; private static final int NEW_VALUE = 4; //新值下面的编辑器的宽度 private static final int NEW_PANE_WIDTH = 120; private UICheckBox floatElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox cellElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox widgetVisible = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox widgetAvailable = new UICheckBox(Inter.getLocText("FR-Designer_Enabled")); private UICheckBox gridColumnRowVisible = new UICheckBox(Inter.getLocText("FR-Designer_Hide")); private UICheckBox newValue = new UICheckBox(Inter.getLocText("FR-Designer_New_Value")); private ValueEditorPane valueEditor = ValueEditorPaneFactory.createBasicValueEditorPane(NEW_PANE_WIDTH); private UICheckBox[] hyperlinkCheckBoxes = null; private ElementCasePane elementCasePane = null; private int selectionType = CellSelection.NORMAL; private CellSelection cellSelection; private FloatSelection floatSelection; private boolean isAllHasWidget; private boolean isAllHasHyperlink; private UIObserverListener observerListener = new UIObserverListener() { @Override public void doChange() { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(NEW_VALUE)) { elementCasePane.fireTargetModified(); } } }; private ItemListener newValuelistener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(NEW_VALUE)) { valueEditor.setEnabled(newValue.isSelected()); doAfterAuthority(); } } }; private ItemListener columnRowAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null) { return; } boolean isDone = false; if (selectionType == CellSelection.CHOOSE_COLUMN) { isDone = setAuthorityColumn(); } else { isDone = setAuthorityRow(); } if (isDone) { doAfterAuthority(); } } }; private ItemListener floatElementAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || floatSelection == null) { return; } if (setLFloatAuthorityStyle()) { doAfterAuthority(); } } }; private ItemListener cellRolesAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(CELL)) { doAfterAuthority(); } } }; private ItemListener widgetVisibleRoleAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(WIDGET_VISIBLE)) { doAfterAuthority(); } } }; private ItemListener widgetUsableAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(WIDGET_USABLE)) { doAfterAuthority(); } } }; public ElementCasePaneAuthorityEditPane(ElementCasePane elementCasePane) { super(elementCasePane); this.elementCasePane = elementCasePane; initCheckBoxesState(); initListener(); } private void doAfterAuthority() { elementCasePane.repaint(); elementCasePane.fireTargetModified(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().setReportAndFSSelectedRoles(); RolesAlreadyEditedPane.getInstance().repaint(); checkCheckBoxes(); } private boolean setAuthorityColumn() { String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRoles, Inter.getLocText("FR-Designer_Role"))) { return false; } if (selectedRoles == null) { return false; } final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isVisible = !gridColumnRowVisible.isSelected(); if (!isVisible) { for (int col = cellSelection.getColumn(); col < cellSelection.getColumn() + cellSelection.getColumnSpan(); col++) { elementCase.addColumnPrivilegeControl(col, selectedRoles); } } else { for (int col = cellSelection.getColumn(); col < cellSelection.getColumn() + cellSelection.getColumnSpan(); col++) { elementCase.removeColumnPrivilegeControl(col, selectedRoles); } } return true; } private boolean setAuthorityRow() { String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRoles, Inter.getLocText("FR-Designer_Role"))) { return false; } if (selectedRoles == null) { return false; } final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isVisible = !gridColumnRowVisible.isSelected(); if (!isVisible) { for (int row = cellSelection.getRow(); row < cellSelection.getRow() + cellSelection.getRowSpan(); row++) { elementCase.addRowPrivilegeControl(row, selectedRoles); } } else { for (int row = cellSelection.getRow(); row < cellSelection.getRow() + cellSelection.getRowSpan(); row++) { elementCase.removeRowPrivilegeControl(row, selectedRoles); } } return true; } private boolean setLFloatAuthorityStyle() { String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRoles, Inter.getLocText("FR-Designer_Role"))) { return false; } if (selectedRoles == null) { return false; } String name = floatSelection.getSelectedFloatName(); TemplateElementCase ec = elementCasePane.getEditingElementCase(); FloatElement fe = ec.getFloatElement(name); fe.changeAuthorityState(selectedRoles, floatElementVisibleCheckBoxes.isSelected()); return true; } private boolean setAuthorityStyle(int type) { String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRoles, Inter.getLocText("FR-Designer_Role"))) { return false; } if (selectedRoles == null) { return false; } final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); int cellRectangleCount = cellSelection.getCellRectangleCount(); for (int rec = 0; rec < cellRectangleCount; rec++) { Rectangle cellRectangle = cellSelection.getCellRectangle(rec); // 从最后循环起以保证最后一个修改标准单元格(originalStyle)。 for (int j = cellRectangle.height - 1; j >= 0; j--) { for (int i = cellRectangle.width - 1; i >= 0; i--) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement == null) { editCellElement = new DefaultTemplateCellElement(column, row); elementCase.addCellElement(editCellElement); } else { // 对于合并的格子,我们不多次计算的权限. if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { continue; } } if (type == CELL) { editCellElement.changeAuthorityState(selectedRoles, cellElementVisibleCheckBoxes.isSelected()); } else if (type == NEW_VALUE) { editCellElement.changeNewValueAuthorityState(selectedRoles, newValue.isSelected(), valueEditor.update()); } else if (type == WIDGET_VISIBLE) { Widget widget = editCellElement.getWidget(); widget.changeVisibleAuthorityState(selectedRoles, widgetVisible.isSelected()); } else { Widget widget = editCellElement.getWidget(); widget.changeUsableAuthorityState(selectedRoles, widgetAvailable.isSelected()); } } } } return true; } /** * 选中的单元格的乐见状态以第一个单元格为齐 */ public void initCheckBoxesState() { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); if (cellSelection == null) { cellElementVisibleCheckBoxes.setSelected(true); } else { Rectangle cellRectangle = cellSelection.getCellRectangle(0); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellRectangle.x, cellRectangle.y); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellRectangle.x, cellRectangle.y); } boolean firstCellDoneaAuthority = cellElement.isDoneAuthority( ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName()); cellElementVisibleCheckBoxes.setSelected(!firstCellDoneaAuthority); } widgetAvailable.setEnabled(cellElementVisibleCheckBoxes.isSelected()); widgetVisible.setEnabled(cellElementVisibleCheckBoxes.isSelected()); } private void initListener() { cellElementVisibleCheckBoxes.addItemListener(cellRolesAuthorityListener); widgetVisible.addItemListener(widgetVisibleRoleAuthorityListener); widgetAvailable.addItemListener(widgetUsableAuthorityListener); floatElementVisibleCheckBoxes.addItemListener(floatElementAuthorityListener); gridColumnRowVisible.addItemListener(columnRowAuthorityListener); newValue.addItemListener(newValuelistener); valueEditor.registerChangeListener(observerListener); } private void removeListener() { cellElementVisibleCheckBoxes.removeItemListener(cellRolesAuthorityListener); widgetVisible.removeItemListener(widgetVisibleRoleAuthorityListener); widgetAvailable.removeItemListener(widgetUsableAuthorityListener); floatElementVisibleCheckBoxes.removeItemListener(floatElementAuthorityListener); gridColumnRowVisible.removeItemListener(columnRowAuthorityListener); newValue.removeItemListener(newValuelistener); valueEditor.registerChangeListener(null); } private void addHyperlinkListener() { cellElementVisibleCheckBoxes.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (hyperlinkCheckBoxes != null) { for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].setEnabled(cellElementVisibleCheckBoxes.isSelected()); if (!cellElementVisibleCheckBoxes.isSelected()) { hyperlinkCheckBoxes[i].setSelected(false); } } } } }); for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].addItemListener(cellRolesAuthorityListener); } } /** * 更新适合的类型 */ public void populateType() { if (selectionType == CellSelection.NORMAL) { type.setText(Inter.getLocText("FR-Designer_Cell")); } else if (selectionType == CellSelection.CHOOSE_ROW) { type.setText(Inter.getLocText("FR-Designer_Row")); } else if (selectionType == CellSelection.CHOOSE_COLUMN) { type.setText(Inter.getLocText("FR-Designer_Column")); } else { type.setText(Inter.getLocText("M_Insert-Float")); } } /** * 名字 */ public void populateName() { if (selectionType == CellSelection.NORMAL) { name.setText(getCellSelectionName()); } else if (selectionType == CellSelection.CHOOSE_ROW || selectionType == CellSelection.CHOOSE_COLUMN) { name.setText(getCellColumnRowName()); } else { name.setText(getFloatSelectionName()); } } private String getCellSelectionName() { String nameText = ""; int count = cellSelection.getCellRectangleCount(); for (int rect = 0; rect < count; rect++) { nameText += ","; Rectangle cellRectangle = cellSelection.getCellRectangle(rect); ColumnRow beginCR = ColumnRow.valueOf(cellRectangle.x, cellRectangle.y); nameText += beginCR.toString(); if (cellRectangle.width * cellRectangle.height != 1) { ColumnRow endCR = ColumnRow.valueOf(cellRectangle.width + cellRectangle.x - 1, cellRectangle.height + cellRectangle.y - 1); nameText += ":" + endCR.toString(); } } return nameText.substring(1); } private String getCellColumnRowName() { int count = cellSelection.getCellRectangleCount(); String nameText = ""; ColumnRow cr = ColumnRow.valueOf(cellSelection.getColumn(), cellSelection.getRow()); if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN && count == 1) { if (cellSelection.getColumnSpan() == 1) { nameText = cr.toString().substring(0, 1); } else { ColumnRow endCr = ColumnRow.valueOf(cellSelection.getColumn() + cellSelection.getColumnSpan() - 1, cellSelection.getRow() + cellSelection.getRowSpan() - 1); nameText = cr.toString().substring(0, 1) + "-" + endCr.toString().substring(0, 1); } } else if (cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW && count == 1) { if (cellSelection.getRowSpan() == 1) { nameText = cr.toString().substring(1); } else { ColumnRow endCr = ColumnRow.valueOf(cellSelection.getColumn() + cellSelection.getColumnSpan() - 1, cellSelection.getRow() + cellSelection.getRowSpan() - 1); nameText = cr.toString().substring(1) + "-" + endCr.toString().substring(1); } } return nameText; } private String getFloatSelectionName() { return floatSelection.getSelectedFloatName(); } private void mutilRect(CellSelection cellSelection) { isAllHasWidget = true; isAllHasHyperlink = true; int count = cellSelection.getCellRectangleCount(); final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); for (int rect = 0; rect < count; rect++) { Rectangle cellRectangle = cellSelection.getCellRectangle(rect); for (int j = 0; j < cellRectangle.height; j++) { for (int i = 0; i < cellRectangle.width; i++) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(column, row); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); } if (cellElement.getCellWidgetAttr() == null) { isAllHasWidget = false; } if (cellElement.getNameHyperlinkGroup() == null) { isAllHasHyperlink = false; } } } } } /** * 更新适合的pane * * @return 返回Pane */ public JPanel populateCheckPane() { checkPane.removeAll(); if (selectionType == CellSelection.NORMAL) { populateCellSelectionCheckPane(checkPane); } else if (selectionType == CellSelection.CHOOSE_COLUMN || selectionType == CellSelection.CHOOSE_ROW) { populateColumnRowCheckPane(checkPane); } else if (selectionType == FLOAT_SELECTION) { populateFloatSelectionCheckPane(checkPane); } checkPane.setBorder(BorderFactory.createEmptyBorder(ALIGNMENT_GAP, 0, 0, 0)); return checkPane; } private void populateColumnRowCheckPane(JPanel checkPane) { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{gridColumnRowVisible} }; double[] rowSize = {p}; double[] columnSize = {f}; int[][] rowCount = {{1}}; checkPane.add( TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM) , BorderLayout.WEST); } private void populateFloatSelectionCheckPane(JPanel checkPane) { checkPane.add(populateFloatElementCheckPane(), BorderLayout.WEST); } private void populateCellSelectionCheckPane(JPanel checkPane) { if (elementCasePane.isSelectedOneCell()) { //只选中了一个单元格 final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellSelection.getColumn(), cellSelection.getRow()); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); } //单元格带控件 if (cellElement.getCellWidgetAttr() != null) { checkPane.add(populateWidgetCheckPane(), BorderLayout.WEST); } else { checkPane.add(populatCellCheckPane(), BorderLayout.WEST); } } else { //批量选中单元格 mutilRect(cellSelection); if (!isAllHasWidget && !isAllHasHyperlink) { checkPane.add(populateMutilCellCheckPane(), BorderLayout.WEST); } else if (isAllHasWidget) { checkPane.add(populateMutilWidgetCheckPane(), BorderLayout.WEST); } } } /** * 对单元格区域进行操作时的权限编辑页面 ,对应的角色的populate */ public void populateDetials() { //做模式标记,此时鼠标焦点是在报表主体,为下一次退出权限编辑时做准备 HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setAuthorityMode(false); TemplateElementCase templateElementCase = elementCasePane.getEditingElementCase(); if (templateElementCase instanceof WorkSheet) { ((WorkSheet) templateElementCase).setPaintSelection(true); } signelSelection(); Selection selection = elementCasePane.getSelection(); if (selection instanceof CellSelection) { selectionType = CellSelection.NORMAL; this.cellSelection = ((CellSelection) selection).clone(); this.floatSelection = null; judgeChooseCR(); } else if (selection instanceof FloatSelection) { selectionType = FLOAT_SELECTION; cellSelection = null; floatSelection = new FloatSelection(((FloatSelection) selection).getSelectedFloatName()); } populateType(); populateName(); populateCheckPane(); checkCheckBoxes(); } //判断是否选择的行列 private void judgeChooseCR() { if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN && cellSelection.getCellRectangleCount() == 1) { selectionType = CellSelection.CHOOSE_COLUMN; } if (cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW && cellSelection.getCellRectangleCount() == 1) { selectionType = CellSelection.CHOOSE_ROW; } } //实现单选 private void signelSelection() { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate.isJWorkBook()) { //清工具栏 JComponent component = DesignerContext.getDesignerFrame().getToolbarComponent(); if (component instanceof AuthorityEditToolBarComponent) { ((AuthorityEditToolBarComponent) component).removeSelection(); } //清参数面板 jTemplate.removeParameterPaneSelection(); } } private JPanel populateFloatElementCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("M_Insert-Float"), SwingConstants.LEFT), floatElementVisibleCheckBoxes} }; double[] rowSize = {p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, new Component[]{null, newValue}, new Component[]{null, valueEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, new Component[]{null, widgetAvailable} }; double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, new Component[]{null, widgetAvailable} }; double[] rowSize = {p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes}, }; double[] rowSize = {p}; double[] columnSize = {f}; int[][] rowCount = {{1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populatCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes}, new Component[]{newValue}, new Component[]{valueEditor} }; double[] rowSize = {p, p, p}; double[] columnSize = {f}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } public TemplateCellElement getFirstCell() { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); Rectangle cellRectangle = cellSelection.getCellRectangle(0); // 从最后循环起以保证最后一个修改标准单元格(originalStyle)。 TemplateCellElement firstCell = null; for (int j = cellRectangle.height - 1; j >= 0; j--) { for (int i = cellRectangle.width - 1; i >= 0; i--) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement != null) { // 对于合并的格子,我们不多次计算的权限. if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { continue; } firstCell = editCellElement; } } } return firstCell; } private void checkCheckBoxes() { String selected = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); removeListener(); if (selectionType == CellSelection.NORMAL) { checkCellSelectionCkeckboxes(selected); } else if (selectionType == CellSelection.CHOOSE_COLUMN || selectionType == CellSelection.CHOOSE_ROW) { checkColumnRowCheckBoxes(selected); } else if (selectionType == FLOAT_SELECTION) { checkFloatSelectionCkeckboxes(selected); } initListener(); } private void checkCellSelectionCkeckboxes(String selected) { TemplateCellElement firstCell = getFirstCell(); if (firstCell == null) { resetCellElementCheckBoxes(); return; } cellElementVisibleCheckBoxes.setSelected(!firstCell.isDoneAuthority(selected)); newValue.setEnabled(!firstCell.isDoneAuthority(selected)); if (!firstCell.isDoneAuthority(selected)) { newValue.setSelected(firstCell.isDoneNewValueAuthority(selected)); if (newValue.isSelected()) { valueEditor.setEnabled(true); valueEditor.populate(firstCell.getCellPrivilegeControl().getNewValueMap().get(selected)); } else { valueEditor.setEnabled(false); } } else { newValue.setSelected(false); valueEditor.setEnabled(false); } populateWidgetButton(firstCell.getWidget(), selected, firstCell); } private void populateWidgetButton(Widget widget, String selected, TemplateCellElement firstCell){ if(widget == null){ return; } if(widget.isVisible()){ widgetVisible.setSelected(!widget.isDoneVisibleAuthority(selected)); widgetVisible.setEnabled(!firstCell.isDoneAuthority(selected)); }else{ widgetVisible.setSelected(widget.isVisibleAuthority(selected)); } if(widget.isEnabled()){ widgetAvailable.setSelected(!widget.isDoneUsableAuthority(selected)); widgetAvailable.setEnabled(!widget.isDoneVisibleAuthority(selected)); }else{ widgetAvailable.setSelected(widget.isUsableAuthority(selected)); } } private void resetCellElementCheckBoxes() { cellElementVisibleCheckBoxes.setSelected(true); widgetVisible.setSelected(true); widgetVisible.setEnabled(true); widgetAvailable.setSelected(true); widgetAvailable.setEnabled(true); newValue.setSelected(false); valueEditor.setEnabled(false); } private void checkColumnRowCheckBoxes(String selected) { if (cellSelection == null) { gridColumnRowVisible.setSelected(false); return; } TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isInside = selectionType == CellSelection.CHOOSE_COLUMN ? elementCase.getColumnPrivilegeControl(cellSelection.getColumn()).checkInvisible(selected) : elementCase.getRowPrivilegeControl(cellSelection.getRow()).checkInvisible(selected); gridColumnRowVisible.setSelected(isInside); } private void checkFloatSelectionCkeckboxes(String selected) { String name = floatSelection.getSelectedFloatName(); TemplateElementCase ec = elementCasePane.getEditingElementCase(); FloatElement fe = ec.getFloatElement(name); floatElementVisibleCheckBoxes.setSelected(!fe.isDoneAuthority(selected)); } private JPanel populateHyperlinkCheckPane(AbstractCellElement cellElement) { NameJavaScriptGroup linkGroup = cellElement.getNameHyperlinkGroup(); //超链接的个数+单元格可见的操作 hyperlinkCheckBoxes = new UICheckBox[linkGroup.size()]; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[hyperlinkCheckBoxes.length + 1][]; if (linkGroup.size() == 1) { components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; } else { components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(linkGroup.getNameHyperlink(0).getName() + Inter.getLocText("FR-Designer_Visible"))}; for (int i = 1; i < hyperlinkCheckBoxes.length; i++) { components[i + 1] = new Component[]{null, hyperlinkCheckBoxes[i] = new UICheckBox(linkGroup.getNameHyperlink(i).getName() + Inter.getLocText("FR-Designer_Visible"))}; } } for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].setEnabled(cellElementVisibleCheckBoxes.isSelected()); } addHyperlinkListener(); double[] rowSize = new double[hyperlinkCheckBoxes.length + 1]; int[][] rowCount = new int[hyperlinkCheckBoxes.length + 1][]; for (int i = 0; i < hyperlinkCheckBoxes.length + 1; i++) { rowSize[i] = p; rowCount[i] = new int[]{1, 1}; } double[] columnSize = {p, f}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilHyperlinkCheckPane() { //超链接的个数+单元格可见的操作 hyperlinkCheckBoxes = new UICheckBox[1]; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[2][]; components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; hyperlinkCheckBoxes[0].setEnabled(cellElementVisibleCheckBoxes.isSelected()); addHyperlinkListener(); double[] rowSize = {p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } } \ No newline at end of file +package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.js.NameJavaScriptGroup; import com.fr.report.cell.AbstractCellElement; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ColumnRow; import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; /** * Author : daisy * Date: 13-9-4 * Time: 下午4:01 */ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { private static final int WIDGET_VISIBLE = 0; private static final int WIDGET_USABLE = 1; private static final int CELL = 2; private static final int HYPER_LINK = 3; private static final int FLOAT_SELECTION = 3; private static final int NEW_VALUE = 4; //新值下面的编辑器的宽度 private static final int NEW_PANE_WIDTH = 120; private UICheckBox floatElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox cellElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox widgetVisible = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox widgetAvailable = new UICheckBox(Inter.getLocText("FR-Designer_Enabled")); private UICheckBox gridColumnRowVisible = new UICheckBox(Inter.getLocText("FR-Designer_Hide")); private UICheckBox newValue = new UICheckBox(Inter.getLocText("FR-Designer_New_Value")); private ValueEditorPane valueEditor = ValueEditorPaneFactory.createBasicValueEditorPane(NEW_PANE_WIDTH); private UICheckBox[] hyperlinkCheckBoxes = null; private ElementCasePane elementCasePane = null; private int selectionType = CellSelection.NORMAL; private CellSelection cellSelection; private FloatSelection floatSelection; private boolean isAllHasWidget; private boolean isAllHasHyperlink; private String[] selectedPathArray; private UIObserverListener observerListener = new UIObserverListener() { @Override public void doChange() { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(NEW_VALUE)) { elementCasePane.fireTargetModified(); } } }; private ItemListener newValuelistener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(NEW_VALUE)) { valueEditor.setEnabled(newValue.isSelected()); doAfterAuthority(); } } }; private ItemListener columnRowAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null) { return; } boolean isDone = false; if (selectionType == CellSelection.CHOOSE_COLUMN) { isDone = setAuthorityColumn(); } else { isDone = setAuthorityRow(); } if (isDone) { doAfterAuthority(); } } }; private ItemListener floatElementAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || floatSelection == null) { return; } if (setLFloatAuthorityStyle()) { doAfterAuthority(); } } }; private ItemListener cellRolesAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(CELL)) { doAfterAuthority(); } } }; private ItemListener widgetVisibleRoleAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(WIDGET_VISIBLE)) { doAfterAuthority(); } } }; private ItemListener widgetUsableAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(WIDGET_USABLE)) { doAfterAuthority(); } } }; public ElementCasePaneAuthorityEditPane(ElementCasePane elementCasePane) { super(elementCasePane); this.elementCasePane = elementCasePane; initCheckBoxesState(); initListener(); } private void doAfterAuthority() { elementCasePane.repaint(); elementCasePane.fireTargetModified(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().setReportAndFSSelectedRoles(); RolesAlreadyEditedPane.getInstance().repaint(); checkCheckBoxes(); } private boolean setAuthorityColumn() { initSelectedselectedPathArray(); String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRoles, Inter.getLocText("FR-Designer_Role"))) { return false; } if (selectedRoles == null) { return false; } if (selectedPathArray == null) { return false; } final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isVisible = !gridColumnRowVisible.isSelected(); for (int t = 0; t= 0; j--) { for (int i = cellRectangle.width - 1; i >= 0; i--) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement == null) { editCellElement = new DefaultTemplateCellElement(column, row); elementCase.addCellElement(editCellElement); } else { // 对于合并的格子,我们不多次计算的权限. if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { continue; } } if (type == CELL) { editCellElement.changeAuthorityState(selectedPathArray[t], cellElementVisibleCheckBoxes.isSelected()); } else if (type == NEW_VALUE) { editCellElement.changeNewValueAuthorityState(selectedPathArray[t], newValue.isSelected(), valueEditor.update()); } else if (type == WIDGET_VISIBLE) { Widget widget = editCellElement.getWidget(); widget.changeVisibleAuthorityState(selectedPathArray[t], widgetVisible.isSelected()); } else { Widget widget = editCellElement.getWidget(); widget.changeUsableAuthorityState(selectedPathArray[t], widgetAvailable.isSelected()); } } } } } return true; } private void initSelectedselectedPathArray () { TreePath[] selectionPaths = ReportAndFSManagePane.getInstance().getRoleTree().getCheckBoxTreeSelectionModel().getSelectionPaths(); if (selectionPaths.length==1){ if(((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getChildCount() > 0){ ExpandMutableTreeNode node = (ExpandMutableTreeNode) ((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getLastChild(); System.out.printf(node.getUserObject().toString()); selectedPathArray = new String[node.getChildCount()]; for (int y =0; y 0 && temp.charAt(0) == '[' && temp.endsWith("]"); if (isTrue) { temp = temp.substring(1, temp.length() - 1); String[] selectedRoles = temp.split(","); String role = selectedRoles[2].trim(); if(roles.isEmpty()){ roles = role; }else{ roles = roles + "," + role; } } } String[] selectedRole = roles.split(","); return selectedRole; } /** * 选中的单元格的乐见状态以第一个单元格为齐 */ public void initCheckBoxesState() { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); if (cellSelection == null) { cellElementVisibleCheckBoxes.setSelected(true); } else { Rectangle cellRectangle = cellSelection.getCellRectangle(0); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellRectangle.x, cellRectangle.y); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellRectangle.x, cellRectangle.y); } boolean firstCellDoneaAuthority = cellElement.isDoneAuthority( ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName()); cellElementVisibleCheckBoxes.setSelected(!firstCellDoneaAuthority); } widgetAvailable.setEnabled(cellElementVisibleCheckBoxes.isSelected()); widgetVisible.setEnabled(cellElementVisibleCheckBoxes.isSelected()); } private void initListener() { cellElementVisibleCheckBoxes.addItemListener(cellRolesAuthorityListener); widgetVisible.addItemListener(widgetVisibleRoleAuthorityListener); widgetAvailable.addItemListener(widgetUsableAuthorityListener); floatElementVisibleCheckBoxes.addItemListener(floatElementAuthorityListener); gridColumnRowVisible.addItemListener(columnRowAuthorityListener); newValue.addItemListener(newValuelistener); valueEditor.registerChangeListener(observerListener); } private void removeListener() { cellElementVisibleCheckBoxes.removeItemListener(cellRolesAuthorityListener); widgetVisible.removeItemListener(widgetVisibleRoleAuthorityListener); widgetAvailable.removeItemListener(widgetUsableAuthorityListener); floatElementVisibleCheckBoxes.removeItemListener(floatElementAuthorityListener); gridColumnRowVisible.removeItemListener(columnRowAuthorityListener); newValue.removeItemListener(newValuelistener); valueEditor.registerChangeListener(null); } private void addHyperlinkListener() { cellElementVisibleCheckBoxes.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (hyperlinkCheckBoxes != null) { for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].setEnabled(cellElementVisibleCheckBoxes.isSelected()); if (!cellElementVisibleCheckBoxes.isSelected()) { hyperlinkCheckBoxes[i].setSelected(false); } } } } }); for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].addItemListener(cellRolesAuthorityListener); } } /** * 更新适合的类型 */ public void populateType() { if (selectionType == CellSelection.NORMAL) { type.setText(Inter.getLocText("FR-Designer_Cell")); } else if (selectionType == CellSelection.CHOOSE_ROW) { type.setText(Inter.getLocText("FR-Designer_Row")); } else if (selectionType == CellSelection.CHOOSE_COLUMN) { type.setText(Inter.getLocText("FR-Designer_Column")); } else { type.setText(Inter.getLocText("M_Insert-Float")); } } /** * 名字 */ public void populateName() { if (selectionType == CellSelection.NORMAL) { name.setText(getCellSelectionName()); } else if (selectionType == CellSelection.CHOOSE_ROW || selectionType == CellSelection.CHOOSE_COLUMN) { name.setText(getCellColumnRowName()); } else { name.setText(getFloatSelectionName()); } } private String getCellSelectionName() { String nameText = ""; int count = cellSelection.getCellRectangleCount(); for (int rect = 0; rect < count; rect++) { nameText += ","; Rectangle cellRectangle = cellSelection.getCellRectangle(rect); ColumnRow beginCR = ColumnRow.valueOf(cellRectangle.x, cellRectangle.y); nameText += beginCR.toString(); if (cellRectangle.width * cellRectangle.height != 1) { ColumnRow endCR = ColumnRow.valueOf(cellRectangle.width + cellRectangle.x - 1, cellRectangle.height + cellRectangle.y - 1); nameText += ":" + endCR.toString(); } } return nameText.substring(1); } private String getCellColumnRowName() { int count = cellSelection.getCellRectangleCount(); String nameText = ""; ColumnRow cr = ColumnRow.valueOf(cellSelection.getColumn(), cellSelection.getRow()); if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN && count == 1) { if (cellSelection.getColumnSpan() == 1) { nameText = cr.toString().substring(0, 1); } else { ColumnRow endCr = ColumnRow.valueOf(cellSelection.getColumn() + cellSelection.getColumnSpan() - 1, cellSelection.getRow() + cellSelection.getRowSpan() - 1); nameText = cr.toString().substring(0, 1) + "-" + endCr.toString().substring(0, 1); } } else if (cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW && count == 1) { if (cellSelection.getRowSpan() == 1) { nameText = cr.toString().substring(1); } else { ColumnRow endCr = ColumnRow.valueOf(cellSelection.getColumn() + cellSelection.getColumnSpan() - 1, cellSelection.getRow() + cellSelection.getRowSpan() - 1); nameText = cr.toString().substring(1) + "-" + endCr.toString().substring(1); } } return nameText; } private String getFloatSelectionName() { return floatSelection.getSelectedFloatName(); } private void mutilRect(CellSelection cellSelection) { isAllHasWidget = true; isAllHasHyperlink = true; int count = cellSelection.getCellRectangleCount(); final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); for (int rect = 0; rect < count; rect++) { Rectangle cellRectangle = cellSelection.getCellRectangle(rect); for (int j = 0; j < cellRectangle.height; j++) { for (int i = 0; i < cellRectangle.width; i++) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(column, row); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); } if (cellElement.getCellWidgetAttr() == null) { isAllHasWidget = false; } if (cellElement.getNameHyperlinkGroup() == null) { isAllHasHyperlink = false; } } } } } /** * 更新适合的pane * * @return 返回Pane */ public JPanel populateCheckPane() { checkPane.removeAll(); if (selectionType == CellSelection.NORMAL) { populateCellSelectionCheckPane(checkPane); } else if (selectionType == CellSelection.CHOOSE_COLUMN || selectionType == CellSelection.CHOOSE_ROW) { populateColumnRowCheckPane(checkPane); } else if (selectionType == FLOAT_SELECTION) { populateFloatSelectionCheckPane(checkPane); } checkPane.setBorder(BorderFactory.createEmptyBorder(ALIGNMENT_GAP, 0, 0, 0)); return checkPane; } private void populateColumnRowCheckPane(JPanel checkPane) { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{gridColumnRowVisible} }; double[] rowSize = {p}; double[] columnSize = {f}; int[][] rowCount = {{1}}; checkPane.add( TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM) , BorderLayout.WEST); } private void populateFloatSelectionCheckPane(JPanel checkPane) { checkPane.add(populateFloatElementCheckPane(), BorderLayout.WEST); } private void populateCellSelectionCheckPane(JPanel checkPane) { if (elementCasePane.isSelectedOneCell()) { //只选中了一个单元格 final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellSelection.getColumn(), cellSelection.getRow()); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); } //单元格带控件 if (cellElement.getCellWidgetAttr() != null) { checkPane.add(populateWidgetCheckPane(), BorderLayout.WEST); } else { checkPane.add(populatCellCheckPane(), BorderLayout.WEST); } } else { //批量选中单元格 mutilRect(cellSelection); if (!isAllHasWidget && !isAllHasHyperlink) { checkPane.add(populateMutilCellCheckPane(), BorderLayout.WEST); } else if (isAllHasWidget) { checkPane.add(populateMutilWidgetCheckPane(), BorderLayout.WEST); } } } /** * 对单元格区域进行操作时的权限编辑页面 ,对应的角色的populate */ public void populateDetials() { //做模式标记,此时鼠标焦点是在报表主体,为下一次退出权限编辑时做准备 HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setAuthorityMode(false); TemplateElementCase templateElementCase = elementCasePane.getEditingElementCase(); if (templateElementCase instanceof WorkSheet) { ((WorkSheet) templateElementCase).setPaintSelection(true); } signelSelection(); Selection selection = elementCasePane.getSelection(); if (selection instanceof CellSelection) { selectionType = CellSelection.NORMAL; this.cellSelection = ((CellSelection) selection).clone(); this.floatSelection = null; judgeChooseCR(); } else if (selection instanceof FloatSelection) { selectionType = FLOAT_SELECTION; cellSelection = null; floatSelection = new FloatSelection(((FloatSelection) selection).getSelectedFloatName()); } populateType(); populateName(); populateCheckPane(); checkCheckBoxes(); } //判断是否选择的行列 private void judgeChooseCR() { if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN && cellSelection.getCellRectangleCount() == 1) { selectionType = CellSelection.CHOOSE_COLUMN; } if (cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW && cellSelection.getCellRectangleCount() == 1) { selectionType = CellSelection.CHOOSE_ROW; } } //实现单选 private void signelSelection() { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate.isJWorkBook()) { //清工具栏 JComponent component = DesignerContext.getDesignerFrame().getToolbarComponent(); if (component instanceof AuthorityEditToolBarComponent) { ((AuthorityEditToolBarComponent) component).removeSelection(); } //清参数面板 jTemplate.removeParameterPaneSelection(); } } private JPanel populateFloatElementCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("M_Insert-Float"), SwingConstants.LEFT), floatElementVisibleCheckBoxes} }; double[] rowSize = {p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, new Component[]{null, newValue}, new Component[]{null, valueEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, new Component[]{null, widgetAvailable} }; double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, new Component[]{null, widgetAvailable} }; double[] rowSize = {p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes}, }; double[] rowSize = {p}; double[] columnSize = {f}; int[][] rowCount = {{1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populatCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes}, new Component[]{newValue}, new Component[]{valueEditor} }; double[] rowSize = {p, p, p}; double[] columnSize = {f}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } public TemplateCellElement getFirstCell() { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); Rectangle cellRectangle = cellSelection.getCellRectangle(0); // 从最后循环起以保证最后一个修改标准单元格(originalStyle)。 TemplateCellElement firstCell = null; for (int j = cellRectangle.height - 1; j >= 0; j--) { for (int i = cellRectangle.width - 1; i >= 0; i--) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement != null) { // 对于合并的格子,我们不多次计算的权限. if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { continue; } firstCell = editCellElement; } } } return firstCell; } private void checkCheckBoxes() { String selected = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); removeListener(); if (selectionType == CellSelection.NORMAL) { checkCellSelectionCkeckboxes(selected); } else if (selectionType == CellSelection.CHOOSE_COLUMN || selectionType == CellSelection.CHOOSE_ROW) { checkColumnRowCheckBoxes(selected); } else if (selectionType == FLOAT_SELECTION) { checkFloatSelectionCkeckboxes(selected); } initListener(); } private void checkCellSelectionCkeckboxes(String selected) { TemplateCellElement firstCell = getFirstCell(); if (firstCell == null) { resetCellElementCheckBoxes(); return; } cellElementVisibleCheckBoxes.setSelected(!firstCell.isDoneAuthority(selected)); newValue.setEnabled(!firstCell.isDoneAuthority(selected)); if (!firstCell.isDoneAuthority(selected)) { newValue.setSelected(firstCell.isDoneNewValueAuthority(selected)); if (newValue.isSelected()) { valueEditor.setEnabled(true); valueEditor.populate(firstCell.getCellPrivilegeControl().getNewValueMap().get(selected)); } else { valueEditor.setEnabled(false); } } else { newValue.setSelected(false); valueEditor.setEnabled(false); } populateWidgetButton(firstCell.getWidget(), selected, firstCell); } private void populateWidgetButton(Widget widget, String selected, TemplateCellElement firstCell){ if(widget == null){ return; } if(widget.isVisible()){ widgetVisible.setSelected(!widget.isDoneVisibleAuthority(selected)); widgetVisible.setEnabled(!firstCell.isDoneAuthority(selected)); }else{ widgetVisible.setSelected(widget.isVisibleAuthority(selected)); } if(widget.isEnabled()){ widgetAvailable.setSelected(!widget.isDoneUsableAuthority(selected)); widgetAvailable.setEnabled(!widget.isDoneVisibleAuthority(selected)); }else{ widgetAvailable.setSelected(widget.isUsableAuthority(selected)); } } private void resetCellElementCheckBoxes() { cellElementVisibleCheckBoxes.setSelected(true); widgetVisible.setSelected(true); widgetVisible.setEnabled(true); widgetAvailable.setSelected(true); widgetAvailable.setEnabled(true); newValue.setSelected(false); valueEditor.setEnabled(false); } private void checkColumnRowCheckBoxes(String selected) { if (cellSelection == null) { gridColumnRowVisible.setSelected(false); return; } TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isInside = selectionType == CellSelection.CHOOSE_COLUMN ? elementCase.getColumnPrivilegeControl(cellSelection.getColumn()).checkInvisible(selected) : elementCase.getRowPrivilegeControl(cellSelection.getRow()).checkInvisible(selected); gridColumnRowVisible.setSelected(isInside); } private void checkFloatSelectionCkeckboxes(String selected) { String name = floatSelection.getSelectedFloatName(); TemplateElementCase ec = elementCasePane.getEditingElementCase(); FloatElement fe = ec.getFloatElement(name); floatElementVisibleCheckBoxes.setSelected(!fe.isDoneAuthority(selected)); } private JPanel populateHyperlinkCheckPane(AbstractCellElement cellElement) { NameJavaScriptGroup linkGroup = cellElement.getNameHyperlinkGroup(); //超链接的个数+单元格可见的操作 hyperlinkCheckBoxes = new UICheckBox[linkGroup.size()]; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[hyperlinkCheckBoxes.length + 1][]; if (linkGroup.size() == 1) { components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; } else { components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(linkGroup.getNameHyperlink(0).getName() + Inter.getLocText("FR-Designer_Visible"))}; for (int i = 1; i < hyperlinkCheckBoxes.length; i++) { components[i + 1] = new Component[]{null, hyperlinkCheckBoxes[i] = new UICheckBox(linkGroup.getNameHyperlink(i).getName() + Inter.getLocText("FR-Designer_Visible"))}; } } for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].setEnabled(cellElementVisibleCheckBoxes.isSelected()); } addHyperlinkListener(); double[] rowSize = new double[hyperlinkCheckBoxes.length + 1]; int[][] rowCount = new int[hyperlinkCheckBoxes.length + 1][]; for (int i = 0; i < hyperlinkCheckBoxes.length + 1; i++) { rowSize[i] = p; rowCount[i] = new int[]{1, 1}; } double[] columnSize = {p, f}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilHyperlinkCheckPane() { //超链接的个数+单元格可见的操作 hyperlinkCheckBoxes = new UICheckBox[1]; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[2][]; components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; hyperlinkCheckBoxes[0].setEnabled(cellElementVisibleCheckBoxes.isSelected()); addHyperlinkListener(); double[] rowSize = {p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/itree/refreshabletree/RefreshableJTree.java b/designer_base/src/com/fr/design/gui/itree/refreshabletree/RefreshableJTree.java index fdf6b56ade..963c5506b7 100644 --- a/designer_base/src/com/fr/design/gui/itree/refreshabletree/RefreshableJTree.java +++ b/designer_base/src/com/fr/design/gui/itree/refreshabletree/RefreshableJTree.java @@ -9,6 +9,7 @@ import javax.swing.tree.*; import com.fr.general.NameObject; import com.fr.design.constants.UIConstants; import com.fr.design.gui.itooltip.UIToolTip; +import com.fr.design.gui.itree.checkboxtree.CheckBoxTree; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.StringUtils; @@ -16,7 +17,7 @@ import com.fr.stable.StringUtils; import java.awt.*; import java.awt.event.MouseEvent; -public abstract class RefreshableJTree extends JTree { +public abstract class RefreshableJTree extends CheckBoxTree { private static final int WIDTH_BETWEEN_NODES = 20; //tree父子节点之间最左侧横向像素的差 private Icon icon; @@ -31,7 +32,9 @@ public abstract class RefreshableJTree extends JTree { public RefreshableJTree() { this(null); } - + public boolean isCheckBoxVisible(TreePath path) { + return false; + } public RefreshableJTree(Object rootObj) { super(new DefaultTreeModel(new ExpandMutableTreeNode(rootObj))); DefaultTreeModel model = (DefaultTreeModel) getModel(); diff --git a/designer_base/src/com/fr/design/gui/itree/refreshabletree/UserObjectRefreshJTree.java b/designer_base/src/com/fr/design/gui/itree/refreshabletree/UserObjectRefreshJTree.java index 9bef9e6fad..b463ca7eb6 100644 --- a/designer_base/src/com/fr/design/gui/itree/refreshabletree/UserObjectRefreshJTree.java +++ b/designer_base/src/com/fr/design/gui/itree/refreshabletree/UserObjectRefreshJTree.java @@ -133,7 +133,7 @@ public abstract class UserObjectRefreshJTree> extends super.setSelectionPath(treePath); } - private MouseListener treeMouseListener = new MouseAdapter() { + protected MouseListener treeMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { TreePath path = getPathForLocation(e.getX(), e.getY()); diff --git a/designer_base/src/com/fr/design/roleAuthority/RoleTree.java b/designer_base/src/com/fr/design/roleAuthority/RoleTree.java index de621a043e..3ee6279878 100644 --- a/designer_base/src/com/fr/design/roleAuthority/RoleTree.java +++ b/designer_base/src/com/fr/design/roleAuthority/RoleTree.java @@ -1 +1 @@ -package com.fr.design.roleAuthority; import com.fr.general.NameObject; import com.fr.design.constants.UIConstants; import com.fr.design.beans.BasicBeanPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree; import com.fr.design.mainframe.AuthorityPropertyPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.*; import java.awt.*; import java.util.Enumeration; /** * Author : daisy * Date: 13-8-30 * Time: 下午3:32 */ public class RoleTree extends UserObjectRefreshJTree { private static final long serialVersionUID = 2L; private String roleName = null; public RoleTree() { super(); this.setCellRenderer(roleTreeRenderer); this.setEnabled(true); this.setEditable(true); this.setRowHeight(20); this.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { doWithValueChanged(e); } }); } /** * 更新UI */ public void updateUI() { super.updateUI(); setUI(new UIRoleTreeUI()); } protected void doWithValueChanged(TreeSelectionEvent e) { if (e.getNewLeadSelectionPath() != null) { if (e.getNewLeadSelectionPath().getLastPathComponent().toString() != Inter.getLocText("Role")) { roleName = e.getNewLeadSelectionPath().getLastPathComponent().toString(); setTabRoleName(roleName); refreshRoleTree(roleName); refreshElementAndAuthorityPane(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().judgeSheetAuthority(roleName); } } } protected void setTabRoleName(String roleName) { } /** * 刷新角色树 * * @param selectedRole 角色 */ public void refreshRoleTree(String selectedRole) { if (EastRegionContainerPane.getInstance().getUpPane() instanceof AuthorityPropertyPane) { AuthorityPropertyPane authorityPropertyPane = (AuthorityPropertyPane) EastRegionContainerPane.getInstance().getUpPane(); authorityPropertyPane.populate(); EastRegionContainerPane.getInstance().replaceUpPane(authorityPropertyPane); } } public void setSelectedRole(String selectedRole, TreePath parent) { ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); if (node.children() != null && node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { ExpandMutableTreeNode n = (ExpandMutableTreeNode) e.nextElement(); Object userObj = n.getUserObject(); String chilld = null; if (userObj instanceof String) { chilld = (String) userObj; } else if (userObj instanceof NameObject) { NameObject nameObject = (NameObject) userObj; chilld = nameObject.getName(); } if (ComparatorUtils.equals(chilld, selectedRole)) { this.setSelectionPath(parent.pathByAddingChild(n)); return; } else { setSelectedRole(selectedRole, parent.pathByAddingChild(n)); } } } } private void refreshElementAndAuthorityPane() { JComponent authorityToolBar = DesignerContext.getDesignerFrame().getToolbarComponent(); if (authorityToolBar instanceof BasicBeanPane) { //说明是工具栏的 ((BasicBeanPane) authorityToolBar).populateAuthority(); } HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().repaint(); } public String getSelectedRoleName() { return roleName; } public void setSelectedRoleName(String name) { roleName = name; } private DefaultTreeCellRenderer roleTreeRenderer = new DefaultTreeCellRenderer() { private static final long serialVersionUID = 2L; public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) value; Object userObj = treeNode.getUserObject(); if (userObj instanceof String) { // p:这个是column field. this.setIcon(null); this.setText((String) userObj); } else if (userObj instanceof NameObject) { NameObject nameObject = (NameObject) userObj; this.setText(nameObject.getName()); this.setIcon(null); } // 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..." this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND); this.setForeground(UIConstants.FONT_COLOR); this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); return this; } }; /* * p:获得选中的NameObject = name + role. */ public NameObject getSelectedNameObject() { TreePath selectedTreePath = this.getSelectionPath(); if (selectedTreePath == null) { return null; } ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent(); Object selectedUserObject = selectedTreeNode.getUserObject(); return new NameObject(selectedUserObject.toString(), ""); } /** * p:添加一个NameObject节点 * @param no 需要添加的节点 */ public void addNameObject(NameObject no) { if (no == null) { return; } DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel(); // 新建一个放着NameObject的newChildTreeNode,加到Root下面 ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); ExpandMutableTreeNode newChildTreeNode = new ExpandMutableTreeNode(no); root.add(newChildTreeNode); newChildTreeNode.add(new ExpandMutableTreeNode()); treeModel.reload(root); } /** * 刷新树节点 */ public void refreshTreeNode() { DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel(); ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); if (interceptRefresh(root)) { return; } ExpandMutableTreeNode[] new_nodes = loadChildTreeNodes(root); java.util.List childTreeNodeList = new java.util.ArrayList(); for (int i = 0, len = root.getChildCount(); i < len; i++) { if (root.getChildAt(i) instanceof ExpandMutableTreeNode) { childTreeNodeList.add((ExpandMutableTreeNode) root.getChildAt(i)); } else { childTreeNodeList.add((DefaultMutableTreeNode) root.getChildAt(i)); } } root.removeAllChildren(); for (int ci = 0; ci < new_nodes.length; ci++) { Object cUserObject = new_nodes[ci].getUserObject(); for (int ni = 0, nlen = childTreeNodeList.size(); ni < nlen; ni++) { ExpandMutableTreeNode cTreeNode = (ExpandMutableTreeNode) childTreeNodeList.get(ni); if (ComparatorUtils.equals(cTreeNode.getUserObject(), cUserObject)) { new_nodes[ci].setExpanded(cTreeNode.isExpanded()); if (cTreeNode.getFirstChild() instanceof ExpandMutableTreeNode && cTreeNode.isExpanded()) { checkChildNodes(cTreeNode, new_nodes[ci]); } break; } } root.add(new_nodes[ci]); } } protected void checkChildNodes(ExpandMutableTreeNode oldNode, ExpandMutableTreeNode newNode) { for (int i = 0; i < oldNode.getChildCount(); i++) { ExpandMutableTreeNode oldChild = (ExpandMutableTreeNode) oldNode.getChildAt(i); for (int j = 0; j < newNode.getChildCount(); j++) { ExpandMutableTreeNode newChild = (ExpandMutableTreeNode) newNode.getChildAt(j); ExpandMutableTreeNode[] nodes = RoleTree.this.loadChildTreeNodes(newChild); for (int k = 0; k < nodes.length; k++) { newChild.add(nodes[k]); } if (newChild.getChildCount() > 1 && ((ExpandMutableTreeNode) newChild.getFirstChild()).getUserObject() == PENDING) { newChild.remove(0); } if (ComparatorUtils.equals(oldChild.getUserObject(), newChild.getUserObject())) { newChild.setExpanded(oldChild.isExpanded()); } } } } public NameObject getRealSelectedNameObject() { TreePath selectedTreePath = this.getSelectionPath(); if (selectedTreePath == null) { return null; } ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent(); Object selectedUserObject = selectedTreeNode.getUserObject(); if (selectedUserObject instanceof NameObject) { return (NameObject) selectedUserObject; } selectedTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent(); selectedUserObject = selectedTreeNode.getUserObject(); if (selectedUserObject instanceof NameObject) { return (NameObject) selectedUserObject; } return null; } } \ No newline at end of file +package com.fr.design.roleAuthority; import com.fr.general.NameObject; import com.fr.design.constants.UIConstants; import com.fr.design.beans.BasicBeanPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree; import com.fr.design.mainframe.AuthorityPropertyPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.*; import java.awt.*; import java.util.Enumeration; /** * Author : daisy * Date: 13-8-30 * Time: 下午3:32 */ public class RoleTree extends UserObjectRefreshJTree { private static final long serialVersionUID = 2L; private String roleName = null; public RoleTree() { super(); this.setCellRenderer(roleTreeRenderer); this.setEnabled(true); this.setEditable(true); this.setRowHeight(20); this.setDigIn(true); this.removeMouseListener(treeMouseListener); this.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { doWithValueChanged(e); } }); } public boolean isCheckBoxVisible(TreePath path) { return true; } /** * 更新UI */ public void updateUI() { super.updateUI(); setUI(new UIRoleTreeUI()); } protected void doWithValueChanged(TreeSelectionEvent e) { if (e.getNewLeadSelectionPath() != null) { if (e.getNewLeadSelectionPath().getLastPathComponent().toString() != Inter.getLocText("Role")) { roleName = e.getNewLeadSelectionPath().getLastPathComponent().toString(); setTabRoleName(roleName); refreshRoleTree(roleName); refreshElementAndAuthorityPane(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().judgeSheetAuthority(roleName); } } } protected void setTabRoleName(String roleName) { } /** * 刷新角色树 * * @param selectedRole 角色 */ public void refreshRoleTree(String selectedRole) { if (EastRegionContainerPane.getInstance().getUpPane() instanceof AuthorityPropertyPane) { AuthorityPropertyPane authorityPropertyPane = (AuthorityPropertyPane) EastRegionContainerPane.getInstance().getUpPane(); authorityPropertyPane.populate(); EastRegionContainerPane.getInstance().replaceUpPane(authorityPropertyPane); } } public void setSelectedRole(String selectedRole, TreePath parent) { ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); if (node.children() != null && node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { ExpandMutableTreeNode n = (ExpandMutableTreeNode) e.nextElement(); Object userObj = n.getUserObject(); String chilld = null; if (userObj instanceof String) { chilld = (String) userObj; } else if (userObj instanceof NameObject) { NameObject nameObject = (NameObject) userObj; chilld = nameObject.getName(); } if (ComparatorUtils.equals(chilld, selectedRole)) { this.setSelectionPath(parent.pathByAddingChild(n)); return; } else { setSelectedRole(selectedRole, parent.pathByAddingChild(n)); } } } } private void refreshElementAndAuthorityPane() { JComponent authorityToolBar = DesignerContext.getDesignerFrame().getToolbarComponent(); if (authorityToolBar instanceof BasicBeanPane) { //说明是工具栏的 ((BasicBeanPane) authorityToolBar).populateAuthority(); } HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().repaint(); } public String getSelectedRoleName() { return roleName; } public void setSelectedRoleName(String name) { roleName = name; } private DefaultTreeCellRenderer roleTreeRenderer = new DefaultTreeCellRenderer() { private static final long serialVersionUID = 2L; public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) value; Object userObj = treeNode.getUserObject(); if (userObj instanceof String) { // p:这个是column field. this.setIcon(null); this.setText((String) userObj); } else if (userObj instanceof NameObject) { NameObject nameObject = (NameObject) userObj; this.setText(nameObject.getName()); this.setIcon(null); } // 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..." this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND); this.setForeground(UIConstants.FONT_COLOR); this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); return this; } }; /* * p:获得选中的NameObject = name + role. */ public NameObject getSelectedNameObject() { TreePath selectedTreePath = this.getSelectionPath(); if (selectedTreePath == null) { return null; } ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent(); Object selectedUserObject = selectedTreeNode.getUserObject(); return new NameObject(selectedUserObject.toString(), ""); } /** * p:添加一个NameObject节点 * @param no 需要添加的节点 */ public void addNameObject(NameObject no) { if (no == null) { return; } DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel(); // 新建一个放着NameObject的newChildTreeNode,加到Root下面 ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); ExpandMutableTreeNode newChildTreeNode = new ExpandMutableTreeNode(no); root.add(newChildTreeNode); newChildTreeNode.add(new ExpandMutableTreeNode()); treeModel.reload(root); } /** * 刷新树节点 */ public void refreshTreeNode() { DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel(); ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); if (interceptRefresh(root)) { return; } ExpandMutableTreeNode[] new_nodes = loadChildTreeNodes(root); java.util.List childTreeNodeList = new java.util.ArrayList(); for (int i = 0, len = root.getChildCount(); i < len; i++) { if (root.getChildAt(i) instanceof ExpandMutableTreeNode) { childTreeNodeList.add((ExpandMutableTreeNode) root.getChildAt(i)); } else { childTreeNodeList.add((DefaultMutableTreeNode) root.getChildAt(i)); } } root.removeAllChildren(); for (int ci = 0; ci < new_nodes.length; ci++) { Object cUserObject = new_nodes[ci].getUserObject(); for (int ni = 0, nlen = childTreeNodeList.size(); ni < nlen; ni++) { ExpandMutableTreeNode cTreeNode = (ExpandMutableTreeNode) childTreeNodeList.get(ni); if (ComparatorUtils.equals(cTreeNode.getUserObject(), cUserObject)) { new_nodes[ci].setExpanded(cTreeNode.isExpanded()); if (cTreeNode.getFirstChild() instanceof ExpandMutableTreeNode && cTreeNode.isExpanded()) { checkChildNodes(cTreeNode, new_nodes[ci]); } break; } } root.add(new_nodes[ci]); } } protected void checkChildNodes(ExpandMutableTreeNode oldNode, ExpandMutableTreeNode newNode) { for (int i = 0; i < oldNode.getChildCount(); i++) { ExpandMutableTreeNode oldChild = (ExpandMutableTreeNode) oldNode.getChildAt(i); for (int j = 0; j < newNode.getChildCount(); j++) { ExpandMutableTreeNode newChild = (ExpandMutableTreeNode) newNode.getChildAt(j); ExpandMutableTreeNode[] nodes = RoleTree.this.loadChildTreeNodes(newChild); for (int k = 0; k < nodes.length; k++) { newChild.add(nodes[k]); } if (newChild.getChildCount() > 1 && ((ExpandMutableTreeNode) newChild.getFirstChild()).getUserObject() == PENDING) { newChild.remove(0); } if (ComparatorUtils.equals(oldChild.getUserObject(), newChild.getUserObject())) { newChild.setExpanded(oldChild.isExpanded()); } } } } public NameObject getRealSelectedNameObject() { TreePath selectedTreePath = this.getSelectionPath(); if (selectedTreePath == null) { return null; } ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent(); Object selectedUserObject = selectedTreeNode.getUserObject(); if (selectedUserObject instanceof NameObject) { return (NameObject) selectedUserObject; } selectedTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent(); selectedUserObject = selectedTreeNode.getUserObject(); if (selectedUserObject instanceof NameObject) { return (NameObject) selectedUserObject; } return null; } } \ No newline at end of file From 231796a2f33cf1d24c688abfe03e3c2a4491f3f0 Mon Sep 17 00:00:00 2001 From: xiaxiang <1438003374@qq.com> Date: Thu, 21 Apr 2016 00:11:03 +0800 Subject: [PATCH 19/19] rt --- .../src/com/fr/design/mainframe/AuthorityEditToolBarPane.java | 2 +- .../fr/design/mainframe/ElementCasePaneAuthorityEditPane.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java index 018ac9bc8f..d464d8f487 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java @@ -1 +1 @@ -package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.webattr.ToolBarButton; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; /** * 用于在权限编辑状态对工具栏的元素进行权限编辑的面板 * Author : daisy * Date: 13-9-18 * Time: 下午2:15 */ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { private static final int TITLE_HEIGHT = 19; private AuthorityEditPane authorityEditPane = null; private AuthorityToolBarPane authorityToolBarPane; private String[] selectedPathArray; public AuthorityEditToolBarPane(List buttonlists) { super(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); this.setLayout(new BorderLayout()); this.setBorder(null); UILabel authorityTitle = new UILabel(Inter.getLocText(new String[]{"DashBoard-Potence", "Edit"})) { @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, TITLE_HEIGHT); } }; authorityTitle.setHorizontalAlignment(SwingConstants.CENTER); authorityTitle.setVerticalAlignment(SwingConstants.CENTER); JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); northPane.add(authorityTitle, BorderLayout.CENTER); northPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); this.add(northPane, BorderLayout.NORTH); authorityEditPane = new AuthorityEditPane(buttonlists); this.add(authorityEditPane, BorderLayout.CENTER); } public void setAuthorityToolBarPane(AuthorityToolBarPane authorityToolBarPane) { this.authorityToolBarPane = authorityToolBarPane; } public void populate() { authorityToolBarPane.populateAuthority(); signelSelection(); authorityEditPane.populateDetials(); } private void signelSelection() { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate.isJWorkBook()) { //清参数面板 jTemplate.removeParameterPaneSelection(); //清报表主体 jTemplate.removeTemplateSelection(); } } private class AuthorityEditPane extends JPanel { private static final int TOP_GAP = 11; private static final int LEFT_GAP = 8; private static final int ALIGNMENT_GAP = -3; private UILabel type = null; private UILabel name = null; private JPanel checkPane = null; private List buttonlists; private UICheckBox buttonVisible = new UICheckBox(Inter.getLocText("Widget-Visible")); private ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { String selectedRole = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); initSelectedselectedPathArray(); if (ComparatorUtils.equals(selectedRole, Inter.getLocText("Role"))) { return; } if (selectedRole == null) { return; } if (selectedPathArray == null) { return; } for (int t = 0; t _buttonlists = AuthorityEditPane.this.buttonlists; for (int j = 0; j < _buttonlists.size(); j++) { if (_buttonlists.get(j).isSelected()) { //由引擎实现保存进模板报表 authorityToolBarPane.setAuthorityWebAttr(_buttonlists.get(j).getWidget(), checkbox.isSelected(), selectedPathArray[t]); } } } } }; private void initSelectedselectedPathArray () { TreePath[] selectionPaths = ReportAndFSManagePane.getInstance().getRoleTree().getCheckBoxTreeSelectionModel().getSelectionPaths(); if (selectionPaths.length == 1){ if(((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getChildCount() > 0){ ExpandMutableTreeNode node = (ExpandMutableTreeNode) ((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getLastChild(); selectedPathArray = new String[node.getChildCount()]; for (int y =0 ; y 0 && temp.charAt(0) == '[' && temp.endsWith("]"); if (isTrue) { temp = temp.substring(1, temp.length() - 1); String[] selectedRoles = temp.split(","); String role = selectedRoles[2].trim(); if(roles.isEmpty()){ roles = role; }else{ roles = roles + "," + role; } } } String[] selectedRole = roles.split(","); return selectedRole; } public AuthorityEditPane(List buttonlists) { setLayout(new BorderLayout()); type = new UILabel(); name = new UILabel(); checkPane = new JPanel(); checkPane.setLayout(new BorderLayout()); this.add(layoutText(), BorderLayout.WEST); this.add(layoutPane(), BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder(TOP_GAP, LEFT_GAP, 0, 0)); this.buttonlists = buttonlists; buttonVisible.addItemListener(itemListener); } private JPanel layoutText() { double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("Type") + ":", SwingConstants.RIGHT)}, new Component[]{new UILabel(Inter.getLocText("WF-Name") + ":", SwingConstants.RIGHT)}, new Component[]{new UILabel(Inter.getLocText("DashBoard-Potence") + ":", SwingConstants.RIGHT)}, }; double[] rowSize = {p, p, p}; double[] columnSize = {p}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel layoutPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{type}, new Component[]{name}, new Component[]{checkPane}, }; double[] rowSize = {p, p, p}; double[] columnSize = {f}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } /** * 更新权限编辑面板的具体内容:类型、名称、权限面板 */ public void populateDetials() { populateName(); populateType(); populateCheckPane(); checkVisibleCheckBoxes(); } private void checkVisibleCheckBoxes() { buttonVisible.removeItemListener(itemListener); String selected = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (selected == null) { buttonVisible.setSelected(true); } for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { buttonVisible.setSelected(!buttonlists.get(i).isDoneAuthorityEdited(selected)); break; } } buttonVisible.addItemListener(itemListener); } public void populateType() { if (name.getText() == "") { type.setText(""); } else { type.setText(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "Form-Button"})); } } public void populateName() { String names = ""; for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { names += "," + buttonlists.get(i).getNameOption().optionName(); } } if (names != "") { names = names.substring(1); } name.setText(names); } public void populateCheckPane() { checkPane.removeAll(); if (name.getText() == "") { return; } double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("Form-Button"), SwingConstants.LEFT), buttonVisible}, }; double[] rowSize = {p, p}; double[] columnSize = {p, p, f}; int[][] rowCount = {{1, 1, 1}, {1, 1, 1}}; JPanel check = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); checkPane.add(check, BorderLayout.CENTER); checkPane.setBorder(BorderFactory.createEmptyBorder(ALIGNMENT_GAP, 0, 0, 0)); } } } \ No newline at end of file +package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.webattr.ToolBarButton; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; /** * 用于在权限编辑状态对工具栏的元素进行权限编辑的面板 * Author : daisy * Date: 13-9-18 * Time: 下午2:15 */ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { private static final int TITLE_HEIGHT = 19; private AuthorityEditPane authorityEditPane = null; private AuthorityToolBarPane authorityToolBarPane; private String[] selectedPathArray; public AuthorityEditToolBarPane(List buttonlists) { super(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); this.setLayout(new BorderLayout()); this.setBorder(null); UILabel authorityTitle = new UILabel(Inter.getLocText(new String[]{"DashBoard-Potence", "Edit"})) { @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, TITLE_HEIGHT); } }; authorityTitle.setHorizontalAlignment(SwingConstants.CENTER); authorityTitle.setVerticalAlignment(SwingConstants.CENTER); JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); northPane.add(authorityTitle, BorderLayout.CENTER); northPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); this.add(northPane, BorderLayout.NORTH); authorityEditPane = new AuthorityEditPane(buttonlists); this.add(authorityEditPane, BorderLayout.CENTER); } public void setAuthorityToolBarPane(AuthorityToolBarPane authorityToolBarPane) { this.authorityToolBarPane = authorityToolBarPane; } public void populate() { authorityToolBarPane.populateAuthority(); signelSelection(); authorityEditPane.populateDetials(); } private void signelSelection() { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate.isJWorkBook()) { //清参数面板 jTemplate.removeParameterPaneSelection(); //清报表主体 jTemplate.removeTemplateSelection(); } } private class AuthorityEditPane extends JPanel { private static final int TOP_GAP = 11; private static final int LEFT_GAP = 8; private static final int ALIGNMENT_GAP = -3; private UILabel type = null; private UILabel name = null; private JPanel checkPane = null; private List buttonlists; private UICheckBox buttonVisible = new UICheckBox(Inter.getLocText("Widget-Visible")); private ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { String selectedRole = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); initSelectedselectedPathArray(); if (ComparatorUtils.equals(selectedRole, Inter.getLocText("Role"))) { return; } if (selectedRole == null) { return; } if (selectedPathArray == null) { return; } for (int t = 0; t _buttonlists = AuthorityEditPane.this.buttonlists; for (int j = 0; j < _buttonlists.size(); j++) { if (_buttonlists.get(j).isSelected()) { //由引擎实现保存进模板报表 authorityToolBarPane.setAuthorityWebAttr(_buttonlists.get(j).getWidget(), checkbox.isSelected(), selectedPathArray[t]); } } } } }; private void initSelectedselectedPathArray () { TreePath[] selectionPaths = ReportAndFSManagePane.getInstance().getRoleTree().getCheckBoxTreeSelectionModel().getSelectionPaths(); if (selectionPaths.length == 1){ if(((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getChildCount() > 0){ ExpandMutableTreeNode node = (ExpandMutableTreeNode) ((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getLastChild(); selectedPathArray = new String[node.getChildCount()]; for (int i = 0 ; i < node.getChildCount(); i++) { ExpandMutableTreeNode n = (ExpandMutableTreeNode) node.getChildAt(i); String nodeName = n.getUserObject().toString(); selectedPathArray[i] = nodeName; } } else { selectedPathArray = pathToString(selectionPaths); } } else { selectedPathArray = pathToString(selectionPaths); } } protected String[] pathToString(TreePath[] path) { String roles = StringUtils.EMPTY; if(path == null || path.length == 0){ return null; } for(TreePath tempPath:path){ String temp = tempPath.toString(); boolean isTrue = temp.length() > 0 && temp.charAt(0) == '[' && temp.endsWith("]"); if (isTrue) { temp = temp.substring(1, temp.length() - 1); String[] selectedRoles = temp.split(","); String role = selectedRoles[2].trim(); if(roles.isEmpty()){ roles = role; }else{ roles = roles + "," + role; } } } String[] selectedRole = roles.split(","); return selectedRole; } public AuthorityEditPane(List buttonlists) { setLayout(new BorderLayout()); type = new UILabel(); name = new UILabel(); checkPane = new JPanel(); checkPane.setLayout(new BorderLayout()); this.add(layoutText(), BorderLayout.WEST); this.add(layoutPane(), BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder(TOP_GAP, LEFT_GAP, 0, 0)); this.buttonlists = buttonlists; buttonVisible.addItemListener(itemListener); } private JPanel layoutText() { double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("Type") + ":", SwingConstants.RIGHT)}, new Component[]{new UILabel(Inter.getLocText("WF-Name") + ":", SwingConstants.RIGHT)}, new Component[]{new UILabel(Inter.getLocText("DashBoard-Potence") + ":", SwingConstants.RIGHT)}, }; double[] rowSize = {p, p, p}; double[] columnSize = {p}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel layoutPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{type}, new Component[]{name}, new Component[]{checkPane}, }; double[] rowSize = {p, p, p}; double[] columnSize = {f}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } /** * 更新权限编辑面板的具体内容:类型、名称、权限面板 */ public void populateDetials() { populateName(); populateType(); populateCheckPane(); checkVisibleCheckBoxes(); } private void checkVisibleCheckBoxes() { buttonVisible.removeItemListener(itemListener); String selected = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (selected == null) { buttonVisible.setSelected(true); } for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { buttonVisible.setSelected(!buttonlists.get(i).isDoneAuthorityEdited(selected)); break; } } buttonVisible.addItemListener(itemListener); } public void populateType() { if (name.getText() == "") { type.setText(""); } else { type.setText(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "Form-Button"})); } } public void populateName() { String names = ""; for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { names += "," + buttonlists.get(i).getNameOption().optionName(); } } if (names != "") { names = names.substring(1); } name.setText(names); } public void populateCheckPane() { checkPane.removeAll(); if (name.getText() == "") { return; } double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("Form-Button"), SwingConstants.LEFT), buttonVisible}, }; double[] rowSize = {p, p}; double[] columnSize = {p, p, f}; int[][] rowCount = {{1, 1, 1}, {1, 1, 1}}; JPanel check = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); checkPane.add(check, BorderLayout.CENTER); checkPane.setBorder(BorderFactory.createEmptyBorder(ALIGNMENT_GAP, 0, 0, 0)); } } } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java b/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java index 6e59d01224..3f9a717dd4 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java @@ -1 +1 @@ -package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.js.NameJavaScriptGroup; import com.fr.report.cell.AbstractCellElement; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ColumnRow; import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; /** * Author : daisy * Date: 13-9-4 * Time: 下午4:01 */ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { private static final int WIDGET_VISIBLE = 0; private static final int WIDGET_USABLE = 1; private static final int CELL = 2; private static final int HYPER_LINK = 3; private static final int FLOAT_SELECTION = 3; private static final int NEW_VALUE = 4; //新值下面的编辑器的宽度 private static final int NEW_PANE_WIDTH = 120; private UICheckBox floatElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox cellElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox widgetVisible = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox widgetAvailable = new UICheckBox(Inter.getLocText("FR-Designer_Enabled")); private UICheckBox gridColumnRowVisible = new UICheckBox(Inter.getLocText("FR-Designer_Hide")); private UICheckBox newValue = new UICheckBox(Inter.getLocText("FR-Designer_New_Value")); private ValueEditorPane valueEditor = ValueEditorPaneFactory.createBasicValueEditorPane(NEW_PANE_WIDTH); private UICheckBox[] hyperlinkCheckBoxes = null; private ElementCasePane elementCasePane = null; private int selectionType = CellSelection.NORMAL; private CellSelection cellSelection; private FloatSelection floatSelection; private boolean isAllHasWidget; private boolean isAllHasHyperlink; private String[] selectedPathArray; private UIObserverListener observerListener = new UIObserverListener() { @Override public void doChange() { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(NEW_VALUE)) { elementCasePane.fireTargetModified(); } } }; private ItemListener newValuelistener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(NEW_VALUE)) { valueEditor.setEnabled(newValue.isSelected()); doAfterAuthority(); } } }; private ItemListener columnRowAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null) { return; } boolean isDone = false; if (selectionType == CellSelection.CHOOSE_COLUMN) { isDone = setAuthorityColumn(); } else { isDone = setAuthorityRow(); } if (isDone) { doAfterAuthority(); } } }; private ItemListener floatElementAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || floatSelection == null) { return; } if (setLFloatAuthorityStyle()) { doAfterAuthority(); } } }; private ItemListener cellRolesAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(CELL)) { doAfterAuthority(); } } }; private ItemListener widgetVisibleRoleAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(WIDGET_VISIBLE)) { doAfterAuthority(); } } }; private ItemListener widgetUsableAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(WIDGET_USABLE)) { doAfterAuthority(); } } }; public ElementCasePaneAuthorityEditPane(ElementCasePane elementCasePane) { super(elementCasePane); this.elementCasePane = elementCasePane; initCheckBoxesState(); initListener(); } private void doAfterAuthority() { elementCasePane.repaint(); elementCasePane.fireTargetModified(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().setReportAndFSSelectedRoles(); RolesAlreadyEditedPane.getInstance().repaint(); checkCheckBoxes(); } private boolean setAuthorityColumn() { initSelectedselectedPathArray(); String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRoles, Inter.getLocText("FR-Designer_Role"))) { return false; } if (selectedRoles == null) { return false; } if (selectedPathArray == null) { return false; } final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isVisible = !gridColumnRowVisible.isSelected(); for (int t = 0; t= 0; j--) { for (int i = cellRectangle.width - 1; i >= 0; i--) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement == null) { editCellElement = new DefaultTemplateCellElement(column, row); elementCase.addCellElement(editCellElement); } else { // 对于合并的格子,我们不多次计算的权限. if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { continue; } } if (type == CELL) { editCellElement.changeAuthorityState(selectedPathArray[t], cellElementVisibleCheckBoxes.isSelected()); } else if (type == NEW_VALUE) { editCellElement.changeNewValueAuthorityState(selectedPathArray[t], newValue.isSelected(), valueEditor.update()); } else if (type == WIDGET_VISIBLE) { Widget widget = editCellElement.getWidget(); widget.changeVisibleAuthorityState(selectedPathArray[t], widgetVisible.isSelected()); } else { Widget widget = editCellElement.getWidget(); widget.changeUsableAuthorityState(selectedPathArray[t], widgetAvailable.isSelected()); } } } } } return true; } private void initSelectedselectedPathArray () { TreePath[] selectionPaths = ReportAndFSManagePane.getInstance().getRoleTree().getCheckBoxTreeSelectionModel().getSelectionPaths(); if (selectionPaths.length==1){ if(((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getChildCount() > 0){ ExpandMutableTreeNode node = (ExpandMutableTreeNode) ((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getLastChild(); System.out.printf(node.getUserObject().toString()); selectedPathArray = new String[node.getChildCount()]; for (int y =0; y 0 && temp.charAt(0) == '[' && temp.endsWith("]"); if (isTrue) { temp = temp.substring(1, temp.length() - 1); String[] selectedRoles = temp.split(","); String role = selectedRoles[2].trim(); if(roles.isEmpty()){ roles = role; }else{ roles = roles + "," + role; } } } String[] selectedRole = roles.split(","); return selectedRole; } /** * 选中的单元格的乐见状态以第一个单元格为齐 */ public void initCheckBoxesState() { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); if (cellSelection == null) { cellElementVisibleCheckBoxes.setSelected(true); } else { Rectangle cellRectangle = cellSelection.getCellRectangle(0); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellRectangle.x, cellRectangle.y); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellRectangle.x, cellRectangle.y); } boolean firstCellDoneaAuthority = cellElement.isDoneAuthority( ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName()); cellElementVisibleCheckBoxes.setSelected(!firstCellDoneaAuthority); } widgetAvailable.setEnabled(cellElementVisibleCheckBoxes.isSelected()); widgetVisible.setEnabled(cellElementVisibleCheckBoxes.isSelected()); } private void initListener() { cellElementVisibleCheckBoxes.addItemListener(cellRolesAuthorityListener); widgetVisible.addItemListener(widgetVisibleRoleAuthorityListener); widgetAvailable.addItemListener(widgetUsableAuthorityListener); floatElementVisibleCheckBoxes.addItemListener(floatElementAuthorityListener); gridColumnRowVisible.addItemListener(columnRowAuthorityListener); newValue.addItemListener(newValuelistener); valueEditor.registerChangeListener(observerListener); } private void removeListener() { cellElementVisibleCheckBoxes.removeItemListener(cellRolesAuthorityListener); widgetVisible.removeItemListener(widgetVisibleRoleAuthorityListener); widgetAvailable.removeItemListener(widgetUsableAuthorityListener); floatElementVisibleCheckBoxes.removeItemListener(floatElementAuthorityListener); gridColumnRowVisible.removeItemListener(columnRowAuthorityListener); newValue.removeItemListener(newValuelistener); valueEditor.registerChangeListener(null); } private void addHyperlinkListener() { cellElementVisibleCheckBoxes.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (hyperlinkCheckBoxes != null) { for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].setEnabled(cellElementVisibleCheckBoxes.isSelected()); if (!cellElementVisibleCheckBoxes.isSelected()) { hyperlinkCheckBoxes[i].setSelected(false); } } } } }); for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].addItemListener(cellRolesAuthorityListener); } } /** * 更新适合的类型 */ public void populateType() { if (selectionType == CellSelection.NORMAL) { type.setText(Inter.getLocText("FR-Designer_Cell")); } else if (selectionType == CellSelection.CHOOSE_ROW) { type.setText(Inter.getLocText("FR-Designer_Row")); } else if (selectionType == CellSelection.CHOOSE_COLUMN) { type.setText(Inter.getLocText("FR-Designer_Column")); } else { type.setText(Inter.getLocText("M_Insert-Float")); } } /** * 名字 */ public void populateName() { if (selectionType == CellSelection.NORMAL) { name.setText(getCellSelectionName()); } else if (selectionType == CellSelection.CHOOSE_ROW || selectionType == CellSelection.CHOOSE_COLUMN) { name.setText(getCellColumnRowName()); } else { name.setText(getFloatSelectionName()); } } private String getCellSelectionName() { String nameText = ""; int count = cellSelection.getCellRectangleCount(); for (int rect = 0; rect < count; rect++) { nameText += ","; Rectangle cellRectangle = cellSelection.getCellRectangle(rect); ColumnRow beginCR = ColumnRow.valueOf(cellRectangle.x, cellRectangle.y); nameText += beginCR.toString(); if (cellRectangle.width * cellRectangle.height != 1) { ColumnRow endCR = ColumnRow.valueOf(cellRectangle.width + cellRectangle.x - 1, cellRectangle.height + cellRectangle.y - 1); nameText += ":" + endCR.toString(); } } return nameText.substring(1); } private String getCellColumnRowName() { int count = cellSelection.getCellRectangleCount(); String nameText = ""; ColumnRow cr = ColumnRow.valueOf(cellSelection.getColumn(), cellSelection.getRow()); if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN && count == 1) { if (cellSelection.getColumnSpan() == 1) { nameText = cr.toString().substring(0, 1); } else { ColumnRow endCr = ColumnRow.valueOf(cellSelection.getColumn() + cellSelection.getColumnSpan() - 1, cellSelection.getRow() + cellSelection.getRowSpan() - 1); nameText = cr.toString().substring(0, 1) + "-" + endCr.toString().substring(0, 1); } } else if (cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW && count == 1) { if (cellSelection.getRowSpan() == 1) { nameText = cr.toString().substring(1); } else { ColumnRow endCr = ColumnRow.valueOf(cellSelection.getColumn() + cellSelection.getColumnSpan() - 1, cellSelection.getRow() + cellSelection.getRowSpan() - 1); nameText = cr.toString().substring(1) + "-" + endCr.toString().substring(1); } } return nameText; } private String getFloatSelectionName() { return floatSelection.getSelectedFloatName(); } private void mutilRect(CellSelection cellSelection) { isAllHasWidget = true; isAllHasHyperlink = true; int count = cellSelection.getCellRectangleCount(); final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); for (int rect = 0; rect < count; rect++) { Rectangle cellRectangle = cellSelection.getCellRectangle(rect); for (int j = 0; j < cellRectangle.height; j++) { for (int i = 0; i < cellRectangle.width; i++) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(column, row); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); } if (cellElement.getCellWidgetAttr() == null) { isAllHasWidget = false; } if (cellElement.getNameHyperlinkGroup() == null) { isAllHasHyperlink = false; } } } } } /** * 更新适合的pane * * @return 返回Pane */ public JPanel populateCheckPane() { checkPane.removeAll(); if (selectionType == CellSelection.NORMAL) { populateCellSelectionCheckPane(checkPane); } else if (selectionType == CellSelection.CHOOSE_COLUMN || selectionType == CellSelection.CHOOSE_ROW) { populateColumnRowCheckPane(checkPane); } else if (selectionType == FLOAT_SELECTION) { populateFloatSelectionCheckPane(checkPane); } checkPane.setBorder(BorderFactory.createEmptyBorder(ALIGNMENT_GAP, 0, 0, 0)); return checkPane; } private void populateColumnRowCheckPane(JPanel checkPane) { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{gridColumnRowVisible} }; double[] rowSize = {p}; double[] columnSize = {f}; int[][] rowCount = {{1}}; checkPane.add( TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM) , BorderLayout.WEST); } private void populateFloatSelectionCheckPane(JPanel checkPane) { checkPane.add(populateFloatElementCheckPane(), BorderLayout.WEST); } private void populateCellSelectionCheckPane(JPanel checkPane) { if (elementCasePane.isSelectedOneCell()) { //只选中了一个单元格 final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellSelection.getColumn(), cellSelection.getRow()); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); } //单元格带控件 if (cellElement.getCellWidgetAttr() != null) { checkPane.add(populateWidgetCheckPane(), BorderLayout.WEST); } else { checkPane.add(populatCellCheckPane(), BorderLayout.WEST); } } else { //批量选中单元格 mutilRect(cellSelection); if (!isAllHasWidget && !isAllHasHyperlink) { checkPane.add(populateMutilCellCheckPane(), BorderLayout.WEST); } else if (isAllHasWidget) { checkPane.add(populateMutilWidgetCheckPane(), BorderLayout.WEST); } } } /** * 对单元格区域进行操作时的权限编辑页面 ,对应的角色的populate */ public void populateDetials() { //做模式标记,此时鼠标焦点是在报表主体,为下一次退出权限编辑时做准备 HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setAuthorityMode(false); TemplateElementCase templateElementCase = elementCasePane.getEditingElementCase(); if (templateElementCase instanceof WorkSheet) { ((WorkSheet) templateElementCase).setPaintSelection(true); } signelSelection(); Selection selection = elementCasePane.getSelection(); if (selection instanceof CellSelection) { selectionType = CellSelection.NORMAL; this.cellSelection = ((CellSelection) selection).clone(); this.floatSelection = null; judgeChooseCR(); } else if (selection instanceof FloatSelection) { selectionType = FLOAT_SELECTION; cellSelection = null; floatSelection = new FloatSelection(((FloatSelection) selection).getSelectedFloatName()); } populateType(); populateName(); populateCheckPane(); checkCheckBoxes(); } //判断是否选择的行列 private void judgeChooseCR() { if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN && cellSelection.getCellRectangleCount() == 1) { selectionType = CellSelection.CHOOSE_COLUMN; } if (cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW && cellSelection.getCellRectangleCount() == 1) { selectionType = CellSelection.CHOOSE_ROW; } } //实现单选 private void signelSelection() { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate.isJWorkBook()) { //清工具栏 JComponent component = DesignerContext.getDesignerFrame().getToolbarComponent(); if (component instanceof AuthorityEditToolBarComponent) { ((AuthorityEditToolBarComponent) component).removeSelection(); } //清参数面板 jTemplate.removeParameterPaneSelection(); } } private JPanel populateFloatElementCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("M_Insert-Float"), SwingConstants.LEFT), floatElementVisibleCheckBoxes} }; double[] rowSize = {p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, new Component[]{null, newValue}, new Component[]{null, valueEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, new Component[]{null, widgetAvailable} }; double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, new Component[]{null, widgetAvailable} }; double[] rowSize = {p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes}, }; double[] rowSize = {p}; double[] columnSize = {f}; int[][] rowCount = {{1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populatCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes}, new Component[]{newValue}, new Component[]{valueEditor} }; double[] rowSize = {p, p, p}; double[] columnSize = {f}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } public TemplateCellElement getFirstCell() { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); Rectangle cellRectangle = cellSelection.getCellRectangle(0); // 从最后循环起以保证最后一个修改标准单元格(originalStyle)。 TemplateCellElement firstCell = null; for (int j = cellRectangle.height - 1; j >= 0; j--) { for (int i = cellRectangle.width - 1; i >= 0; i--) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement != null) { // 对于合并的格子,我们不多次计算的权限. if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { continue; } firstCell = editCellElement; } } } return firstCell; } private void checkCheckBoxes() { String selected = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); removeListener(); if (selectionType == CellSelection.NORMAL) { checkCellSelectionCkeckboxes(selected); } else if (selectionType == CellSelection.CHOOSE_COLUMN || selectionType == CellSelection.CHOOSE_ROW) { checkColumnRowCheckBoxes(selected); } else if (selectionType == FLOAT_SELECTION) { checkFloatSelectionCkeckboxes(selected); } initListener(); } private void checkCellSelectionCkeckboxes(String selected) { TemplateCellElement firstCell = getFirstCell(); if (firstCell == null) { resetCellElementCheckBoxes(); return; } cellElementVisibleCheckBoxes.setSelected(!firstCell.isDoneAuthority(selected)); newValue.setEnabled(!firstCell.isDoneAuthority(selected)); if (!firstCell.isDoneAuthority(selected)) { newValue.setSelected(firstCell.isDoneNewValueAuthority(selected)); if (newValue.isSelected()) { valueEditor.setEnabled(true); valueEditor.populate(firstCell.getCellPrivilegeControl().getNewValueMap().get(selected)); } else { valueEditor.setEnabled(false); } } else { newValue.setSelected(false); valueEditor.setEnabled(false); } populateWidgetButton(firstCell.getWidget(), selected, firstCell); } private void populateWidgetButton(Widget widget, String selected, TemplateCellElement firstCell){ if(widget == null){ return; } if(widget.isVisible()){ widgetVisible.setSelected(!widget.isDoneVisibleAuthority(selected)); widgetVisible.setEnabled(!firstCell.isDoneAuthority(selected)); }else{ widgetVisible.setSelected(widget.isVisibleAuthority(selected)); } if(widget.isEnabled()){ widgetAvailable.setSelected(!widget.isDoneUsableAuthority(selected)); widgetAvailable.setEnabled(!widget.isDoneVisibleAuthority(selected)); }else{ widgetAvailable.setSelected(widget.isUsableAuthority(selected)); } } private void resetCellElementCheckBoxes() { cellElementVisibleCheckBoxes.setSelected(true); widgetVisible.setSelected(true); widgetVisible.setEnabled(true); widgetAvailable.setSelected(true); widgetAvailable.setEnabled(true); newValue.setSelected(false); valueEditor.setEnabled(false); } private void checkColumnRowCheckBoxes(String selected) { if (cellSelection == null) { gridColumnRowVisible.setSelected(false); return; } TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isInside = selectionType == CellSelection.CHOOSE_COLUMN ? elementCase.getColumnPrivilegeControl(cellSelection.getColumn()).checkInvisible(selected) : elementCase.getRowPrivilegeControl(cellSelection.getRow()).checkInvisible(selected); gridColumnRowVisible.setSelected(isInside); } private void checkFloatSelectionCkeckboxes(String selected) { String name = floatSelection.getSelectedFloatName(); TemplateElementCase ec = elementCasePane.getEditingElementCase(); FloatElement fe = ec.getFloatElement(name); floatElementVisibleCheckBoxes.setSelected(!fe.isDoneAuthority(selected)); } private JPanel populateHyperlinkCheckPane(AbstractCellElement cellElement) { NameJavaScriptGroup linkGroup = cellElement.getNameHyperlinkGroup(); //超链接的个数+单元格可见的操作 hyperlinkCheckBoxes = new UICheckBox[linkGroup.size()]; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[hyperlinkCheckBoxes.length + 1][]; if (linkGroup.size() == 1) { components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; } else { components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(linkGroup.getNameHyperlink(0).getName() + Inter.getLocText("FR-Designer_Visible"))}; for (int i = 1; i < hyperlinkCheckBoxes.length; i++) { components[i + 1] = new Component[]{null, hyperlinkCheckBoxes[i] = new UICheckBox(linkGroup.getNameHyperlink(i).getName() + Inter.getLocText("FR-Designer_Visible"))}; } } for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].setEnabled(cellElementVisibleCheckBoxes.isSelected()); } addHyperlinkListener(); double[] rowSize = new double[hyperlinkCheckBoxes.length + 1]; int[][] rowCount = new int[hyperlinkCheckBoxes.length + 1][]; for (int i = 0; i < hyperlinkCheckBoxes.length + 1; i++) { rowSize[i] = p; rowCount[i] = new int[]{1, 1}; } double[] columnSize = {p, f}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilHyperlinkCheckPane() { //超链接的个数+单元格可见的操作 hyperlinkCheckBoxes = new UICheckBox[1]; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[2][]; components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; hyperlinkCheckBoxes[0].setEnabled(cellElementVisibleCheckBoxes.isSelected()); addHyperlinkListener(); double[] rowSize = {p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } } \ No newline at end of file +package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.js.NameJavaScriptGroup; import com.fr.report.cell.AbstractCellElement; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ColumnRow; import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; /** * Author : daisy * Date: 13-9-4 * Time: 下午4:01 */ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { private static final int WIDGET_VISIBLE = 0; private static final int WIDGET_USABLE = 1; private static final int CELL = 2; private static final int HYPER_LINK = 3; private static final int FLOAT_SELECTION = 3; private static final int NEW_VALUE = 4; //新值下面的编辑器的宽度 private static final int NEW_PANE_WIDTH = 120; private UICheckBox floatElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox cellElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox widgetVisible = new UICheckBox(Inter.getLocText("FR-Designer_Visible")); private UICheckBox widgetAvailable = new UICheckBox(Inter.getLocText("FR-Designer_Enabled")); private UICheckBox gridColumnRowVisible = new UICheckBox(Inter.getLocText("FR-Designer_Hide")); private UICheckBox newValue = new UICheckBox(Inter.getLocText("FR-Designer_New_Value")); private ValueEditorPane valueEditor = ValueEditorPaneFactory.createBasicValueEditorPane(NEW_PANE_WIDTH); private UICheckBox[] hyperlinkCheckBoxes = null; private ElementCasePane elementCasePane = null; private int selectionType = CellSelection.NORMAL; private CellSelection cellSelection; private FloatSelection floatSelection; private boolean isAllHasWidget; private boolean isAllHasHyperlink; private String[] selectedPathArray; private UIObserverListener observerListener = new UIObserverListener() { @Override public void doChange() { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(NEW_VALUE)) { elementCasePane.fireTargetModified(); } } }; private ItemListener newValuelistener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(NEW_VALUE)) { valueEditor.setEnabled(newValue.isSelected()); doAfterAuthority(); } } }; private ItemListener columnRowAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null) { return; } boolean isDone = false; if (selectionType == CellSelection.CHOOSE_COLUMN) { isDone = setAuthorityColumn(); } else { isDone = setAuthorityRow(); } if (isDone) { doAfterAuthority(); } } }; private ItemListener floatElementAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || floatSelection == null) { return; } if (setLFloatAuthorityStyle()) { doAfterAuthority(); } } }; private ItemListener cellRolesAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(CELL)) { doAfterAuthority(); } } }; private ItemListener widgetVisibleRoleAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(WIDGET_VISIBLE)) { doAfterAuthority(); } } }; private ItemListener widgetUsableAuthorityListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (elementCasePane == null || cellSelection == null) { return; } if (setAuthorityStyle(WIDGET_USABLE)) { doAfterAuthority(); } } }; public ElementCasePaneAuthorityEditPane(ElementCasePane elementCasePane) { super(elementCasePane); this.elementCasePane = elementCasePane; initCheckBoxesState(); initListener(); } private void doAfterAuthority() { elementCasePane.repaint(); elementCasePane.fireTargetModified(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().setReportAndFSSelectedRoles(); RolesAlreadyEditedPane.getInstance().repaint(); checkCheckBoxes(); } private boolean setAuthorityColumn() { initSelectedselectedPathArray(); String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRoles, Inter.getLocText("FR-Designer_Role"))) { return false; } if (selectedRoles == null) { return false; } if (selectedPathArray == null) { return false; } final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isVisible = !gridColumnRowVisible.isSelected(); for (int t = 0; t= 0; j--) { for (int i = cellRectangle.width - 1; i >= 0; i--) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement == null) { editCellElement = new DefaultTemplateCellElement(column, row); elementCase.addCellElement(editCellElement); } else { // 对于合并的格子,我们不多次计算的权限. if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { continue; } } if (type == CELL) { editCellElement.changeAuthorityState(selectedPathArray[t], cellElementVisibleCheckBoxes.isSelected()); } else if (type == NEW_VALUE) { editCellElement.changeNewValueAuthorityState(selectedPathArray[t], newValue.isSelected(), valueEditor.update()); } else if (type == WIDGET_VISIBLE) { Widget widget = editCellElement.getWidget(); widget.changeVisibleAuthorityState(selectedPathArray[t], widgetVisible.isSelected()); } else { Widget widget = editCellElement.getWidget(); widget.changeUsableAuthorityState(selectedPathArray[t], widgetAvailable.isSelected()); } } } } } return true; } private void initSelectedselectedPathArray () { TreePath[] selectionPaths = ReportAndFSManagePane.getInstance().getRoleTree().getCheckBoxTreeSelectionModel().getSelectionPaths(); if (selectionPaths.length == 1){ if(((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getChildCount() > 0){ ExpandMutableTreeNode node = (ExpandMutableTreeNode) ((ExpandMutableTreeNode)(selectionPaths[0].getLastPathComponent())).getLastChild(); System.out.printf(node.getUserObject().toString()); selectedPathArray = new String[node.getChildCount()]; for (int i = 0; i < node.getChildCount(); i++) { ExpandMutableTreeNode n = (ExpandMutableTreeNode) node.getChildAt(i); String nodeName = n.getUserObject().toString(); selectedPathArray[i] = nodeName; } } else { selectedPathArray = pathToString(selectionPaths); } } else { selectedPathArray = pathToString(selectionPaths); } } protected String[] pathToString(TreePath[] path) { String roles = StringUtils.EMPTY; if(path == null || path.length == 0){ return null; } for(TreePath tempPath:path){ String temp = tempPath.toString(); boolean isTrue = temp.length() > 0 && temp.charAt(0) == '[' && temp.endsWith("]"); if (isTrue) { temp = temp.substring(1, temp.length() - 1); String[] selectedRoles = temp.split(","); String role = selectedRoles[2].trim(); if(roles.isEmpty()){ roles = role; }else{ roles = roles + "," + role; } } } String[] selectedRole = roles.split(","); return selectedRole; } /** * 选中的单元格的乐见状态以第一个单元格为齐 */ public void initCheckBoxesState() { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); if (cellSelection == null) { cellElementVisibleCheckBoxes.setSelected(true); } else { Rectangle cellRectangle = cellSelection.getCellRectangle(0); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellRectangle.x, cellRectangle.y); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellRectangle.x, cellRectangle.y); } boolean firstCellDoneaAuthority = cellElement.isDoneAuthority( ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName()); cellElementVisibleCheckBoxes.setSelected(!firstCellDoneaAuthority); } widgetAvailable.setEnabled(cellElementVisibleCheckBoxes.isSelected()); widgetVisible.setEnabled(cellElementVisibleCheckBoxes.isSelected()); } private void initListener() { cellElementVisibleCheckBoxes.addItemListener(cellRolesAuthorityListener); widgetVisible.addItemListener(widgetVisibleRoleAuthorityListener); widgetAvailable.addItemListener(widgetUsableAuthorityListener); floatElementVisibleCheckBoxes.addItemListener(floatElementAuthorityListener); gridColumnRowVisible.addItemListener(columnRowAuthorityListener); newValue.addItemListener(newValuelistener); valueEditor.registerChangeListener(observerListener); } private void removeListener() { cellElementVisibleCheckBoxes.removeItemListener(cellRolesAuthorityListener); widgetVisible.removeItemListener(widgetVisibleRoleAuthorityListener); widgetAvailable.removeItemListener(widgetUsableAuthorityListener); floatElementVisibleCheckBoxes.removeItemListener(floatElementAuthorityListener); gridColumnRowVisible.removeItemListener(columnRowAuthorityListener); newValue.removeItemListener(newValuelistener); valueEditor.registerChangeListener(null); } private void addHyperlinkListener() { cellElementVisibleCheckBoxes.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (hyperlinkCheckBoxes != null) { for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].setEnabled(cellElementVisibleCheckBoxes.isSelected()); if (!cellElementVisibleCheckBoxes.isSelected()) { hyperlinkCheckBoxes[i].setSelected(false); } } } } }); for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].addItemListener(cellRolesAuthorityListener); } } /** * 更新适合的类型 */ public void populateType() { if (selectionType == CellSelection.NORMAL) { type.setText(Inter.getLocText("FR-Designer_Cell")); } else if (selectionType == CellSelection.CHOOSE_ROW) { type.setText(Inter.getLocText("FR-Designer_Row")); } else if (selectionType == CellSelection.CHOOSE_COLUMN) { type.setText(Inter.getLocText("FR-Designer_Column")); } else { type.setText(Inter.getLocText("M_Insert-Float")); } } /** * 名字 */ public void populateName() { if (selectionType == CellSelection.NORMAL) { name.setText(getCellSelectionName()); } else if (selectionType == CellSelection.CHOOSE_ROW || selectionType == CellSelection.CHOOSE_COLUMN) { name.setText(getCellColumnRowName()); } else { name.setText(getFloatSelectionName()); } } private String getCellSelectionName() { String nameText = ""; int count = cellSelection.getCellRectangleCount(); for (int rect = 0; rect < count; rect++) { nameText += ","; Rectangle cellRectangle = cellSelection.getCellRectangle(rect); ColumnRow beginCR = ColumnRow.valueOf(cellRectangle.x, cellRectangle.y); nameText += beginCR.toString(); if (cellRectangle.width * cellRectangle.height != 1) { ColumnRow endCR = ColumnRow.valueOf(cellRectangle.width + cellRectangle.x - 1, cellRectangle.height + cellRectangle.y - 1); nameText += ":" + endCR.toString(); } } return nameText.substring(1); } private String getCellColumnRowName() { int count = cellSelection.getCellRectangleCount(); String nameText = ""; ColumnRow cr = ColumnRow.valueOf(cellSelection.getColumn(), cellSelection.getRow()); if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN && count == 1) { if (cellSelection.getColumnSpan() == 1) { nameText = cr.toString().substring(0, 1); } else { ColumnRow endCr = ColumnRow.valueOf(cellSelection.getColumn() + cellSelection.getColumnSpan() - 1, cellSelection.getRow() + cellSelection.getRowSpan() - 1); nameText = cr.toString().substring(0, 1) + "-" + endCr.toString().substring(0, 1); } } else if (cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW && count == 1) { if (cellSelection.getRowSpan() == 1) { nameText = cr.toString().substring(1); } else { ColumnRow endCr = ColumnRow.valueOf(cellSelection.getColumn() + cellSelection.getColumnSpan() - 1, cellSelection.getRow() + cellSelection.getRowSpan() - 1); nameText = cr.toString().substring(1) + "-" + endCr.toString().substring(1); } } return nameText; } private String getFloatSelectionName() { return floatSelection.getSelectedFloatName(); } private void mutilRect(CellSelection cellSelection) { isAllHasWidget = true; isAllHasHyperlink = true; int count = cellSelection.getCellRectangleCount(); final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); for (int rect = 0; rect < count; rect++) { Rectangle cellRectangle = cellSelection.getCellRectangle(rect); for (int j = 0; j < cellRectangle.height; j++) { for (int i = 0; i < cellRectangle.width; i++) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(column, row); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); } if (cellElement.getCellWidgetAttr() == null) { isAllHasWidget = false; } if (cellElement.getNameHyperlinkGroup() == null) { isAllHasHyperlink = false; } } } } } /** * 更新适合的pane * * @return 返回Pane */ public JPanel populateCheckPane() { checkPane.removeAll(); if (selectionType == CellSelection.NORMAL) { populateCellSelectionCheckPane(checkPane); } else if (selectionType == CellSelection.CHOOSE_COLUMN || selectionType == CellSelection.CHOOSE_ROW) { populateColumnRowCheckPane(checkPane); } else if (selectionType == FLOAT_SELECTION) { populateFloatSelectionCheckPane(checkPane); } checkPane.setBorder(BorderFactory.createEmptyBorder(ALIGNMENT_GAP, 0, 0, 0)); return checkPane; } private void populateColumnRowCheckPane(JPanel checkPane) { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{gridColumnRowVisible} }; double[] rowSize = {p}; double[] columnSize = {f}; int[][] rowCount = {{1}}; checkPane.add( TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM) , BorderLayout.WEST); } private void populateFloatSelectionCheckPane(JPanel checkPane) { checkPane.add(populateFloatElementCheckPane(), BorderLayout.WEST); } private void populateCellSelectionCheckPane(JPanel checkPane) { if (elementCasePane.isSelectedOneCell()) { //只选中了一个单元格 final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellSelection.getColumn(), cellSelection.getRow()); if (cellElement == null) { cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); } //单元格带控件 if (cellElement.getCellWidgetAttr() != null) { checkPane.add(populateWidgetCheckPane(), BorderLayout.WEST); } else { checkPane.add(populatCellCheckPane(), BorderLayout.WEST); } } else { //批量选中单元格 mutilRect(cellSelection); if (!isAllHasWidget && !isAllHasHyperlink) { checkPane.add(populateMutilCellCheckPane(), BorderLayout.WEST); } else if (isAllHasWidget) { checkPane.add(populateMutilWidgetCheckPane(), BorderLayout.WEST); } } } /** * 对单元格区域进行操作时的权限编辑页面 ,对应的角色的populate */ public void populateDetials() { //做模式标记,此时鼠标焦点是在报表主体,为下一次退出权限编辑时做准备 HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setAuthorityMode(false); TemplateElementCase templateElementCase = elementCasePane.getEditingElementCase(); if (templateElementCase instanceof WorkSheet) { ((WorkSheet) templateElementCase).setPaintSelection(true); } signelSelection(); Selection selection = elementCasePane.getSelection(); if (selection instanceof CellSelection) { selectionType = CellSelection.NORMAL; this.cellSelection = ((CellSelection) selection).clone(); this.floatSelection = null; judgeChooseCR(); } else if (selection instanceof FloatSelection) { selectionType = FLOAT_SELECTION; cellSelection = null; floatSelection = new FloatSelection(((FloatSelection) selection).getSelectedFloatName()); } populateType(); populateName(); populateCheckPane(); checkCheckBoxes(); } //判断是否选择的行列 private void judgeChooseCR() { if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN && cellSelection.getCellRectangleCount() == 1) { selectionType = CellSelection.CHOOSE_COLUMN; } if (cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW && cellSelection.getCellRectangleCount() == 1) { selectionType = CellSelection.CHOOSE_ROW; } } //实现单选 private void signelSelection() { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (jTemplate.isJWorkBook()) { //清工具栏 JComponent component = DesignerContext.getDesignerFrame().getToolbarComponent(); if (component instanceof AuthorityEditToolBarComponent) { ((AuthorityEditToolBarComponent) component).removeSelection(); } //清参数面板 jTemplate.removeParameterPaneSelection(); } } private JPanel populateFloatElementCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("M_Insert-Float"), SwingConstants.LEFT), floatElementVisibleCheckBoxes} }; double[] rowSize = {p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, new Component[]{null, newValue}, new Component[]{null, valueEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, new Component[]{null, widgetAvailable} }; double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, new Component[]{null, widgetAvailable} }; double[] rowSize = {p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes}, }; double[] rowSize = {p}; double[] columnSize = {f}; int[][] rowCount = {{1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populatCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes}, new Component[]{newValue}, new Component[]{valueEditor} }; double[] rowSize = {p, p, p}; double[] columnSize = {f}; int[][] rowCount = {{1}, {1}, {1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } public TemplateCellElement getFirstCell() { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); Rectangle cellRectangle = cellSelection.getCellRectangle(0); // 从最后循环起以保证最后一个修改标准单元格(originalStyle)。 TemplateCellElement firstCell = null; for (int j = cellRectangle.height - 1; j >= 0; j--) { for (int i = cellRectangle.width - 1; i >= 0; i--) { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement != null) { // 对于合并的格子,我们不多次计算的权限. if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { continue; } firstCell = editCellElement; } } } return firstCell; } private void checkCheckBoxes() { String selected = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); removeListener(); if (selectionType == CellSelection.NORMAL) { checkCellSelectionCkeckboxes(selected); } else if (selectionType == CellSelection.CHOOSE_COLUMN || selectionType == CellSelection.CHOOSE_ROW) { checkColumnRowCheckBoxes(selected); } else if (selectionType == FLOAT_SELECTION) { checkFloatSelectionCkeckboxes(selected); } initListener(); } private void checkCellSelectionCkeckboxes(String selected) { TemplateCellElement firstCell = getFirstCell(); if (firstCell == null) { resetCellElementCheckBoxes(); return; } cellElementVisibleCheckBoxes.setSelected(!firstCell.isDoneAuthority(selected)); newValue.setEnabled(!firstCell.isDoneAuthority(selected)); if (!firstCell.isDoneAuthority(selected)) { newValue.setSelected(firstCell.isDoneNewValueAuthority(selected)); if (newValue.isSelected()) { valueEditor.setEnabled(true); valueEditor.populate(firstCell.getCellPrivilegeControl().getNewValueMap().get(selected)); } else { valueEditor.setEnabled(false); } } else { newValue.setSelected(false); valueEditor.setEnabled(false); } populateWidgetButton(firstCell.getWidget(), selected, firstCell); } private void populateWidgetButton(Widget widget, String selected, TemplateCellElement firstCell){ if(widget == null){ return; } if(widget.isVisible()){ widgetVisible.setSelected(!widget.isDoneVisibleAuthority(selected)); widgetVisible.setEnabled(!firstCell.isDoneAuthority(selected)); }else{ widgetVisible.setSelected(widget.isVisibleAuthority(selected)); } if(widget.isEnabled()){ widgetAvailable.setSelected(!widget.isDoneUsableAuthority(selected)); widgetAvailable.setEnabled(!widget.isDoneVisibleAuthority(selected)); }else{ widgetAvailable.setSelected(widget.isUsableAuthority(selected)); } } private void resetCellElementCheckBoxes() { cellElementVisibleCheckBoxes.setSelected(true); widgetVisible.setSelected(true); widgetVisible.setEnabled(true); widgetAvailable.setSelected(true); widgetAvailable.setEnabled(true); newValue.setSelected(false); valueEditor.setEnabled(false); } private void checkColumnRowCheckBoxes(String selected) { if (cellSelection == null) { gridColumnRowVisible.setSelected(false); return; } TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); boolean isInside = selectionType == CellSelection.CHOOSE_COLUMN ? elementCase.getColumnPrivilegeControl(cellSelection.getColumn()).checkInvisible(selected) : elementCase.getRowPrivilegeControl(cellSelection.getRow()).checkInvisible(selected); gridColumnRowVisible.setSelected(isInside); } private void checkFloatSelectionCkeckboxes(String selected) { String name = floatSelection.getSelectedFloatName(); TemplateElementCase ec = elementCasePane.getEditingElementCase(); FloatElement fe = ec.getFloatElement(name); floatElementVisibleCheckBoxes.setSelected(!fe.isDoneAuthority(selected)); } private JPanel populateHyperlinkCheckPane(AbstractCellElement cellElement) { NameJavaScriptGroup linkGroup = cellElement.getNameHyperlinkGroup(); //超链接的个数+单元格可见的操作 hyperlinkCheckBoxes = new UICheckBox[linkGroup.size()]; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[hyperlinkCheckBoxes.length + 1][]; if (linkGroup.size() == 1) { components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; } else { components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(linkGroup.getNameHyperlink(0).getName() + Inter.getLocText("FR-Designer_Visible"))}; for (int i = 1; i < hyperlinkCheckBoxes.length; i++) { components[i + 1] = new Component[]{null, hyperlinkCheckBoxes[i] = new UICheckBox(linkGroup.getNameHyperlink(i).getName() + Inter.getLocText("FR-Designer_Visible"))}; } } for (int i = 0; i < hyperlinkCheckBoxes.length; i++) { hyperlinkCheckBoxes[i].setEnabled(cellElementVisibleCheckBoxes.isSelected()); } addHyperlinkListener(); double[] rowSize = new double[hyperlinkCheckBoxes.length + 1]; int[][] rowCount = new int[hyperlinkCheckBoxes.length + 1][]; for (int i = 0; i < hyperlinkCheckBoxes.length + 1; i++) { rowSize[i] = p; rowCount[i] = new int[]{1, 1}; } double[] columnSize = {p, f}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } private JPanel populateMutilHyperlinkCheckPane() { //超链接的个数+单元格可见的操作 hyperlinkCheckBoxes = new UICheckBox[1]; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[2][]; components[0] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}; components[1] = new Component[]{new UILabel(Inter.getLocText("FR-Designer_Hyperlink"), SwingConstants.LEFT), hyperlinkCheckBoxes[0] = new UICheckBox(Inter.getLocText("FR-Designer_Visible"))}; hyperlinkCheckBoxes[0].setEnabled(cellElementVisibleCheckBoxes.isSelected()); addHyperlinkListener(); double[] rowSize = {p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } } \ No newline at end of file