diff --git a/designer/src/com/fr/design/cell/editor/RichTextToolBar.java b/designer/src/com/fr/design/cell/editor/RichTextToolBar.java index 8d7708c9ce..1bf8a2f569 100644 --- a/designer/src/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer/src/com/fr/design/cell/editor/RichTextToolBar.java @@ -134,7 +134,7 @@ public class RichTextToolBar extends BasicPane{ } private void bindListener(){ - FRFont defaultFont = RichTextPane.DEFAUL_FONT; + FRFont defaultFont = (this.textPane != null) ? FRFont.getInstance(this.textPane.getFont()) : RichTextPane.DEFAUL_FONT; fontNameComboBox.addItemListener(fontNameItemListener); fontNameComboBox.setSelectedItem(defaultFont.getFontName()); fontSizeComboBox.addItemListener(fontSizeItemListener); diff --git a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java index d464d8f487..a760e0043b 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java @@ -1 +1,251 @@ -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 +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 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[]{"FR-Designer_Permissions", + "FR-Designer_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("FR-Designer_Visible")); + private ItemListener itemListener = new ItemListener() { + public void itemStateChanged(ItemEvent e) { + String selectedRole = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); + initSelectedPathArray(); + if (ComparatorUtils.equals(selectedRole, Inter.getLocText("FR-Designer_Role")) || selectedRole == + null || selectedPathArray == null) { + return; + } + for (int t = 0; t < selectedPathArray.length; t++) { + for (int i = 0; i < buttonlists.size(); i++) { + if (buttonlists.get(i).isSelected()) { + buttonlists.get(i).changeAuthorityState(selectedPathArray[t], buttonVisible.isSelected()); + authorityToolBarPane.repaint(); + } + } + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); + RolesAlreadyEditedPane.getInstance().refreshDockingView(); + UICheckBox checkbox = (UICheckBox) e.getSource(); + List btns = AuthorityEditPane.this.buttonlists; + for (int j = 0; j < btns.size(); j++) { + if (btns.get(j).isSelected()) { + //由引擎实现保存进模板报表 + authorityToolBarPane.setAuthorityWebAttr(btns.get(j).getWidget(), checkbox.isSelected(), selectedPathArray[t]); + } + } + } + } + }; + + /** + * @see ElementCasePaneAuthorityEditPane initSelectedPathArray() + */ + private void initSelectedPathArray() { + 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 = ElementCasePaneAuthorityEditPane.pathToString(selectionPaths); + } + } else { + selectedPathArray = ElementCasePaneAuthorityEditPane.pathToString(selectionPaths); + } + + } + + 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("FR-Designer_Type") + ":", SwingConstants.RIGHT)}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_WF_Name") + ":", SwingConstants.RIGHT)}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Permissions") + ":", 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", "FR-Designer_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("FR-Designer_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 3f9a717dd4..fe6c616ede 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java @@ -1 +1,829 @@ -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 +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; +import java.util.ArrayList; + +/** + * 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() { + initSelectedPathArray(); + 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 < selectedPathArray.length; t++) { + if (!isVisible) { + for (int col = cellSelection.getColumn(); col < cellSelection.getColumn() + cellSelection.getColumnSpan(); col++) { + elementCase.addColumnPrivilegeControl(col, selectedPathArray[t]); + } + } else { + for (int col = cellSelection.getColumn(); col < cellSelection.getColumn() + cellSelection.getColumnSpan(); col++) { + elementCase.removeColumnPrivilegeControl(col, selectedPathArray[t]); + } + } + } + + return true; + } + + private boolean setAuthorityRow() { + initSelectedPathArray(); + 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 < selectedPathArray.length; t++) { + if (!isVisible) { + for (int row = cellSelection.getRow(); row < cellSelection.getRow() + cellSelection.getRowSpan(); row++) { + elementCase.addRowPrivilegeControl(row, selectedPathArray[t]); + } + } else { + for (int row = cellSelection.getRow(); row < cellSelection.getRow() + cellSelection.getRowSpan(); row++) { + elementCase.removeRowPrivilegeControl(row, selectedPathArray[t]); + } + } + } + + + return true; + } + + private boolean setLFloatAuthorityStyle() { + initSelectedPathArray(); + 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; + } + String name = floatSelection.getSelectedFloatName(); + TemplateElementCase ec = elementCasePane.getEditingElementCase(); + FloatElement fe = ec.getFloatElement(name); + for (int t = 0; t < selectedPathArray.length; t++) { + fe.changeAuthorityState(selectedPathArray[t], floatElementVisibleCheckBoxes.isSelected()); + } + + return true; + } + + private boolean setAuthorityStyle(int type) { + initSelectedPathArray(); + String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); + if (ComparatorUtils.equals(selectedRoles, Inter.getLocText("FR-Designer_Role")) || + selectedRoles == null || selectedPathArray == null) { + return false; + } + final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); + int cellRectangleCount = cellSelection.getCellRectangleCount(); + for (int t = 0; t < selectedPathArray.length; t++) { + + 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(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; + } + + /** + * @see AuthorityEditToolBarPane initSelectedPathArray + */ + private void initSelectedPathArray() { + 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); + } + + } + + public static String[] pathToString(TreePath[] path) { + java.util.List roles = new ArrayList(); + if (path != null && path.length > 0) { + 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("," + StringUtils.BLANK); + String role = selectedRoles[2].trim(); + roles.add(role); + } + + } + } + return roles.toArray(new String[0]); + } + + /** + * 选中的单元格的乐见状态以第一个单元格为齐 + */ + 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) { + 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/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index b3b020ac31..182239ee84 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -1986,4 +1986,8 @@ FR-Designer_Edit_String_To_Formula= FR-Base_UnSignIn= Every= CellWrite-Preview_Cell_Content=Preview Content of Cell -FormulaD-Data_Fields=Data Fields \ No newline at end of file +FormulaD-Data_Fields=Data Fields +FR-Designer_Role=Role +FR-Designer_Permissions=Permissions +FR-Designer_Form_Button=Button +FR-Designer_WF_Name=Name \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 4bfbbdf899..4c0135daf1 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -1987,4 +1987,8 @@ FR-Designer_Edit_String_To_Formula=Edit String To Formula FR-Base_UnSignIn=\ Not Logged In Every=Every CellWrite-Preview_Cell_Content=Content of Cell -FormulaD-Data_Fields=Data Items \ No newline at end of file +FormulaD-Data_Fields=Data Items +FR-Designer_Role=Role +FR-Designer_Permissions=Permissions +FR-Designer_Form_Button=Button +FR-Designer_WF_Name=Name \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index db6c120c90..64aff3d0fa 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -1982,4 +1982,8 @@ FR-Designer_Edit_String_To_Formula=\u662F\u5426\u5C06\u5B57\u7B26\u4E32\u7F16\u8 FR-Base_UnSignIn=\ \u672A\u767B\u5F55 Every=\u6BCF CellWrite-Preview_Cell_Content=\u9884\u89C8\u5355\u5143\u683C\u5185\u5BB9 -FormulaD-Data_Fields=\u6570\u636E\u9879 \ No newline at end of file +FormulaD-Data_Fields=\u6570\u636E\u9879 +FR-Designer_Role=\u89D2\u8272 +FR-Designer_Permissions=\u6743\u9650 +FR-Designer_Form_Button=\u6309\u94AE +FR-Designer_WF_Name=\u540D\u79F0 \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 674a95f90e..9994427d88 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -1982,4 +1982,8 @@ FR-Designer_Edit_String_To_Formula=\u662F\u5426\u5C07\u5B57\u5143\u4E32\u7DE8\u8 FR-Base_UnSignIn=\u672A\u767B\u9304 Every=\u6BCF CellWrite-Preview_Cell_Content=\u9810\u89BD\u5132\u5B58\u683C\u5167\u5BB9 -FormulaD-Data_Fields=\u8CC7\u6599\u9805 \ No newline at end of file +FormulaD-Data_Fields=\u8CC7\u6599\u9805 +FR-Designer_Role=\u89D2\u8272 +FR-Designer_Permissions=\u6B0A\u9650 +FR-Designer_Form_Button=\u6309\u9215 +FR-Designer_WF_Name=\u540D\u7A31 \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XElementCase.java b/designer_form/src/com/fr/design/designer/creator/XElementCase.java index 7eb967a9f7..c22c6acf54 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -10,11 +10,9 @@ import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.impl.AbstractFormElementCaseEditorProvider; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.*; -import com.fr.design.mainframe.widget.editors.BooleanEditor; +import com.fr.design.mainframe.widget.editors.ElementCaseToolBarEditor; import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; -import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; -import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.FormProvider; @@ -104,7 +102,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) .setI18NName(Inter.getLocText("FR-Layout_Padding")) .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - new CRPropertyDescriptor("showToolBar", this.data.getClass()).setEditorClass(BooleanEditor.class) + new CRPropertyDescriptor("toolBars", this.data.getClass()).setEditorClass(ElementCaseToolBarEditor.class) .setI18NName(Inter.getLocText("Form-EC_toolbar")) .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") };