帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

251 lines
11 KiB

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