diff --git a/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java b/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java index 7f52a21abb..1d7a29ac3e 100644 --- a/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java +++ b/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.bbs.BBSConstants; +import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.stable.StringUtils; import com.fr.stable.core.UUID; @@ -101,7 +102,7 @@ public class ActiveKeyGenerator { para.put("uuid", envManager.getUUID()); para.put("key", key); para.put("username", envManager.getBBSName()); - HttpClient hc = new HttpClient(BBSConstants.VERIFY_URL, para); + HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("verify.code"), para); if (timeout != -1) { hc.setTimeout(timeout); } diff --git a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java index 27c2c1ec0c..0cc1bfc6b4 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.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 +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 diff --git a/designer/src/com/fr/design/mainframe/InformationCollector.java b/designer/src/com/fr/design/mainframe/InformationCollector.java index f7711efb74..c528e84a03 100644 --- a/designer/src/com/fr/design/mainframe/InformationCollector.java +++ b/designer/src/com/fr/design/mainframe/InformationCollector.java @@ -51,8 +51,6 @@ public class InformationCollector implements XMLReadable, XMLWriter { private static final String XML_KEY = "ActiveKey"; private static final String XML_OS = "OS"; - public static final String FUNCTIONS_INFO = "http://feedback.finedevelop.com:3000/monitor/function/record"; - public static final String USER_INFO = "http://feedback.finedevelop.com:3000/monitor/userinfo/record"; public static final String TABLE_NAME = "fr_functionrecord"; public static final String FUNC_COLUMNNAME = "func"; @@ -154,7 +152,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { return; } byte[] content = getJSONContentAsByte(); - HttpClient hc = new HttpClient(USER_INFO); + HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("user.info")); hc.setContent(content); if (!hc.isServerAlive()) { return; @@ -192,7 +190,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { DBUtils.closeConnection(conn); } - HttpClient httpClient = new HttpClient(FUNCTIONS_INFO); + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("functions.info")); httpClient.setContent(content); httpClient.setTimeout(5000); diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java b/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java index f294b302e1..121929e090 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java @@ -14,20 +14,6 @@ import java.util.Properties; */ public class BBSConstants { - //获取当前登陆用户未读取消息条数 - public static final String GET_MESSAGE_URL = loadAttribute("GET_MESSAGE_URL", "http://feedback.finedevelop.com:3000/bbs/message/count"); - //默认打开的论坛窗口 - public static final String DEFAULT_URL = loadAttribute("DEFAULT_URL", "http://bbs.finereport.com/home.php?mod=space&do=pm"); - //默认模板分享的url - public static final String SHARE_URL = loadAttribute("SHARE_URL", "http://bbs.finereport.com/"); - //收集设计器的信息url - public static final String COLLECT_URL = loadAttribute("COLLECT_URL", "http://bbs.finereport.com/"); - //在线验证激活码 - public static final String VERIFY_URL = loadAttribute("VERIFY_URL", "http://bbs.finereport.com/"); - //获取论坛更新信息, 判断是否需要弹窗 - public static final String UPDATE_INFO_URL = loadAttribute("UPDATE_INFO_URL", "http://bbs.finereport.com/"); - //论坛手机版 - public static final String BBS_MOBILE_MOD = loadAttribute("BBS_MOBILE_MOD", "http://bbs.finereport.com/forum.php?mobile=1"); //判断是否更新的关键字 public static final String UPDATE_KEY = loadAttribute("UPDATE_KEY", "newIsPopup"); diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java index 3465d17939..c714bb055b 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java @@ -5,6 +5,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; +import com.fr.general.SiteCenter; import javafx.application.Platform; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -14,6 +15,7 @@ import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.web.WebEngine; import javafx.scene.web.WebView; +import netscape.javascript.JSObject; import javax.swing.*; @@ -30,8 +32,8 @@ public class BBSDialog extends UIDialog { private static final int WIDTH = 600; private static final int HEIGHT = 400; - private static final int OUTER_WIDTH = 605; - private static final int OUTER_HEIGHT = 428; + private static final int OUTER_WIDTH = 600; + private static final int OUTER_HEIGHT = 400; private JFXPanel jfxPanel; @@ -39,7 +41,7 @@ public class BBSDialog extends UIDialog { public BBSDialog(Frame parent) { super(parent); - //setUndecorated(true); + setUndecorated(true); JPanel panel = (JPanel) getContentPane(); initComponents(panel); setSize(new Dimension(OUTER_WIDTH, OUTER_HEIGHT)); @@ -95,7 +97,7 @@ public class BBSDialog extends UIDialog { { disableLink(eng); // webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转 - if(ComparatorUtils.equals(newValue, url) || ComparatorUtils.equals(newValue, BBSConstants.BBS_MOBILE_MOD)){ + if(ComparatorUtils.equals(newValue, url) || ComparatorUtils.equals(newValue, SiteCenter.getInstance().acquireUrlByKind("bbs.mobile"))){ return; } openUrlAtLocalWebBrowser(eng,newValue); @@ -105,6 +107,8 @@ public class BBSDialog extends UIDialog { @Override public void changed(ObservableValue observable, Worker.State oldValue, Worker.State newValue) { if (newValue == Worker.State.SUCCEEDED){ + JSObject obj = (JSObject) eng.executeScript("window"); + obj.setMember("BBSWebBridge", BBSDialog.this); setVisible(true); } } @@ -112,7 +116,7 @@ public class BBSDialog extends UIDialog { } }); } - + // 在本地浏览器里打开url private void openUrlAtLocalWebBrowser(WebEngine eng,String url){ if(Desktop.isDesktopSupported()){ @@ -136,6 +140,13 @@ public class BBSDialog extends UIDialog { } } + /** + * 提供给web页面调用的关闭窗口 + */ + public void closeWindow() { + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + this.setVisible(false); + } /** * 略 */ diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java index 319c3d92e6..712bba5ebe 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -11,6 +11,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.DesignerContext; import com.fr.general.ComparatorUtils; import com.fr.general.DateUtils; +import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; @@ -112,7 +113,7 @@ public class UserInfoLabel extends UILabel{ FRContext.getLogger().error(e.getMessage()); } - HttpClient hc = new HttpClient(BBSConstants.UPDATE_INFO_URL); + HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.popup")); if (!hc.isServerAlive()){ return; } @@ -124,7 +125,7 @@ public class UserInfoLabel extends UILabel{ try { BBSDialog bbsLabel = new BBSDialog(DesignerContext.getDesignerFrame()); - bbsLabel.showWindow(BBSConstants.UPDATE_INFO_URL); + bbsLabel.showWindow(SiteCenter.getInstance().acquireUrlByKind("bbs.popup")); DesignerEnvManager.getEnvManager().setLastShowBBSNewsTime(DateUtils.DATEFORMAT2.format(new Date())); } catch (Throwable e) { @@ -181,7 +182,7 @@ public class UserInfoLabel extends UILabel{ while(StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getBBSName())){ HashMap para = new HashMap(); para.put("username", encode(encode(userName))); - HttpClient getMessage = new HttpClient(BBSConstants.GET_MESSAGE_URL, para); + HttpClient getMessage = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.message"), para); getMessage.asGet(); if(getMessage.isServerAlive()){ try { @@ -243,7 +244,7 @@ public class UserInfoLabel extends UILabel{ public void mouseClicked(MouseEvent e) { if(StringUtils.isNotEmpty(userName)){ try { - Desktop.getDesktop().browse(new URI(BBSConstants.DEFAULT_URL)); + Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.default"))); } catch (Exception exp) { } diff --git a/designer/src/com/fr/design/report/share/ShareButton.java b/designer/src/com/fr/design/report/share/ShareButton.java index 8bbdcc4143..756f4028f8 100644 --- a/designer/src/com/fr/design/report/share/ShareButton.java +++ b/designer/src/com/fr/design/report/share/ShareButton.java @@ -20,6 +20,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.file.FILE; import com.fr.general.Inter; import com.fr.general.NameObject; +import com.fr.general.SiteCenter; import com.fr.io.exporter.ImageExporter; import com.fr.main.TemplateWorkBook; import com.fr.main.workbook.ResultWorkBook; @@ -56,7 +57,7 @@ public class ShareButton extends UIButton{ //打开论坛, url可在bbs.properties中配置 private void openBBS(){ try { - Desktop.getDesktop().browse(new URI(BBSConstants.SHARE_URL)); + Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.share"))); } catch (Exception e1) { FRContext.getLogger().error(e1.getMessage()); } diff --git a/designer_base/designer_base.iml b/designer_base/designer_base.iml index 9f8c89a0b5..d20642b282 100644 --- a/designer_base/designer_base.iml +++ b/designer_base/designer_base.iml @@ -1,7 +1,7 @@ - + diff --git a/designer_base/src/com/fr/design/actions/help/ForumAction.java b/designer_base/src/com/fr/design/actions/help/ForumAction.java index 8df49a5bba..5b0af84dc8 100644 --- a/designer_base/src/com/fr/design/actions/help/ForumAction.java +++ b/designer_base/src/com/fr/design/actions/help/ForumAction.java @@ -9,6 +9,7 @@ import com.fr.base.FRContext; import com.fr.design.actions.UpdateAction; import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; +import com.fr.general.SiteCenter; import com.fr.stable.StringUtils; import javax.swing.*; @@ -38,7 +39,7 @@ public class ForumAction extends UpdateAction { * @param e 事件 */ public void actionPerformed(ActionEvent e) { - String url = "http://bbs.finereport.com/"; + String url = SiteCenter.getInstance().acquireUrlByKind("bbs"); if (StringUtils.isEmpty(url)) { FRContext.getLogger().info("The URL is empty!"); return; diff --git a/designer_base/src/com/fr/design/extra/PluginConstants.java b/designer_base/src/com/fr/design/extra/PluginConstants.java index 7f60a0b52f..4704ed129a 100644 --- a/designer_base/src/com/fr/design/extra/PluginConstants.java +++ b/designer_base/src/com/fr/design/extra/PluginConstants.java @@ -7,22 +7,6 @@ package com.fr.design.extra; */ public class PluginConstants { - public static final String PLUGIN_INSTALL_INFO = "http://feedback.finedevelop.com:3000/plugin"; - - /** - * 获取所有插件的服务器地址 - */ - public static final String PLUGIN_STORE_URL = "http://shop.finereport.com/ShopServer?pg=all_plugin"; - - /** - * 获取插件更新信息的服务器地址 - */ - public static final String PLUGIN_CHECK_UPDATE_URL = "http://shop.finereport.com/ShopServer?pg=all_plugin"; - - /** - * 插件下载服务器地址 - */ - public static final String PLUGIN_DOWNLOAD_URL = "http://shop.finereport.com/ShopServer?pg=plugin"; public static final int BYTES_NUM = 1024; diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 62f6c5e30f..b50b904a02 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -3,11 +3,7 @@ package com.fr.design.extra; import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; -import com.fr.general.ComparatorUtils; -import com.fr.general.FRLogger; -import com.fr.general.GeneralUtils; -import com.fr.general.IOUtils; -import com.fr.general.Inter; +import com.fr.general.*; import com.fr.general.http.HttpClient; import com.fr.plugin.Plugin; import com.fr.plugin.PluginLoader; @@ -73,7 +69,7 @@ public class PluginHelper { map.put("id", id); map.put("username", username); map.put("password", password); - HttpClient httpClient = new HttpClient(PluginConstants.PLUGIN_DOWNLOAD_URL, map); + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.download"), map); String resText = httpClient.getResponseText(); String charSet = EncodeConstants.ENCODING_UTF_8; resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet); @@ -288,7 +284,7 @@ public class PluginHelper { map.put("detail", plugin.toJSONObject().toString()); map.put("build", GeneralUtils.readBuildNO()); //第三个参数encode, nodejs服务器那边如果参数不encode, 带了空格会报错, 直接用urlconnection也是一样, jetty没能还原. - HttpClient httpClient = new HttpClient(PluginConstants.PLUGIN_INSTALL_INFO, map, true); + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.install"), map, true); httpClient.setTimeout(TIME_OUT); httpClient.asGet(); return httpClient.getResponseText(); diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index d2e267ed07..d579266eff 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -37,14 +37,15 @@ public class PluginManagerPane extends BasicPane { public PluginManagerPane() { setLayout(new BorderLayout()); - if (StableUtils.isDebug()) { - URL url = ClassLoader.getSystemResource(""); - String installHome = url.getPath(); - PluginWebPane webPane = new PluginWebPane(installHome); - add(webPane, BorderLayout.CENTER); - } else { - initTraditionalStore(); - } +// if (StableUtils.isDebug()) { +// URL url = ClassLoader.getSystemResource(""); +// String installHome = url.getPath(); +// PluginWebPane webPane = new PluginWebPane(installHome); +// add(webPane, BorderLayout.CENTER); +// } else { +// +// } + initTraditionalStore(); } private void initTraditionalStore() { diff --git a/designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java b/designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java index 533ef33abe..8c77141ca7 100644 --- a/designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java +++ b/designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java @@ -2,6 +2,7 @@ package com.fr.design.extra; import com.fr.general.GeneralUtils; import com.fr.general.Inter; +import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; @@ -32,7 +33,7 @@ public class PluginsReaderFromStore { public static Plugin[] readPlugins() throws Exception { String resText; try { - HttpClient httpClient = new HttpClient(PluginConstants.PLUGIN_STORE_URL); + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.store")); resText = httpClient.getResponseText(); String charSet = EncodeConstants.ENCODING_UTF_8; resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet); @@ -70,7 +71,7 @@ public class PluginsReaderFromStore { para.put("plugins", PluginLoader.getLoader().pluginsToString()); //只有当前设计器的jar高于插件新版本需要的jarTime时, 才提示更新该插件. para.put("jarTime", GeneralUtils.readBuildNO()); - HttpClient httpClient = new HttpClient(PluginConstants.PLUGIN_CHECK_UPDATE_URL, para); + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.update"), para); resText = httpClient.getResponseText(); String charSet = EncodeConstants.ENCODING_UTF_8; resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet); diff --git a/designer_base/src/com/fr/design/fun/DesignerEnvProcessor.java b/designer_base/src/com/fr/design/fun/DesignerEnvProcessor.java index 805a074b4b..a74c73f96d 100644 --- a/designer_base/src/com/fr/design/fun/DesignerEnvProcessor.java +++ b/designer_base/src/com/fr/design/fun/DesignerEnvProcessor.java @@ -21,4 +21,11 @@ public interface DesignerEnvProcessor extends Level{ * @return 修改后的jsessionid */ String changeEnvPathBeforeConnect(String userName, String password, String path); + + /** + * web端预览的时候不需要jsessionid, 他会默认跳转到登陆页面, 如果带上了, 反而会因为里面资源文件加载不到而出问题. + * + * @return web端预览地址 + */ + String getWebBrowserURL(String envPath); } diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractDesignerEnvProcessor.java b/designer_base/src/com/fr/design/fun/impl/AbstractDesignerEnvProcessor.java index 1c07a37db7..03a0b7f369 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractDesignerEnvProcessor.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractDesignerEnvProcessor.java @@ -15,4 +15,8 @@ public abstract class AbstractDesignerEnvProcessor implements DesignerEnvProcess return path; } + public String getWebBrowserURL(String envPath){ + return envPath; + } + } diff --git a/designer_base/src/com/fr/design/utils/DesignUtils.java b/designer_base/src/com/fr/design/utils/DesignUtils.java index f048578d91..94db76af54 100644 --- a/designer_base/src/com/fr/design/utils/DesignUtils.java +++ b/designer_base/src/com/fr/design/utils/DesignUtils.java @@ -5,6 +5,8 @@ import com.fr.base.remote.RemoteDeziConstants; import com.fr.dav.DavXMLUtils; import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.UILookAndFeel; import com.fr.design.mainframe.DesignerContext; import com.fr.env.RemoteEnv; @@ -303,7 +305,8 @@ public class DesignUtils { postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCurrentEnv().getUserID(): postfixOfUri ; } - Desktop.getDesktop().browse(new URI(FRContext.getCurrentEnv().getPath() + postfixOfUri)); + String urlPath = getWebBrowserPath(); + Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri)); } catch (Exception e) { FRContext.getLogger().error("cannot open the url Successful", e); } @@ -319,6 +322,16 @@ public class DesignUtils { } } + private static String getWebBrowserPath() { + String urlPath = FRContext.getCurrentEnv().getPath(); + DesignerEnvProcessor processor = ExtraDesignClassManager.getInstance().getEnvProcessor(); + if (processor != null) { + //cas访问的时候, url要处理下. + urlPath = processor.getWebBrowserURL(urlPath); + } + return urlPath; + } + //TODO:august:下个版本,要把下面的图片都放在一个preload文件夹下,表示可以预先加载。然后遍历一下就可以了,不用这么一个一个的写了 /**