diff --git a/designer/src/com/fr/design/actions/cell/CleanAuthorityAction.java b/designer/src/com/fr/design/actions/cell/CleanAuthorityAction.java index a7b22cfbe7..0251654f40 100644 --- a/designer/src/com/fr/design/actions/cell/CleanAuthorityAction.java +++ b/designer/src/com/fr/design/actions/cell/CleanAuthorityAction.java @@ -1 +1 @@ -package com.fr.design.actions.cell; import java.awt.Rectangle; import java.awt.event.ActionEvent; import com.fr.design.actions.ElementCaseAction; import com.fr.design.mainframe.AuthorityPropertyPane; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; 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.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; /** * Author : daisy * Date: 13-9-23 * Time: 下午2:41 */ public class CleanAuthorityAction extends ElementCaseAction { public CleanAuthorityAction(ElementCasePane t) { super(t); this.setName(Inter.getLocText(new String[]{"Clear", "DashBoard-Potence"})); } /** * 清楚权限动作 * * @param evt 事件 */ public void actionPerformed(ActionEvent evt) { ElementCasePane reportPane = getEditingComponent(); Selection selection = reportPane.getSelection(); String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (selection instanceof FloatSelection) { String name = ((FloatSelection) selection).getSelectedFloatName(); TemplateElementCase ec = reportPane.getEditingElementCase(); FloatElement fe = ec.getFloatElement(name); if (fe.isDoneAuthority(selectedRoles)) { fe.cleanAuthority(selectedRoles); } doAfterAuthority(reportPane); return; } CellSelection cellSelection = (CellSelection) selection; boolean isChooseColumnRow = cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN || cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW; if (isChooseColumnRow && cellSelection.getCellRectangleCount() == 1) { cleanColumnRow(cellSelection, reportPane, selectedRoles); } else { cleanCell(cellSelection, reportPane, selectedRoles); } doAfterAuthority(reportPane); } private void doAfterAuthority(ElementCasePane reportPane) { reportPane.repaint(); reportPane.fireTargetModified(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().repaint(); if (EastRegionContainerPane.getInstance().getUpPane() instanceof AuthorityPropertyPane) { AuthorityPropertyPane authorityPropertyPane = (AuthorityPropertyPane) EastRegionContainerPane.getInstance().getUpPane(); authorityPropertyPane.populate(); EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.AUTHORITY_EDITION); EastRegionContainerPane.getInstance().replaceAuthorityEditionPane(authorityPropertyPane); } } /** * 清除单元格对应的角色的权限 * * @param cellSelection * @param reportPane */ private void cleanCell(CellSelection cellSelection, ElementCasePane reportPane, String selectedRoles) { if (selectedRoles == null) { return; } TemplateElementCase elementCase = reportPane.getEditingElementCase(); int cellRectangleCount = cellSelection.getCellRectangleCount(); for (int rect = 0; rect < cellRectangleCount; 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; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { continue; } //清除权限 if (cellElement.isDoneAuthority(selectedRoles) || cellElement.isDoneNewValueAuthority(selectedRoles)) { cellElement.cleanAuthority(selectedRoles); } if (cellElement.getWidget() == null) { continue; } boolean isDoneAuthority = cellElement.getWidget().isDoneVisibleAuthority(selectedRoles) || cellElement.getWidget().isDoneUsableAuthority(selectedRoles); if (isDoneAuthority) { cellElement.getWidget().cleanAuthority(selectedRoles); } } } } } private void cleanColumnRow(CellSelection cellSelection, ElementCasePane reportPane, String selectedRoles) { if (selectedRoles == null) { return; } TemplateElementCase elementCase = reportPane.getEditingElementCase(); if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN) { for (int col = cellSelection.getColumn(); col < cellSelection.getColumn() + cellSelection.getColumnSpan(); col++) { elementCase.removeColumnPrivilegeControl(col, selectedRoles); } } else { for (int row = cellSelection.getRow(); row < cellSelection.getRow() + cellSelection.getRowSpan(); row++) { elementCase.removeRowPrivilegeControl(row, selectedRoles); } } } /** * 是否需要撤销动作 * * @return 不需要 */ public boolean executeActionReturnUndoRecordNeeded() { return false; } } \ No newline at end of file +package com.fr.design.actions.cell; import com.fr.design.actions.ElementCaseAction; import com.fr.design.mainframe.AuthorityPropertyPane; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; 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.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import java.awt.*; import java.awt.event.ActionEvent; /** * Author : daisy * Date: 13-9-23 * Time: 下午2:41 */ public class CleanAuthorityAction extends ElementCaseAction { public CleanAuthorityAction(ElementCasePane t) { super(t); this.setName(Inter.getLocText(new String[]{"Clear", "DashBoard-Potence"})); } /** * 清楚权限动作 * * @param evt 事件 */ public void actionPerformed(ActionEvent evt) { ElementCasePane reportPane = getEditingComponent(); Selection selection = reportPane.getSelection(); String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (selection instanceof FloatSelection) { String name = ((FloatSelection) selection).getSelectedFloatName(); TemplateElementCase ec = reportPane.getEditingElementCase(); FloatElement fe = ec.getFloatElement(name); if (fe.isDoneAuthority(selectedRoles)) { fe.cleanAuthority(selectedRoles); } doAfterAuthority(reportPane); return; } CellSelection cellSelection = (CellSelection) selection; boolean isChooseColumnRow = cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN || cellSelection.getSelectedType() == CellSelection.CHOOSE_ROW; if (isChooseColumnRow && cellSelection.getCellRectangleCount() == 1) { cleanColumnRow(cellSelection, reportPane, selectedRoles); } else { cleanCell(cellSelection, reportPane, selectedRoles); } doAfterAuthority(reportPane); } private void doAfterAuthority(ElementCasePane reportPane) { reportPane.repaint(); reportPane.fireTargetModified(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().repaint(); if (EastRegionContainerPane.getInstance().getUpPane() instanceof AuthorityPropertyPane) { AuthorityPropertyPane authorityPropertyPane = (AuthorityPropertyPane) EastRegionContainerPane.getInstance().getUpPane(); authorityPropertyPane.populate(); EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.AUTHORITY_EDITION); EastRegionContainerPane.getInstance().replaceAuthorityEditionPane(authorityPropertyPane); } } /** * 清除单元格对应的角色的权限 * * @param cellSelection * @param reportPane */ private void cleanCell(CellSelection cellSelection, ElementCasePane reportPane, String selectedRoles) { if (selectedRoles == null) { return; } TemplateElementCase elementCase = reportPane.getEditingElementCase(); int cellRectangleCount = cellSelection.getCellRectangleCount(); for (int rect = 0; rect < cellRectangleCount; 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; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { continue; } //清除权限 if (cellElement.isDoneAuthority(selectedRoles) || cellElement.isDoneNewValueAuthority(selectedRoles)) { cellElement.cleanAuthority(selectedRoles); } if (cellElement.getWidget() == null) { continue; } boolean isDoneAuthority = cellElement.getWidget().isDoneVisibleAuthority(selectedRoles) || cellElement.getWidget().isDoneUsableAuthority(selectedRoles); if (isDoneAuthority) { cellElement.getWidget().cleanAuthority(selectedRoles); } } } } } private void cleanColumnRow(CellSelection cellSelection, ElementCasePane reportPane, String selectedRoles) { if (selectedRoles == null) { return; } TemplateElementCase elementCase = reportPane.getEditingElementCase(); if (cellSelection.getSelectedType() == CellSelection.CHOOSE_COLUMN) { for (int col = cellSelection.getColumn(); col < cellSelection.getColumn() + cellSelection.getColumnSpan(); col++) { elementCase.removeColumnPrivilegeControl(col, selectedRoles); } } else { for (int row = cellSelection.getRow(); row < cellSelection.getRow() + cellSelection.getRowSpan(); row++) { elementCase.removeRowPrivilegeControl(row, selectedRoles); } } } /** * 是否需要撤销动作 * * @return 不需要 */ public boolean executeActionReturnUndoRecordNeeded() { return false; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java index 317bed8d9f..2632316771 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java @@ -84,6 +84,8 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { private static final int TOP_GAP = 11; private static final int LEFT_GAP = 4; private static final int LEFT_CHECKPANE = 3; + private JPanel typePane; + private JPanel namePane; private UILabel type = null; private UILabel name = null; private JPanel checkPane = null; @@ -144,9 +146,15 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { public AuthorityEditPane(List buttonlists) { setLayout(new BorderLayout()); type = new UILabel(); - type.setBorder(BorderFactory.createLineBorder(Color.lightGray)); + typePane = new JPanel(new BorderLayout()); + typePane.add(type, BorderLayout.CENTER); + type.setBorder(BorderFactory.createEmptyBorder(0,LEFT_GAP,0,0)); + typePane.setBorder(BorderFactory.createLineBorder(Color.lightGray)); name = new UILabel(); - name.setBorder(BorderFactory.createLineBorder(Color.lightGray)); + namePane = new JPanel(new BorderLayout()); + namePane.add(name, BorderLayout.CENTER); + name.setBorder(BorderFactory.createEmptyBorder(0,LEFT_GAP,0,0)); + namePane.setBorder(BorderFactory.createLineBorder(Color.lightGray)); checkPane = new JPanel(); checkPane.setLayout(new BorderLayout()); this.add(centerPane(), BorderLayout.NORTH); @@ -162,8 +170,8 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Type") + " ", SwingConstants.LEFT), type}, - new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_WF_Name") + " ", SwingConstants.LEFT), name}, + new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Type") + " ", SwingConstants.LEFT), typePane}, + new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_WF_Name") + " ", SwingConstants.LEFT), namePane}, new Component[]{checkPane, null}, }; @@ -200,7 +208,7 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { if (name.getText() == "") { type.setText(""); } else { - type.setText(" " + Inter.getLocText(new String[]{"ReportServerP-Toolbar", "FR-Designer_Form_Button"})); + type.setText(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "FR-Designer_Form_Button"})); } } @@ -214,7 +222,7 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { if (names != "") { names = names.substring(1); } - name.setText(" " + names); + name.setText(names); } public void populateCheckPane() { diff --git a/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java b/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java index 59df5f06f2..ef9e6610cd 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java @@ -427,13 +427,13 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { */ public void populateType() { if (selectionType == CellSelection.NORMAL) { - type.setText(" "+Inter.getLocText("FR-Designer_Cell")); + type.setText(Inter.getLocText("FR-Designer_Cell")); } else if (selectionType == CellSelection.CHOOSE_ROW) { - type.setText(" "+Inter.getLocText("FR-Designer_Row")); + type.setText(Inter.getLocText("FR-Designer_Row")); } else if (selectionType == CellSelection.CHOOSE_COLUMN) { - type.setText(" "+Inter.getLocText("FR-Designer_Column")); + type.setText(Inter.getLocText("FR-Designer_Column")); } else { - type.setText(" "+Inter.getLocText("M_Insert-Float")); + type.setText(Inter.getLocText("M_Insert-Float")); } } @@ -442,11 +442,11 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { */ public void populateName() { if (selectionType == CellSelection.NORMAL) { - name.setText(" "+getCellSelectionName()); + name.setText(getCellSelectionName()); } else if (selectionType == CellSelection.CHOOSE_ROW || selectionType == CellSelection.CHOOSE_COLUMN) { - name.setText(" "+getCellColumnRowName()); + name.setText(getCellColumnRowName()); } else { - name.setText(" "+getFloatSelectionName()); + name.setText(getFloatSelectionName()); } } diff --git a/designer/src/com/fr/design/mainframe/SheetAuthorityEditPane.java b/designer/src/com/fr/design/mainframe/SheetAuthorityEditPane.java index 871b51cc66..66d9f8d95a 100644 --- a/designer/src/com/fr/design/mainframe/SheetAuthorityEditPane.java +++ b/designer/src/com/fr/design/mainframe/SheetAuthorityEditPane.java @@ -34,6 +34,8 @@ public class SheetAuthorityEditPane extends AuthorityEditPane { private UICheckBox sheetVisible = new UICheckBox("sheet" + Inter.getLocText("Widget-Visible")); private WorkBook workBook = null; private int selectedIndex = -1; + private JPanel typePane; + private JPanel namePane; private ItemListener itemListener = new ItemListener() { @Override @@ -66,9 +68,15 @@ public class SheetAuthorityEditPane extends AuthorityEditPane { super(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); setLayout(new BorderLayout()); type = new UILabel(); - type.setBorder(BorderFactory.createLineBorder(Color.lightGray)); + typePane = new JPanel(new BorderLayout()); + typePane.add(type, BorderLayout.CENTER); + type.setBorder(BorderFactory.createEmptyBorder(0,LEFT_GAP,0,0)); + typePane.setBorder(BorderFactory.createLineBorder(Color.lightGray)); name = new UILabel(); - name.setBorder(BorderFactory.createLineBorder(Color.lightGray)); + namePane = new JPanel(new BorderLayout()); + namePane.add(name, BorderLayout.CENTER); + name.setBorder(BorderFactory.createEmptyBorder(0,LEFT_GAP,0,0)); + namePane.setBorder(BorderFactory.createLineBorder(Color.lightGray)); checkPane = new JPanel(); checkPane.setLayout(new BorderLayout()); // this.add(layoutText(), BorderLayout.WEST); @@ -87,41 +95,14 @@ public class SheetAuthorityEditPane extends AuthorityEditPane { double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Type") + " ", SwingConstants.LEFT), type}, - new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_WF_Name") + " ", SwingConstants.LEFT), name}, + new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Type") + " ", SwingConstants.LEFT), typePane}, + new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_WF_Name") + " ", SwingConstants.LEFT), namePane}, new Component[]{checkPane, null}, }; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM); } - 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); - } /** @@ -146,14 +127,14 @@ public class SheetAuthorityEditPane extends AuthorityEditPane { * 刷新类型 */ public void populateType() { - type.setText(" " + "sheet"); + type.setText("sheet"); } /** * 更新名字 */ public void populateName() { - name.setText(" " + workBook.getReportName(selectedIndex)); + name.setText(workBook.getReportName(selectedIndex)); } /** diff --git a/designer_base/src/com/fr/design/mainframe/AuthorityEditPane.java b/designer_base/src/com/fr/design/mainframe/AuthorityEditPane.java index ce6a905433..25b5912551 100644 --- a/designer_base/src/com/fr/design/mainframe/AuthorityEditPane.java +++ b/designer_base/src/com/fr/design/mainframe/AuthorityEditPane.java @@ -1 +1 @@ -package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.TargetComponent; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.Inter; import javax.swing.*; import java.awt.*; /** * Author : daisy * Date: 13-9-12 * Time: 下午6:21 */ public abstract class AuthorityEditPane extends JPanel { protected static final int TOP_GAP = 11; protected static final int LEFT_GAP = 4; protected static final int RIGHT_GAP = 10; protected static final int ALIGNMENT_GAP = -3; protected static final int LEFT_CHECKPANE = 3; protected UILabel type = null; protected UILabel name = null; protected JPanel checkPane = null; private TargetComponent target; public AuthorityEditPane(TargetComponent target) { this.target = target; setLayout(new BorderLayout()); type = new UILabel(); type.setBorder(BorderFactory.createLineBorder(Color.lightGray)); name = new UILabel(); name.setBorder(BorderFactory.createLineBorder(Color.lightGray)); checkPane = new JPanel(); checkPane.setLayout(new BorderLayout()); // this.add(layoutText(), BorderLayout.WEST); // this.add(layoutPane(), BorderLayout.CENTER); this.add(centerPane(), BorderLayout.NORTH); this.setBorder(BorderFactory.createEmptyBorder(TOP_GAP, LEFT_GAP, 0, RIGHT_GAP)); } private JPanel centerPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; Component[][] components = new Component[][]{ new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Type") + " ", SwingConstants.LEFT), type}, new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_WF_Name") + " ", SwingConstants.LEFT), name}, new Component[]{checkPane, null}, }; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM); } /** * 更新权限编辑面板的具体内容:类型、名称、权限面板 */ public void populateDetials() { populateType(); populateName(); checkPane.removeAll(); populateCheckPane(); checkPane.setBorder(BorderFactory.createEmptyBorder(0, LEFT_CHECKPANE, 0, 0)); } public abstract void populateType(); public abstract void populateName(); public abstract JPanel populateCheckPane(); } \ No newline at end of file +package com.fr.design.mainframe; import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.TargetComponent; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.Inter; import javax.swing.*; import java.awt.*; /** * Author : daisy * Date: 13-9-12 * Time: 下午6:21 */ public abstract class AuthorityEditPane extends JPanel { protected static final int TOP_GAP = 11; protected static final int LEFT_GAP = 4; protected static final int RIGHT_GAP = 10; protected static final int ALIGNMENT_GAP = -3; protected static final int LEFT_CHECKPANE = 3; protected UILabel type = null; protected UILabel name = null; protected JPanel checkPane = null; private TargetComponent target; private JPanel typePane; private JPanel namePane; public AuthorityEditPane(TargetComponent target) { this.target = target; setLayout(new BorderLayout()); type = new UILabel(); typePane = new JPanel(new BorderLayout()); typePane.add(type, BorderLayout.CENTER); type.setBorder(BorderFactory.createEmptyBorder(0,LEFT_GAP,0,0)); typePane.setBorder(BorderFactory.createLineBorder(Color.lightGray)); name = new UILabel(); namePane = new JPanel(new BorderLayout()); namePane.add(name, BorderLayout.CENTER); name.setBorder(BorderFactory.createEmptyBorder(0,LEFT_GAP,0,0)); namePane.setBorder(BorderFactory.createLineBorder(Color.lightGray)); checkPane = new JPanel(); checkPane.setLayout(new BorderLayout()); // this.add(layoutText(), BorderLayout.WEST); // this.add(layoutPane(), BorderLayout.CENTER); this.add(centerPane(), BorderLayout.NORTH); this.setBorder(BorderFactory.createEmptyBorder(TOP_GAP, LEFT_GAP, 0, RIGHT_GAP)); } private JPanel centerPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; Component[][] components = new Component[][]{ new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Type") + " ", SwingConstants.LEFT), typePane}, new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_WF_Name") + " ", SwingConstants.LEFT), namePane}, new Component[]{checkPane, null}, }; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM); } /** * 更新权限编辑面板的具体内容:类型、名称、权限面板 */ public void populateDetials() { populateType(); populateName(); checkPane.removeAll(); populateCheckPane(); checkPane.setBorder(BorderFactory.createEmptyBorder(0, LEFT_CHECKPANE, 0, 0)); } public abstract void populateType(); public abstract void populateName(); public abstract JPanel populateCheckPane(); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index 50ca69a9e7..2e54054eaf 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -18,10 +18,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.basic.BasicSliderUI; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; +import java.awt.event.*; import java.math.BigDecimal; /** @@ -48,6 +45,8 @@ public class JSliderPane extends JPanel { private static final int SHOWVALBUTTON_WIDTH = 40; private static final int SHOWVALBUTTON_HEIGHTH = 20; private static final int SLIDER_GAP = 5; + private static final int TOOLTIP_Y = 25; + private static final Color BACK_COLOR = new Color(245, 245, 247); public int showValue = 100; public double resolutionTimes = 1.0; @@ -76,22 +75,70 @@ public class JSliderPane extends JPanel { public JSliderPane() { this.setLayout(new BorderLayout()); - slider = new UISlider(0, HUNDRED, HALF_HUNDRED); + initSlider(); + initShowValSpinner(); + initDownUpButton(); + initShowValButton(); + initUIRadioButton(); + initPane(); + JPanel panel = new JPanel(new FlowLayout(1, 5, 0)); + panel.add(downButton); + panel.add(slider); + panel.add(upButton); + panel.add(showValButton); + panel.setBackground(BACK_COLOR); + this.add(panel, BorderLayout.NORTH); + } + + + + public static final JSliderPane getInstance() { +// if (THIS == null) { +// THIS = new JSliderPane(); +// } + THIS = new JSliderPane(); + return THIS; + } + + private void initSlider() { + slider = new UISlider(0, HUNDRED, HALF_HUNDRED){ + public Point getToolTipLocation(MouseEvent event){ + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; slider.setUI(new JSliderPaneUI(slider)); slider.addChangeListener(listener); slider.setPreferredSize(new Dimension(220, 20)); //去掉虚线框 slider.setFocusable(false); slider.setToolTipText(Inter.getLocText("FR-Designer_Scale_Slider")); - showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOUR_HUNDRED, 1)); + } + + private void initShowValSpinner() { + showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOUR_HUNDRED, 1)){ + public Point getToolTipLocation(MouseEvent event){ + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; showValSpinner.setEnabled(true); showValSpinner.addChangeListener(showValSpinnerChangeListener); showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT)); - downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")); + } + + private void initDownUpButton() { + downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")){ + public Point getToolTipLocation(MouseEvent event){ + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; downButton.setOpaque(false); downButton.setBorderPainted(false); downButton.setToolTipText(Inter.getLocText("FR-Designer_Scale_Down")); - upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png")); + upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png")){ + public Point getToolTipLocation(MouseEvent event){ + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; upButton.setOpaque(false); upButton.setBorderPainted(false); upButton.setToolTipText(Inter.getLocText("FR-Designer_Scale_Up")); @@ -99,7 +146,14 @@ public class JSliderPane extends JPanel { upButton.setActionCommand("more"); downButton.addActionListener(buttonActionListener); upButton.addActionListener(buttonActionListener); - showValButton = new JButton(showValSpinner.getValue() + "%"); + } + + private void initShowValButton() { + showValButton = new JButton(showValSpinner.getValue() + "%"){ + public Point getToolTipLocation(MouseEvent event){ + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; showValButton.setOpaque(false); showValButton.setMargin(new Insets(0, 0, 0, 0)); showValButton.setFont(new Font("SimSun", Font.PLAIN, 12)); @@ -107,31 +161,7 @@ public class JSliderPane extends JPanel { showValButton.setBorderPainted(false); showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); showValButton.addActionListener(showValButtonActionListener); - //TODO 先注释,需要自定义tooltip -// showValButton.setToolTipText(Inter.getLocText("FR-Designer_Scale_Grade")); - initUIRadioButton(); - initPane(); - JPanel panel = new JPanel(new FlowLayout(1, 5, 0)); - panel.add(downButton); - panel.add(slider); - panel.add(upButton); - panel.add(showValButton); - panel.setBackground(BACK_COLOR); - this.add(panel, BorderLayout.NORTH); - } - - public JToolTip createToolTip() { - JToolTip tip = new JToolTip(); - tip.setComponent(this); - return tip; - } - - public static final JSliderPane getInstance() { -// if (THIS == null) { -// THIS = new JSliderPane(); -// } - THIS = new JSliderPane(); - return THIS; + showValButton.setToolTipText(Inter.getLocText("FR-Designer_Scale_Grade")); } private void initUIRadioButton() {