|
|
|
@ -4,14 +4,18 @@ import java.awt.BorderLayout;
|
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.event.ItemEvent; |
|
|
|
|
import java.awt.event.ItemListener; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.tree.TreePath; |
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.LayoutConstants; |
|
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
|
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.AuthorityEditPane; |
|
|
|
@ -22,6 +26,9 @@ 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.stable.ArrayUtils; |
|
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -34,15 +41,21 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
private Widget[] widgets = null; |
|
|
|
|
private UICheckBox widgetVisible = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Visible")); |
|
|
|
|
private UICheckBox widgetAvailable = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Enabled")); |
|
|
|
|
private String[] selectedArray; |
|
|
|
|
private ItemListener visibleItemListener = new ItemListener() { |
|
|
|
|
@Override |
|
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
|
String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); |
|
|
|
|
if (selectedRoles == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (widgets != null && widgets.length > 0) { |
|
|
|
|
for (int i = 0; i < widgets.length; i++) { |
|
|
|
|
widgets[i].changeVisibleAuthorityState(selectedRoles, widgetVisible.isSelected()); |
|
|
|
|
initSelectedArray(); |
|
|
|
|
if (ArrayUtils.isEmpty(selectedArray)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
for (String selectedRole : selectedArray) { |
|
|
|
|
for (Widget widget : widgets) { |
|
|
|
|
widget.changeVisibleAuthorityState(selectedRole, widgetVisible.isSelected()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
doAfterAuthority(); |
|
|
|
@ -51,6 +64,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ItemListener usableItemListener = new ItemListener() { |
|
|
|
|
@Override |
|
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
|
String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); |
|
|
|
|
if (ComparatorUtils.equals(selectedRoles, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Role"))) { |
|
|
|
@ -59,9 +73,13 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
if (selectedRoles == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (widgets != null && widgets.length > 0) { |
|
|
|
|
for (int i = 0; i < widgets.length; i++) { |
|
|
|
|
widgets[i].changeUsableAuthorityState(selectedRoles, widgetAvailable.isSelected()); |
|
|
|
|
initSelectedArray(); |
|
|
|
|
if (ArrayUtils.isEmpty(selectedArray)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
for (String selectedRole : selectedArray) { |
|
|
|
|
for (Widget widget : widgets) { |
|
|
|
|
widget.changeUsableAuthorityState(selectedRole, widgetAvailable.isSelected()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
doAfterAuthority(); |
|
|
|
@ -78,7 +96,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
|
|
|
|
|
private void doAfterAuthority() { |
|
|
|
|
designer.repaint(); |
|
|
|
|
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); |
|
|
|
|
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); |
|
|
|
|
RolesAlreadyEditedPane.getInstance().refreshDockingView(); |
|
|
|
|
RolesAlreadyEditedPane.getInstance().setReportAndFSSelectedRoles(); |
|
|
|
|
RolesAlreadyEditedPane.getInstance().repaint(); |
|
|
|
@ -90,6 +108,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
* |
|
|
|
|
* @date 2014-12-21-下午6:19:43 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void populateType() { |
|
|
|
|
type.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Form_Widget_Config")); |
|
|
|
|
} |
|
|
|
@ -99,15 +118,16 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
* |
|
|
|
|
* @date 2014-12-21-下午7:12:27 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void populateName() { |
|
|
|
|
String nameText = ""; |
|
|
|
|
if (widgets == null || widgets.length <= 0) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < widgets.length; i++) { |
|
|
|
|
nameText += "," + widgets[i].getClass().getSimpleName(); |
|
|
|
|
List<String> widgetNames = new ArrayList<String>(); |
|
|
|
|
for (Widget widget : widgets) { |
|
|
|
|
widgetNames.add(widget.getClass().getSimpleName()); |
|
|
|
|
} |
|
|
|
|
name.setText(nameText.substring(1)); |
|
|
|
|
name.setText(StableUtils.join(widgetNames, ",")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -116,6 +136,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
* @return 面板 |
|
|
|
|
* @date 2014-12-21-下午6:19:03 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public JPanel populateCheckPane() { |
|
|
|
|
checkPane.add(populateWidgetCheckPane(), BorderLayout.CENTER); |
|
|
|
|
checkPane.setBorder(BorderFactory.createEmptyBorder(0, LEFT_CHECKPANE, 0, 0)); |
|
|
|
@ -138,10 +159,11 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
/** |
|
|
|
|
* 对单元格区域进行操作时的权限编辑页面 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void populateDetials() { |
|
|
|
|
//更新说明要是JWorkBook的话,说明鼠标焦点又改变了
|
|
|
|
|
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setAuthorityMode(true); |
|
|
|
|
signelSelection(); |
|
|
|
|
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().setAuthorityMode(true); |
|
|
|
|
singleSelection(); |
|
|
|
|
|
|
|
|
|
refreshCreator(); |
|
|
|
|
//如果是布局选中不支持的元素则显示“该元素不支持权限控制”
|
|
|
|
@ -186,8 +208,8 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
|
|
|
|
|
//实现单选
|
|
|
|
|
|
|
|
|
|
private void signelSelection() { |
|
|
|
|
if (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().isJWorkBook()) { |
|
|
|
|
private void singleSelection() { |
|
|
|
|
if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().isJWorkBook()) { |
|
|
|
|
//清工具栏
|
|
|
|
|
JComponent component = DesignerContext.getDesignerFrame().getToolbarComponent(); |
|
|
|
|
if (component instanceof AuthorityEditToolBarComponent) { |
|
|
|
@ -195,7 +217,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//清空报表主体的单元格选择
|
|
|
|
|
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().removeTemplateSelection(); |
|
|
|
|
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().removeTemplateSelection(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -204,5 +226,40 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane {
|
|
|
|
|
widgets = size == 0 ? null : designer.getSelectionModel().getSelection().getSelectedWidgets(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initSelectedArray() { |
|
|
|
|
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(); |
|
|
|
|
selectedArray = new String[node.getChildCount()]; |
|
|
|
|
for (int i = 0, len = node.getChildCount(); i < len; i++) { |
|
|
|
|
ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) node.getChildAt(i); |
|
|
|
|
String nodeName = treeNode.getUserObject().toString(); |
|
|
|
|
selectedArray[i] = nodeName; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
selectedArray = pathToString(selectionPaths); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
selectedArray = pathToString(selectionPaths); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String[] pathToString(TreePath[] path) { |
|
|
|
|
List<String> roles = new ArrayList<String>(); |
|
|
|
|
if (!ArrayUtils.isEmpty(path)) { |
|
|
|
|
for (TreePath tempPath : path) { |
|
|
|
|
String temp = tempPath.toString(); |
|
|
|
|
boolean exist = StringUtils.isNotEmpty(temp) && temp.startsWith("[") && temp.endsWith("]"); |
|
|
|
|
if (exist) { |
|
|
|
|
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]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|