From 03a3ffe770f91258e5c8f7a2db00ce66a80ce5b9 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 22 Aug 2017 09:43:43 +0800 Subject: [PATCH 1/7] =?UTF-8?q?PFC-607=20=E6=8F=92=E4=BB=B6=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=88=A0=E9=99=A4=E6=9B=B4=E6=96=B0=E4=B8=8D=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E6=94=AF=E6=8C=81=20=E6=B7=BB=E5=8A=A0=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=89=8D=E9=A2=84=E5=A4=84=E7=90=86=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E8=BF=99=E4=B8=AA=E6=97=B6=E5=80=99=E5=81=9A=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E3=80=81=E8=87=AA=E5=8A=A8=E6=B7=BB=E5=8A=A0currentAPILevel?= =?UTF-8?q?=E7=AD=89class=E6=96=87=E4=BB=B6=E7=9A=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/fun/ExportToolBarProvider.java | 5 +++-- .../com/fr/design/chart/fun/IndependentChartUIProvider.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java b/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java index 4e53e96dd2..cfcfd2586f 100644 --- a/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java +++ b/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java @@ -1,6 +1,6 @@ package com.fr.design.fun; -import com.fr.plugin.injectable.SpecialLevel; +import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.Mutable; import javax.swing.*; @@ -8,9 +8,10 @@ import javax.swing.*; /** * 导出菜单设计器端拓展,用于控制该菜单是否在web端显示 */ +@API(level = ExportToolBarProvider.CURRENT_LEVEL) public interface ExportToolBarProvider extends Mutable{ - String XML_TAG = SpecialLevel.ExportToolBarProvider.getTagName(); + String XML_TAG = "ExportToolBarProvider"; int CURRENT_LEVEL = 1; diff --git a/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java b/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java index 290e22eaac..68efd13c78 100644 --- a/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java +++ b/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java @@ -12,8 +12,8 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; -import com.fr.plugin.injectable.SpecialLevel; import com.fr.stable.fun.Level; +import com.fr.stable.fun.mark.API; /** * Created by eason on 14/12/29. @@ -21,9 +21,10 @@ import com.fr.stable.fun.Level; * @since 8.0 * 自定义图表类型设设计界面接口 */ +@API(level = IndependentChartUIProvider.CURRENT_API_LEVEL) public interface IndependentChartUIProvider extends Level { - String XML_TAG = SpecialLevel.IndependentChartUIProvider.getTagName(); + String XML_TAG = "IndependentChartUIProvider"; int CURRENT_API_LEVEL = 3; From a8dc0b036c98acac03deb792824124cdfdcde712 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 22 Aug 2017 10:13:32 +0800 Subject: [PATCH 2/7] =?UTF-8?q?PFC-607=20=E6=8F=92=E4=BB=B6=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=88=A0=E9=99=A4=E6=9B=B4=E6=96=B0=E4=B8=8D=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E6=94=AF=E6=8C=81=20=E4=B8=8D=E5=90=88=E8=A7=84?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3=E7=B1=BB=E4=B8=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/fun/ExportToolBarProvider.java | 5 ++--- .../com/fr/design/chart/fun/IndependentChartUIProvider.java | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java b/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java index cfcfd2586f..4e53e96dd2 100644 --- a/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java +++ b/designer_base/src/com/fr/design/fun/ExportToolBarProvider.java @@ -1,6 +1,6 @@ package com.fr.design.fun; -import com.fr.stable.fun.mark.API; +import com.fr.plugin.injectable.SpecialLevel; import com.fr.stable.fun.mark.Mutable; import javax.swing.*; @@ -8,10 +8,9 @@ import javax.swing.*; /** * 导出菜单设计器端拓展,用于控制该菜单是否在web端显示 */ -@API(level = ExportToolBarProvider.CURRENT_LEVEL) public interface ExportToolBarProvider extends Mutable{ - String XML_TAG = "ExportToolBarProvider"; + String XML_TAG = SpecialLevel.ExportToolBarProvider.getTagName(); int CURRENT_LEVEL = 1; diff --git a/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java b/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java index 68efd13c78..290e22eaac 100644 --- a/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java +++ b/designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java @@ -12,8 +12,8 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.plugin.injectable.SpecialLevel; import com.fr.stable.fun.Level; -import com.fr.stable.fun.mark.API; /** * Created by eason on 14/12/29. @@ -21,10 +21,9 @@ import com.fr.stable.fun.mark.API; * @since 8.0 * 自定义图表类型设设计界面接口 */ -@API(level = IndependentChartUIProvider.CURRENT_API_LEVEL) public interface IndependentChartUIProvider extends Level { - String XML_TAG = "IndependentChartUIProvider"; + String XML_TAG = SpecialLevel.IndependentChartUIProvider.getTagName(); int CURRENT_API_LEVEL = 3; From e60a2c81c6878119109baad0911f5e04e9f4c75a Mon Sep 17 00:00:00 2001 From: MoMeak Date: Thu, 24 Aug 2017 15:50:08 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20->=E4=BF=AE=E6=94=B9=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E6=9D=A1=E6=8C=89=E9=92=AE=E4=BA=A4=E4=BA=92=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=A9=E5=B1=95=E6=8E=A7=E4=BB=B6=E4=B9=8B?= =?UTF-8?q?=E9=97=B4=E7=9A=84=E9=97=B4=E8=B7=9D=20REPORT-3986=20[9.0?= =?UTF-8?q?=E4=B8=80=E8=BD=AE=E5=9B=9E=E5=BD=92]=E5=B0=86=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E5=AE=BD=E5=BA=A6=E8=B0=83=E6=95=B4=E5=88=B0?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E4=B8=80=E5=8D=8A=E5=90=8E=E8=BF=9E=E7=BB=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A010=E4=B8=AAsheet=EF=BC=8C=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=9C=80=E5=A4=A7=E5=8C=96=E5=90=8E=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=E6=BB=91=E5=9D=97=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/ReportComponentComposite.java | 11 +- .../cell/settingpane/CellExpandAttrPane.java | 6 +- .../form/FormReportComponentComposite.java | 7 +- .../fr/design/gui/ibutton/UISliderButton.java | 375 ++++++++++++++++++ .../design/gui/ibutton/UISliderButtonUI.java | 227 +++++++++++ .../com/fr/design/gui/style/FormatPane.java | 6 +- .../fr/design/mainframe/JFormSliderPane.java | 29 +- .../com/fr/design/mainframe/JSliderPane.java | 30 +- .../design/present/dict/FormulaDictPane.java | 18 +- 9 files changed, 657 insertions(+), 52 deletions(-) create mode 100644 designer_base/src/com/fr/design/gui/ibutton/UISliderButton.java create mode 100644 designer_base/src/com/fr/design/gui/ibutton/UISliderButtonUI.java diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index 09b03c1837..41154d75b3 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -204,19 +204,14 @@ public class ReportComponentComposite extends JComponent { } private JComponent createSouthControlPane() { -// hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); -// hbarContainer.add(createSouthControlPaneWithJSliderPane()); hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar()); -// JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, hbarContainer); JPanel southPane = new JPanel(new BorderLayout()); jSliderContainer = JSliderPane.getInstance(); - JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, jSliderContainer); - splitpane.setBorder(null); - splitpane.setDividerSize(3); - splitpane.setResizeWeight(1); + southPane.add(hbarContainer, BorderLayout.NORTH); - southPane.add(splitpane, BorderLayout.CENTER); + southPane.add(sheetNameTab, BorderLayout.CENTER); + southPane.add(jSliderContainer, BorderLayout.EAST); return southPane; } diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index c7e6c93e09..4eedd4f7c5 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -85,8 +85,8 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; UILabel direction = new UILabel(Inter.getLocText("FR-Designer_ExpandD_Expand_Direction"), SwingConstants.LEFT); -// JPanel directionPane = new JPanel(new BorderLayout()); -// directionPane.add(direction, BorderLayout.NORTH); + JPanel directionPane = new JPanel(new BorderLayout()); + directionPane.add(direction, BorderLayout.NORTH); UILabel left = new UILabel(Inter.getLocText("FR-Designer_LeftParent"), SwingConstants.LEFT); JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(left, BorderLayout.NORTH); @@ -95,7 +95,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { upPane.add(up, BorderLayout.NORTH); Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{direction, expandDirectionButton}, + new Component[]{directionPane, expandDirectionButton}, new Component[]{leftPane, leftFatherPane}, new Component[]{upPane, rightFatherPane}, }; diff --git a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java index a79f64af4e..f060130f41 100644 --- a/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java @@ -169,12 +169,9 @@ public class FormReportComponentComposite extends JComponent implements TargetMo hbarContainer.add(elementCaseDesigner.getHorizontalScrollBar()); jSliderContainer = JSliderPane.getInstance(); - JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, jSliderContainer); southPane.add(hbarContainer, BorderLayout.NORTH); - southPane.add(splitpane, BorderLayout.CENTER); - splitpane.setBorder(null); - splitpane.setDividerSize(3); - splitpane.setResizeWeight(1); + southPane.add(sheetNameTab, BorderLayout.CENTER); + southPane.add(jSliderContainer, BorderLayout.EAST); return southPane; } diff --git a/designer_base/src/com/fr/design/gui/ibutton/UISliderButton.java b/designer_base/src/com/fr/design/gui/ibutton/UISliderButton.java new file mode 100644 index 0000000000..13376521ea --- /dev/null +++ b/designer_base/src/com/fr/design/gui/ibutton/UISliderButton.java @@ -0,0 +1,375 @@ +package com.fr.design.gui.ibutton; + +import com.fr.base.BaseUtils; +import com.fr.base.CellBorderStyle; +import com.fr.base.GraphHelper; +import com.fr.design.constants.UIConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.plaf.ButtonUI; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.geom.RoundRectangle2D; + +public class UISliderButton extends JButton implements UIObserver { + + public static final int OTHER_BORDER = 1; + public static final int NORMAL_BORDER = 2; + private static final int HEIGH = 20; + private static final int TOOLTIP_Y = 30; + private boolean isExtraPainted = true; + private boolean isRoundBorder = true; + private int rectDirection = Constants.NULL; + private Stroke borderStroke = UIConstants.BS; + private Color borderColor = UIConstants.LINE_COLOR; + + private boolean isPressedPainted = true; + private boolean isNormalPainted = true; + protected boolean isBorderPaintedOnlyWhenPressed = false; + + private int borderType = NORMAL_BORDER; + private CellBorderStyle border = null; + + protected UIObserverListener uiObserverListener; + + public UISliderButton() { + this(StringUtils.EMPTY); + } + + public UISliderButton(String string) { + super(string); + init(); + } + + + public UISliderButton(Icon icon) { + super(icon); + init(); + } + + public UISliderButton(Action action) { + super(action); + init(); + } + + public UISliderButton(String text, Icon icon) { + super(text, icon); + init(); + } + + /** + * 是否进行过权限编辑 + * + * @param role 角色 + * @return 否 + */ + public boolean isDoneAuthorityEdited(String role) { + return false; + } + + public UISliderButton(Icon normal, Icon rollOver, Icon pressed) { + super(normal); + setBorderPainted(false); + setRolloverIcon(rollOver); + setPressedIcon(pressed); + setExtraPainted(false); + setBackground(null); + setOpaque(false); + initListener(); + } + + protected void initListener() { + if (shouldResponseChangeListener()) { + this.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (uiObserverListener == null) { + return; + } + uiObserverListener.doChange(); + } + }); + } + } + + + //确定是正常的边框类型,还是其他的Border类型 + //若是其他的border类型,则要setOtherType,即设置线型颜色等。若是其他类型,但是没有设置,则默认的是虚线型边框 + public void setBorderType(int borderType) { + this.borderType = borderType; + } + + + public void setBorderStyle(CellBorderStyle border) { + this.border = border; + } + + public void set4ToolbarButton() { + setNormalPainted(false); + Dimension dim = getPreferredSize(); + dim.height = HEIGH; + setBackground(null); + setOpaque(false); + setSize(dim); + setBorderPaintedOnlyWhenPressed(true); + } + + public void set4LargeToolbarButton() { + setNormalPainted(false); + setBackground(null); + setOpaque(false); + setSize(new Dimension(40, 40)); + setBorderPaintedOnlyWhenPressed(true); + } + + public void set4ChartLargeToolButton() { + setNormalPainted(false); + setBackground(null); + setOpaque(false); + setSize(new Dimension(34, 44)); + setBorderPaintedOnlyWhenPressed(true); + } + + + private void init() { + setOpaque(false); + setBackground(null); + setRolloverEnabled(true); + initListener(); + } + + @Override + public ButtonUI getUI() { + return new UISliderButtonUI(); + } + + /** + * 更新界面 + */ + public void updateUI() { + setUI(getUI()); + } + + public CellBorderStyle getBorderStyle() { + return this.border; + } + + @Override + public Insets getInsets() { + if (getIcon() != null) { + return new Insets(0, 3, 0, 3); + } + return new Insets(0, 0, 0, 0); + } + + //@Override + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 20); + } + + + public int getBorderType() { + return borderType; + } + + public void setOtherBorder(Stroke s, Color c) { + borderStroke = s; + borderColor = c; + } + + + @Override + protected void paintBorder(Graphics g) { + + if (!isBorderPainted()) { + return; + } + if (borderType == OTHER_BORDER) { + paintOtherBorder(g); + } else { + boolean isPress = (isBorderPaintedOnlyWhenPressed && getModel().isPressed()); + if (isPress || !isBorderPaintedOnlyWhenPressed) { + if (ui instanceof UISliderButtonUI) { + ((UISliderButtonUI) ui).paintBorder(g, this); + + } else { + super.paintBorder(g); + + } + } + } + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Dimension size = this.getSize(); + Graphics2D g2d = (Graphics2D) g; + Stroke oldStroke = g2d.getStroke(); + if (border != null) { + g2d.setColor(border.getTopColor()); + GraphHelper.drawLine(g2d, 3, 4, size.getWidth() - 4, 4, border.getTopStyle()); + g2d.setColor(border.getLeftColor()); + GraphHelper.drawLine(g2d, 3, 4, 3, size.getHeight() - 4, border.getLeftStyle()); + g2d.setColor(border.getBottomColor()); + GraphHelper.drawLine(g2d, 3, size.getHeight() - 4, size.getWidth() - 4, size.getHeight() - 4, border.getBottomStyle()); + g2d.setColor(border.getRightColor()); + GraphHelper.drawLine(g2d, size.getWidth() - 4, 4, size.getWidth() - 4, size.getHeight() - 4, border.getRightStyle()); + } else { + GraphHelper.drawLine(g2d, 2, 4, size.getWidth() - 4, 4, Constants.LINE_NONE); + GraphHelper.drawLine(g2d, 2, 4, 2, size.getHeight() - 4, Constants.LINE_NONE); + GraphHelper.drawLine(g2d, 2, size.getHeight() - 4, size.getWidth() - 4, size.getHeight() - 4, Constants.LINE_NONE); + GraphHelper.drawLine(g2d, size.getWidth() - 4, 4, size.getWidth() - 4, size.getHeight() - 4, Constants.LINE_NONE); + } + g2d.setStroke(oldStroke); + } + + + protected void paintOtherBorder(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + g2d.setStroke(borderStroke); + Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); + g2d.setColor(borderColor); + g2d.draw(shape); + } + + public void setExtraPainted(boolean extra) { + this.isExtraPainted = extra; + } + + /** + * 是否额外画 + * + * @return 是则返回TRUE + */ + public boolean isExtraPainted() { + return this.isExtraPainted; + } + + /** + * @return + */ + public int getRectDirection() { + return rectDirection; + } + + /** + * 是否圆边框 + * + * @return 是则返回true + */ + public boolean isRoundBorder() { + return isRoundBorder; + } + + /** + * @param isRoundBorder + */ + public void setRoundBorder(boolean isRoundBorder) { + setRoundBorder(isRoundBorder, Constants.NULL); + } + + /** + * @param isRound + * @param rectDirection + */ + public void setRoundBorder(boolean isRound, int rectDirection) { + this.isRoundBorder = isRound; + this.rectDirection = rectDirection; + } + + /** + * 是否按压画 + * + * @return 是则返回TRUE + */ + public boolean isPressedPainted() { + return isPressedPainted; + } + + /** + * @param isPressedPainted + */ + public void setPressedPainted(boolean isPressedPainted) { + this.isPressedPainted = isPressedPainted; + } + + /** + * 是否正常画 + * + * @return 是则返回TRUE + */ + public boolean isNormalPainted() { + return isNormalPainted; + } + + /** + * @param isNormalPressed + */ + public void setNormalPainted(boolean isNormalPressed) { + this.isNormalPainted = isNormalPressed; + if (!isNormalPressed) { + setBackground(null); + setOpaque(false); + } + } + + /** + * @param value + */ + public void setBorderPaintedOnlyWhenPressed(boolean value) { + this.isBorderPaintedOnlyWhenPressed = value; + } + + @Override + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + + /** + * 主函数 + * + * @param args 入口参数 + */ + public static void main(String... args) { + JFrame jf = new JFrame("test"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(null); + + UISliderButton bb = new UISliderButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); + bb.setEnabled(false); + bb.setBorderType(OTHER_BORDER); + // bb.setBounds(20, 20,content.getSize().width, bb.getPreferredSize().height); + bb.setPreferredSize(new Dimension(100, 30)); + bb.setBounds(0, 0, bb.getPreferredSize().width, bb.getPreferredSize().height); + content.add(bb); + GUICoreUtils.centerWindow(jf); + jf.setSize(400, 400); + jf.setVisible(true); + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseChangeListener() { + return true; + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/ibutton/UISliderButtonUI.java b/designer_base/src/com/fr/design/gui/ibutton/UISliderButtonUI.java new file mode 100644 index 0000000000..be6f570aca --- /dev/null +++ b/designer_base/src/com/fr/design/gui/ibutton/UISliderButtonUI.java @@ -0,0 +1,227 @@ +package com.fr.design.gui.ibutton; + +import java.awt.*; +import java.awt.geom.RoundRectangle2D; + +import javax.swing.AbstractButton; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import javax.swing.plaf.basic.BasicButtonUI; +import javax.swing.plaf.basic.BasicHTML; +import javax.swing.text.View; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.UIConstants; +import com.fr.design.roleAuthority.ReportAndFSManagePane; +import com.fr.stable.Constants; +import sun.swing.SwingUtilities2; + +import com.fr.stable.StringUtils; +import com.fr.design.utils.gui.GUIPaintUtils; + +import static com.fr.design.utils.gui.GUIPaintUtils.fillPaint; + +public class UISliderButtonUI extends BasicButtonUI { + + private Rectangle viewRec = new Rectangle(); + private Rectangle textRec = new Rectangle(); + private Rectangle iconRec = new Rectangle(); + + @Override + public void paint(Graphics g, JComponent c) { + UISliderButton b = (UISliderButton) c; + Graphics2D g2d = (Graphics2D) g; + int w = b.getWidth(); + int h = b.getHeight(); + + String text = initRecAndGetText(b, SwingUtilities2.getFontMetrics(b, g), b.getWidth(), b.getHeight()); + String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); + clearTextShiftOffset(); + + ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + if (b.isExtraPainted()) { + if (isPressed(b) && b.isPressedPainted()) { + fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles)); + } else if (isRollOver(b)) { + fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted()); + } else if (b.isNormalPainted()) { + fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted()); + } + } + ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + + paintContent(g, b, text); + } + + protected boolean isRollOver(AbstractButton b) { + ButtonModel model = b.getModel(); + return model.isRollover() && !b.isSelected(); + } + + protected boolean isPressed(AbstractButton b) { + ButtonModel model = b.getModel(); + return (model.isArmed() && model.isPressed()) || b.isSelected(); + } + + private void paintContent(Graphics g, AbstractButton b, String text) { + if (b.getIcon() != null) { + paintIcon(g, b); + } + if (!StringUtils.isEmpty(text)) { + paintText(g, b, text); + } + } + + private void paintText(Graphics g, AbstractButton b, String text) { + View v = (View) b.getClientProperty(BasicHTML.propertyKey); + if (v != null) { + v.paint(g, textRec); + return; + } + FontMetrics fm = SwingUtilities2.getFontMetrics(b, g); + int mnemonicIndex = b.getDisplayedMnemonicIndex(); + if (b.isEnabled()) { + g.setColor(UIConstants.FONT_COLOR); + } else { + g.setColor(UIConstants.LINE_COLOR); + } + + SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemonicIndex, textRec.x + getTextShiftOffset(), textRec.y + fm.getAscent() + getTextShiftOffset()); + } + + private String initRecAndGetText(AbstractButton b, FontMetrics fm, int width, int height) { + Insets i = b.getInsets(); + viewRec.x = i.left; + viewRec.y = i.top; + viewRec.width = width - (i.right + viewRec.x); + viewRec.height = height - (i.bottom + viewRec.y); + textRec.x = textRec.y = textRec.width = textRec.height = 0; + iconRec.x = iconRec.y = iconRec.width = iconRec.height = 0; + // layout the text and icon + return SwingUtilities.layoutCompoundLabel( + b, fm, b.getText(), b.getIcon(), + b.getVerticalAlignment(), b.getHorizontalAlignment(), + b.getVerticalTextPosition(), b.getHorizontalTextPosition(), + viewRec, iconRec, textRec, + b.getText() == null ? 0 : b.getIconTextGap()); + } + + protected void paintBorder(Graphics g, UISliderButton b) { + String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); + GUIPaintUtils.drawBorder((Graphics2D) g, 0, 0, b.getWidth(), b.getHeight(), b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles)); + + } + + protected void paintIcon(Graphics g, JComponent c) { + AbstractButton b = (AbstractButton) c; + ButtonModel model = b.getModel(); + Icon icon = b.getIcon(); + Icon tmpIcon = null; + if (icon == null) { + return; + } + Icon selectedIcon = null; + /* the fallback icon should be based on the selected state */ + if (model.isSelected()) { + selectedIcon = (Icon) b.getSelectedIcon(); + if (selectedIcon != null) { + icon = selectedIcon; + } + } + if (!model.isEnabled()) { + if (model.isSelected()) { + tmpIcon = (Icon) b.getDisabledSelectedIcon(); + if (tmpIcon == null) { + tmpIcon = selectedIcon; + } + } + if (tmpIcon == null) { + tmpIcon = (Icon) b.getDisabledIcon(); + } + } else if (model.isPressed() && model.isArmed()) { + tmpIcon = (Icon) b.getPressedIcon(); + if (tmpIcon != null) { + // revert back to 0 offset + clearTextShiftOffset(); + } + } else if (b.isRolloverEnabled() && model.isRollover()) { + if (model.isSelected()) { + tmpIcon = (Icon) b.getRolloverSelectedIcon(); + if (tmpIcon == null) { + tmpIcon = selectedIcon; + } + } + if (tmpIcon == null) { + tmpIcon = (Icon) b.getRolloverIcon(); + } + } + if (tmpIcon != null) { + icon = tmpIcon; + } + paintModelIcon(model, icon, g, c); + } + + private void paintModelIcon(ButtonModel model, Icon icon, Graphics g, JComponent c) { + if (model.isPressed() && model.isArmed()) { + icon.paintIcon(c, g, iconRec.x + getTextShiftOffset(), + iconRec.y + getTextShiftOffset()); + } else { + icon.paintIcon(c, g, iconRec.x, iconRec.y); + } + } + + private void fillNormal(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) { + GradientPaint gp; + if (BaseUtils.isAuthorityEditing() && isAuthorityEdited) { + gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1, UIConstants.AUTHORITY_DARK_BLUE); + } else if (isPressedPainted) { + gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1, UIConstants.SELECT_TAB); + }else{ + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + } + + fillPaint(g2d, x, y, width, height, isRound, rectDirection, gp, UIConstants.ARC); + } + + private void fillRollOver(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) { + GradientPaint gp; + if (BaseUtils.isAuthorityEditing() && isAuthorityEdited) { + gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1, UIConstants.HOVER_BLUE); + } else if (isPressedPainted) { + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + }else { + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + } + fillPaint(g2d, x, y, width, height, isRound, rectDirection, gp, UIConstants.ARC); + } + + private void fillPressed(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited) { + Color oldColor = g2d.getColor(); + if (BaseUtils.isAuthorityEditing() && isAuthorityEdited) { + g2d.setColor(UIConstants.AUTHORITY_PRESS_BLUE); + } else { + g2d.setColor(UIConstants.POP_DIALOG_BORDER); + } + Shape oldClip = g2d.getClip(); + if (isRound) { + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.clip(new RoundRectangle2D.Double(x, y, width, height, UIConstants.ARC, UIConstants.ARC)); + g2d.fillRoundRect(x, y, width, height, UIConstants.ARC, UIConstants.ARC); + g2d.setClip(oldClip); + if (rectDirection == Constants.RIGHT) { + g2d.fillRect(width - 2, y, x + 2, height); + } else if (rectDirection == Constants.LEFT) { + g2d.fillRect(x, y, x + 2, height); + } + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + } else { + g2d.clip(new Rectangle(x, y, width, height)); + g2d.fillRect(0, 0, width, height); + g2d.setClip(oldClip); + } + + g2d.setColor(oldColor); + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/style/FormatPane.java b/designer_base/src/com/fr/design/gui/style/FormatPane.java index 23b6e213f9..58efc7f1ee 100644 --- a/designer_base/src/com/fr/design/gui/style/FormatPane.java +++ b/designer_base/src/com/fr/design/gui/style/FormatPane.java @@ -109,7 +109,7 @@ public class FormatPane extends AbstractBasicStylePane { JPanel typePane = new JPanel(new BorderLayout()); typePane.add(typeComboBox, BorderLayout.CENTER); typePane.setBorder(LEFT_BORDER); - centerPane.setBorder(LEFT_BORDER); +// centerPane.setBorder(LEFT_BORDER); frFontPane.setBorder(LEFT_BORDER); Component[][] components = getComponent(fontPane, centerPane, typePane); @@ -125,7 +125,7 @@ public class FormatPane extends AbstractBasicStylePane { return new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(Inter.getLocText("FR-Base_Format"), SwingConstants.LEFT), typePane}, - new Component[]{null, centerPane}, + new Component[]{centerPane, null}, new Component[]{fontPane, frFontPane}, }; } @@ -248,7 +248,7 @@ public class FormatPane extends AbstractBasicStylePane { this.typeComboBox.setSelectedItem(formatStyle); int i = isArrayContainPattern(FormatField.getInstance().getFormatArray(formatStyle), pattern); if (i == -1) { - this.textField.setSelectedIndex(0); + this.textField.setSelectedItem(pattern); } else { this.textField.setSelectedIndex(i); } diff --git a/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java b/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java index c796baa6ce..347bed6859 100644 --- a/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ibutton.UISliderButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.islider.UISlider; import com.fr.design.gui.ispinner.UIBasicSpinner; @@ -46,7 +47,7 @@ public class JFormSliderPane 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 int TOOLTIP_Y = 30; private static final Color BACK_COLOR = new Color(245, 245, 247); public int showValue = 100; public double resolutionTimes = 1.0; @@ -58,7 +59,7 @@ public class JFormSliderPane extends JPanel { private int sliderValue; private UIButton downButton; private UIButton upButton; - private JButton showValButton; + private UISliderButton showValButton; private UIRadioButton twoHundredButton; private UIRadioButton oneHundredButton; private UIRadioButton SevenFiveButton; @@ -156,14 +157,7 @@ public class JFormSliderPane extends JPanel { } 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)); + showValButton = new UISliderButton(showValSpinner.getValue() + "%"); showValButton.setBackground(BACK_COLOR); showValButton.setBorderPainted(false); showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); @@ -185,8 +179,17 @@ public class JFormSliderPane extends JPanel { SevenFiveButton.addItemListener(radioButtonItemListener); fiveTenButton.addItemListener(radioButtonItemListener); twoFiveButton.addItemListener(radioButtonItemListener); - //TODO -// selfAdaptButton.addItemListener(); + customButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.requestFocus(); + textField.selectAll(); + } + } + }); ButtonGroup bg = new ButtonGroup();// 初始化按钮组 bg.add(twoHundredButton);// 加入按钮组 @@ -267,6 +270,8 @@ public class JFormSliderPane extends JPanel { } refreshSlider(val); refreshBottun(val); + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.setCaretPosition(showValSpinner.getValue().toString().length()); } }; diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index 006a38ce40..dd0e0f7d9e 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ibutton.UISliderButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.islider.UISlider; import com.fr.design.gui.ispinner.UIBasicSpinner; @@ -17,6 +18,7 @@ import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.basic.BasicSliderUI; +import javax.swing.text.BadLocationException; import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.NumberFormatter; import java.awt.*; @@ -47,7 +49,7 @@ 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 int TOOLTIP_Y = 30; private static final Color BACK_COLOR = new Color(245, 245, 247); public int showValue = 100; @@ -60,7 +62,7 @@ public class JSliderPane extends JPanel { private int sliderValue; private UIButton downButton; private UIButton upButton; - private JButton showValButton; + private UISliderButton showValButton; private UIRadioButton twoHundredButton; private UIRadioButton oneHundredButton; private UIRadioButton SevenFiveButton; @@ -159,14 +161,7 @@ public class JSliderPane extends JPanel { } 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)); + showValButton = new UISliderButton(showValSpinner.getValue() + "%"); showValButton.setBackground(BACK_COLOR); showValButton.setBorderPainted(false); showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); @@ -189,8 +184,17 @@ public class JSliderPane extends JPanel { SevenFiveButton.addItemListener(radioButtonItemListener); fiveTenButton.addItemListener(radioButtonItemListener); twoFiveButton.addItemListener(radioButtonItemListener); - //TODO -// selfAdaptButton.addItemListener(); + customButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.requestFocus(); + textField.selectAll(); + } + } + }); ButtonGroup bg = new ButtonGroup();// 初始化按钮组 bg.add(twoHundredButton);// 加入按钮组 @@ -272,6 +276,8 @@ public class JSliderPane extends JPanel { } refreshSlider(val); refreshBottun(val); + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.setCaretPosition(showValSpinner.getValue().toString().length()); } }; diff --git a/designer_base/src/com/fr/design/present/dict/FormulaDictPane.java b/designer_base/src/com/fr/design/present/dict/FormulaDictPane.java index 3abd31dd8a..22d735ad86 100644 --- a/designer_base/src/com/fr/design/present/dict/FormulaDictPane.java +++ b/designer_base/src/com/fr/design/present/dict/FormulaDictPane.java @@ -29,14 +29,14 @@ public class FormulaDictPane extends FurtherBasicBeanPane { } public static void main(String[] args) { - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(new BorderLayout()); - content.add(new FormulaDictPane(), BorderLayout.NORTH); - GUICoreUtils.centerWindow(jf); - jf.setSize(250, 400); - jf.setVisible(true); +// JFrame jf = new JFrame("test"); +// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); +// JPanel content = (JPanel) jf.getContentPane(); +// content.setLayout(new BorderLayout()); +// content.add(new FormulaDictPane(), BorderLayout.NORTH); +// GUICoreUtils.centerWindow(jf); +// jf.setSize(250, 400); +// jf.setVisible(true); } private void initComponents() { @@ -59,7 +59,7 @@ public class FormulaDictPane extends FurtherBasicBeanPane { int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; UILabel tag = new UILabel(Inter.getLocText("Formula_Dictionary_Display_Examples_Html")); - tag.setPreferredSize(new Dimension(225, 40)); + tag.setPreferredSize(new Dimension(225, 80)); JPanel t = new JPanel(new BorderLayout()); t.add(tag, BorderLayout.CENTER); From d145f7facb4ed697716f7cc7b8a311f4e4a8184e Mon Sep 17 00:00:00 2001 From: MoMeak Date: Thu, 24 Aug 2017 17:01:12 +0800 Subject: [PATCH 4/7] PMD --- .../src/com/fr/design/gui/ibutton/UISliderButton.java | 6 ++---- .../com/fr/design/present/dict/FormulaDictPane.java | 11 ----------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/ibutton/UISliderButton.java b/designer_base/src/com/fr/design/gui/ibutton/UISliderButton.java index 13376521ea..21c5ee4b98 100644 --- a/designer_base/src/com/fr/design/gui/ibutton/UISliderButton.java +++ b/designer_base/src/com/fr/design/gui/ibutton/UISliderButton.java @@ -44,14 +44,12 @@ public class UISliderButton extends JButton implements UIObserver { } public UISliderButton(String string) { - super(string); - init(); + this(string, null); } public UISliderButton(Icon icon) { - super(icon); - init(); + this(null, icon); } public UISliderButton(Action action) { diff --git a/designer_base/src/com/fr/design/present/dict/FormulaDictPane.java b/designer_base/src/com/fr/design/present/dict/FormulaDictPane.java index 22d735ad86..6a3130a9c0 100644 --- a/designer_base/src/com/fr/design/present/dict/FormulaDictPane.java +++ b/designer_base/src/com/fr/design/present/dict/FormulaDictPane.java @@ -28,17 +28,6 @@ public class FormulaDictPane extends FurtherBasicBeanPane { initComponents(); } - public static void main(String[] args) { -// JFrame jf = new JFrame("test"); -// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); -// JPanel content = (JPanel) jf.getContentPane(); -// content.setLayout(new BorderLayout()); -// content.add(new FormulaDictPane(), BorderLayout.NORTH); -// GUICoreUtils.centerWindow(jf); -// jf.setSize(250, 400); -// jf.setVisible(true); - } - private void initComponents() { keyFormulaEditor = new FormulaEditor(); keyFormulaEditor.setColumns(EDITOR_COLUMN); From f86bc5a8f3a74fd8c0bb32e6f3aa42e39bc26145 Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 18:04:35 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=97=A7=E6=A8=A1=E6=9D=BF=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A8=A1=E6=9D=BF=E6=97=B6=E5=80=99=E5=8A=A0ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/JTemplate.java | 10 ++++++++++ .../com/fr/design/parameter/RootDesignDefinePane.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index aa42804dbb..4f9c7a2056 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -1055,4 +1055,14 @@ public abstract class JTemplate> ex return uiButtons; } + + /** + * 由于老版本的模板没有模板ID,当勾选使用参数模板时候,就加一个模板ID + * @param isUseParamTemplate 是否使用参数模板 + */ + public void needAddTemplateId(boolean isUseParamTemplate) { + if (isUseParamTemplate && StringUtils.isEmpty(template.getTemplateID())) { + template.initTemplateID(); + } + } } diff --git a/designer_form/src/com/fr/design/parameter/RootDesignDefinePane.java b/designer_form/src/com/fr/design/parameter/RootDesignDefinePane.java index ac265cc200..85b84588bf 100644 --- a/designer_form/src/com/fr/design/parameter/RootDesignDefinePane.java +++ b/designer_form/src/com/fr/design/parameter/RootDesignDefinePane.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.data.DataCreatorUI; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; @@ -13,6 +14,7 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor; import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.form.ui.container.WParameterLayout; @@ -124,6 +126,8 @@ public class RootDesignDefinePane extends AbstractDataModify { wParameterLayout.setDesignWidth((int) designerWidth.getValue()); wParameterLayout.setDelayDisplayContent(displayReport.isSelected()); wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected()); + JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + jTemplate.needAddTemplateId(useParamsTemplate.isSelected()); wParameterLayout.setBackground((Background) background.getValue()); wParameterLayout.setPosition(hAlignmentPane.getSelectedIndex()); return wParameterLayout; From bbff7976c70a74f1c694408270e5c169a089aa94 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Thu, 24 Aug 2017 18:34:00 +0800 Subject: [PATCH 6/7] =?UTF-8?q?PFC-607=20=E6=8F=92=E4=BB=B6=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=88=A0=E9=99=A4=E6=9B=B4=E6=96=B0=E4=B8=8D=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E6=94=AF=E6=8C=81=20=E6=94=BE=E5=BC=83=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E4=BB=A3=E7=90=86=EF=BC=8C=E7=94=A8javassist=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=9B=B8=E5=90=8C=E5=8A=9F=E8=83=BD:=201=E3=80=81?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=BB=A3=E7=90=86=E4=B8=8D=E8=83=BD=E4=BD=9C?= =?UTF-8?q?=E7=94=A8=E5=88=B0=E6=B2=A1=E6=8E=A5=E5=8F=A3=E7=9A=84class?= =?UTF-8?q?=E4=B8=8A=202=E3=80=81=E5=8A=A8=E6=80=81=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E4=BA=86class=E7=9A=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E5=BC=80=E5=8F=91=E5=92=8C=E8=B0=83=E8=AF=95=E9=83=BD?= =?UTF-8?q?=E4=B8=8D=E5=A4=AA=E6=96=B9=E4=BE=BF=203=E3=80=81=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E4=BB=A3=E7=90=86=E5=BD=B1=E5=93=8D=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ExtraDesignClassManager.java | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index 54fbcf2f10..fe11379c48 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -6,7 +6,13 @@ package com.fr.design; import com.fr.base.BaseUtils; import com.fr.design.data.datapane.TableDataNameObjectCreator; -import com.fr.design.fun.*; +import com.fr.design.fun.CellWidgetOptionProvider; +import com.fr.design.fun.Feedback; +import com.fr.design.fun.FormWidgetOptionProvider; +import com.fr.design.fun.ParameterWidgetOptionProvider; +import com.fr.design.fun.ServerTableDataDefineProvider; +import com.fr.design.fun.TableDataDefineProvider; +import com.fr.design.fun.ToolbarItemProvider; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOptionFactory; import com.fr.design.menu.ShortCut; @@ -16,13 +22,19 @@ import com.fr.general.FRLogger; import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; import com.fr.plugin.AbstractExtraClassManager; -import com.fr.plugin.solution.closeable.CompatibleInjectionContainer; import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginSingleInjection; +import com.fr.plugin.solution.closeable.CloseableContainedSet; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraDesignClassManagerProvider; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * @author : richie @@ -33,7 +45,7 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement private static ExtraDesignClassManager classManager = new ExtraDesignClassManager(); - private CompatibleInjectionContainer shortCuts = new CompatibleInjectionContainer<>(); + private Set shortCuts = new CloseableContainedSet<>(HashSet.class); public synchronized static ExtraDesignClassManager getInstance() { return classManager; @@ -204,8 +216,8 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement @Override protected boolean demountSpecific(PluginSingleInjection injection) { - - if (ShortCut.TEMPLATE_TREE.equals(injection.getName()) && injection.getOriginalObject() instanceof ShortCut) { + + if (ShortCut.TEMPLATE_TREE.equals(injection.getName()) && injection.getObject() instanceof ShortCut) { shortCuts.remove(injection.getObject()); return true; } @@ -214,16 +226,16 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement @Override protected boolean mountSpecific(PluginSingleInjection injection) { - - if (ShortCut.TEMPLATE_TREE.equals(injection.getName()) && injection.getOriginalObject() instanceof ShortCut) { - shortCuts.put(injection.getObject(), (ShortCut) injection.getOriginalObject()); + + if (ShortCut.TEMPLATE_TREE.equals(injection.getName()) && injection.getObject() instanceof ShortCut) { + shortCuts.add((ShortCut) injection.getObject()); return true; } return false; } public Set getExtraShortCuts() { - - return shortCuts.getSet(); + + return Collections.unmodifiableSet(shortCuts); } } \ No newline at end of file From 93ef5715963c2cfe62ff41a2f3edfef9d67f6b50 Mon Sep 17 00:00:00 2001 From: loy Date: Fri, 25 Aug 2017 14:44:11 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=A1=AB=E6=8A=A5=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=96=B9=E5=BC=8F=E6=94=B9=E4=B8=BAop=3Dwrit?= =?UTF-8?q?e=5Fplus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/preview/WriteEnhancePreview.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/preview/WriteEnhancePreview.java b/designer_base/src/com/fr/design/preview/WriteEnhancePreview.java index 71705e9634..8dc18b57d7 100644 --- a/designer_base/src/com/fr/design/preview/WriteEnhancePreview.java +++ b/designer_base/src/com/fr/design/preview/WriteEnhancePreview.java @@ -28,13 +28,13 @@ public class WriteEnhancePreview extends AbstractPreviewProvider { @Override public int previewTypeCode() { - return IOFile.WRITE_PREVIEW_TYPE; + return IOFile.WRITE_ENHANCE_PREVIEW_TYPE; } @Override public Map parametersForPreview() { Map map = new HashMap(); - map.put("op", "write_ex"); + map.put("op", "write_plus"); return map; } }