From f2b67d482dc38b3a134b2d60a6580cf237168bac Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 14:40:21 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E6=97=A0=E4=BB=BB=E5=8A=A1=EF=BC=8Cslide?= =?UTF-8?q?r=E5=92=8Cquickeditor=E7=9A=84=E5=86=85=E5=AD=98=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/core/ActionFactory.java | 14 + .../fr/design/file/MutilTempalteTabPane.java | 15 +- .../fr/design/mainframe/DesignerFrame.java | 45 ++- .../fr/design/mainframe/JFormSliderPane.java | 80 +++-- .../com/fr/design/mainframe/JSliderPane.java | 73 +++-- .../com/fr/design/selection/QuickEditor.java | 9 +- .../design/mainframe/WidgetToolBarPane.java | 18 +- .../fr/design/dscolumn/DSColumnBasicPane.java | 55 ++-- .../SelectedConfirmedDataColumnPane.java | 7 +- .../dscolumn/SelectedDataColumnPane.java | 175 ++++++++--- .../fr/design/mainframe/ElementCasePane.java | 2 + .../mainframe/ReportComponentComposite.java | 5 +- .../cell/AbstractDSCellEditorPane.java | 5 + .../com/fr/design/module/DesignerModule.java | 32 +- .../com/fr/grid/selection/CellSelection.java | 60 ++-- .../com/fr/grid/selection/FloatSelection.java | 17 +- .../com/fr/quickeditor/FloatQuickEditor.java | 28 +- .../cellquick/CellDSColumnEditor.java | 283 ++++++++++++------ .../cellquick/CellRichTextEditor.java | 7 +- .../cellquick/CellStringQuickEditor.java | 2 - .../cellquick/CellSubReportEditor.java | 6 + .../floatquick/FloatImageQuickEditor.java | 8 +- .../floatquick/FloatStringQuickEditor.java | 66 ++-- 23 files changed, 661 insertions(+), 351 deletions(-) diff --git a/designer-base/src/com/fr/design/actions/core/ActionFactory.java b/designer-base/src/com/fr/design/actions/core/ActionFactory.java index 7bc73acbb..e48caa0ac 100644 --- a/designer-base/src/com/fr/design/actions/core/ActionFactory.java +++ b/designer-base/src/com/fr/design/actions/core/ActionFactory.java @@ -55,6 +55,20 @@ public class ActionFactory { private ActionFactory() { } + + /** + * 元素编辑器释放模板对象 + */ + public static void editorRelease() { + for (Map.Entry entry : cellEditor.entrySet()) { + entry.getValue().release(); + } + for (Map.Entry entry : floatEditor.entrySet()) { + entry.getValue().release(); + } + } + + /** * 注册无需每次实例化的单元格元素编辑器 * diff --git a/designer-base/src/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/com/fr/design/file/MutilTempalteTabPane.java index 5a05f20d2..24aa39693 100644 --- a/designer-base/src/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/com/fr/design/file/MutilTempalteTabPane.java @@ -711,21 +711,10 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FRLogger.getLogger().log(Level.INFO, Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{specifiedTemplate.getEditingFILE().getName(), "."})); - HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); - activeTemplate(filename); - } else if (returnVal == JOptionPane.NO_OPTION) { - //不保存 - HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); - activeTemplate(filename); } - //若是点击取消关闭,则什么都不做 - } else { - //若是已经保存过了,则关闭即可 - HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); - activeTemplate(filename); } - - + HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); + activeTemplate(filename); } /** diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index 41d755905..c85565c15 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -10,12 +10,17 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.actions.core.ActionFactory; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; -import com.fr.design.file.*; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.file.NewTemplatePane; +import com.fr.design.file.SaveSomeTemplatePane; +import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIMenuHighLight; @@ -49,13 +54,39 @@ import com.fr.stable.StableUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.project.ProjectConstants; -import javax.swing.*; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLayeredPane; +import javax.swing.JMenuBar; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.WindowConstants; import javax.swing.border.MatteBorder; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; -import java.awt.dnd.*; -import java.awt.event.*; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -734,6 +765,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param jt 添加的模板. */ public void addAndActivateJTemplate(JTemplate jt) { + //释放模板对象 + ActionFactory.editorRelease(); if (jt == null || jt.getEditingFILE() == null) { return; } @@ -750,6 +783,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param jt 模板 */ public void activateJTemplate(JTemplate jt) { + //释放模板对象 + ActionFactory.editorRelease(); if (jt == null || jt.getEditingFILE() == null) { return; } diff --git a/designer-base/src/com/fr/design/mainframe/JFormSliderPane.java b/designer-base/src/com/fr/design/mainframe/JFormSliderPane.java index 81a916637..8a0ad05a4 100644 --- a/designer-base/src/com/fr/design/mainframe/JFormSliderPane.java +++ b/designer-base/src/com/fr/design/mainframe/JFormSliderPane.java @@ -14,13 +14,33 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JRadioButton; +import javax.swing.JSeparator; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.NumberFormatter; -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; import java.math.BigDecimal; /** @@ -51,7 +71,6 @@ public class JFormSliderPane extends JPanel { private static final Color BACK_COLOR = new Color(245, 245, 247); public int showValue = 100; public double resolutionTimes = 1.0; - private static JFormSliderPane THIS; private UITextField showVal; private JSpinner showValSpinner; private UISlider slider; @@ -62,7 +81,7 @@ public class JFormSliderPane extends JPanel { private UISliderButton showValButton; private UIRadioButton twoHundredButton; private UIRadioButton oneHundredButton; - private UIRadioButton SevenFiveButton; + private UIRadioButton sevenFiveButton; private UIRadioButton fiveTenButton; private UIRadioButton twoFiveButton; private UIRadioButton selfAdaptButton; @@ -83,7 +102,7 @@ public class JFormSliderPane extends JPanel { showValSpinner.setEditor(editor); JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); textField.setEditable(true); - DefaultFormatterFactory factory = (DefaultFormatterFactory) textField .getFormatterFactory(); + DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory(); NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); formatter.setAllowsInvalid(false); @@ -91,7 +110,7 @@ public class JFormSliderPane extends JPanel { initShowValButton(); initUIRadioButton(); initPane(); - JPanel panel = new JPanel(new FlowLayout(1, 0, 0)); + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); panel.add(downButton); panel.add(slider); panel.add(upButton); @@ -100,17 +119,13 @@ public class JFormSliderPane extends JPanel { this.add(panel, BorderLayout.NORTH); } - public static final JFormSliderPane getInstance() { -// if (THIS == null) { -// THIS = new JSliderPane(); -// } - THIS = new JFormSliderPane(); - return THIS; + public static JFormSliderPane getInstance() { + return new JFormSliderPane(); } private void initSlider() { - slider = new UISlider(0, HUNDRED, HALF_HUNDRED){ - public Point getToolTipLocation(MouseEvent event){ + slider = new UISlider(0, HUNDRED, HALF_HUNDRED) { + public Point getToolTipLocation(MouseEvent event) { return new Point(event.getX(), event.getY() - TOOLTIP_Y); } }; @@ -123,8 +138,8 @@ public class JFormSliderPane extends JPanel { } private void initShowValSpinner() { - showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)){ - public Point getToolTipLocation(MouseEvent event){ + showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)) { + public Point getToolTipLocation(MouseEvent event) { return new Point(event.getX(), event.getY() - TOOLTIP_Y); } }; @@ -134,16 +149,16 @@ public class JFormSliderPane extends JPanel { } 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){ + 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")){ - public Point getToolTipLocation(MouseEvent event){ + 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); } }; @@ -164,10 +179,11 @@ public class JFormSliderPane extends JPanel { showValButton.addActionListener(showValButtonActionListener); showValButton.setToolTipText(Inter.getLocText("FR-Designer_Scale_Grade")); } + private void initUIRadioButton() { twoHundredButton = new UIRadioButton("200%"); oneHundredButton = new UIRadioButton("100%"); - SevenFiveButton = new UIRadioButton("75%"); + sevenFiveButton = new UIRadioButton("75%"); fiveTenButton = new UIRadioButton("50%"); twoFiveButton = new UIRadioButton("25%"); selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton")); @@ -176,7 +192,7 @@ public class JFormSliderPane extends JPanel { customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); twoHundredButton.addItemListener(radioButtonItemListener); oneHundredButton.addItemListener(radioButtonItemListener); - SevenFiveButton.addItemListener(radioButtonItemListener); + sevenFiveButton.addItemListener(radioButtonItemListener); fiveTenButton.addItemListener(radioButtonItemListener); twoFiveButton.addItemListener(radioButtonItemListener); customButton.addItemListener(new ItemListener() { @@ -194,7 +210,7 @@ public class JFormSliderPane extends JPanel { ButtonGroup bg = new ButtonGroup();// 初始化按钮组 bg.add(twoHundredButton);// 加入按钮组 bg.add(oneHundredButton); - bg.add(SevenFiveButton); + bg.add(sevenFiveButton); bg.add(fiveTenButton); bg.add(twoFiveButton); bg.add(selfAdaptButton); @@ -217,7 +233,7 @@ public class JFormSliderPane extends JPanel { septPane.setBackground(BACK_COLOR); twoHundredButton.setBackground(BACK_COLOR); oneHundredButton.setBackground(BACK_COLOR); - SevenFiveButton.setBackground(BACK_COLOR); + sevenFiveButton.setBackground(BACK_COLOR); fiveTenButton.setBackground(BACK_COLOR); twoFiveButton.setBackground(BACK_COLOR); // selfAdaptButton.setBackground(BACK_COLOR); @@ -227,7 +243,7 @@ public class JFormSliderPane extends JPanel { new Component[]{septPane, null}, new Component[]{twoHundredButton, null}, new Component[]{oneHundredButton, null}, - new Component[]{SevenFiveButton, null}, + new Component[]{sevenFiveButton, null}, new Component[]{fiveTenButton, null}, new Component[]{twoFiveButton, null}, new Component[]{customButton, createSpinnerPanel()} @@ -247,14 +263,14 @@ public class JFormSliderPane extends JPanel { return spinnerPanel; } - ActionListener showValButtonActionListener = new ActionListener() { + private ActionListener showValButtonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupDialog(); } }; - ChangeListener showValSpinnerChangeListener = new ChangeListener() { + private ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); @@ -277,7 +293,7 @@ public class JFormSliderPane extends JPanel { //定义一个监听器,用于监听所有滑动条 - ChangeListener listener = new ChangeListener() { + private ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 if (!isButtonOrIsTxt) { @@ -296,7 +312,7 @@ public class JFormSliderPane extends JPanel { } }; - ItemListener radioButtonItemListener = new ItemListener() { + private ItemListener radioButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { JRadioButton temp = (JRadioButton) e.getSource(); @@ -312,7 +328,7 @@ public class JFormSliderPane extends JPanel { slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); } else if (showValue < HUNDRED) { slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); - } else if (showValue == HUNDRED) { + } else { slider.setValue(HALF_HUNDRED); } } @@ -336,7 +352,7 @@ public class JFormSliderPane extends JPanel { return b1.divide(b2, scale).doubleValue(); } - ActionListener buttonActionListener = new ActionListener() { + private ActionListener buttonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showValue = (int) showValSpinner.getValue(); diff --git a/designer-base/src/com/fr/design/mainframe/JSliderPane.java b/designer-base/src/com/fr/design/mainframe/JSliderPane.java index c2f4da0e7..83edb560a 100644 --- a/designer-base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer-base/src/com/fr/design/mainframe/JSliderPane.java @@ -15,13 +15,34 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JRadioButton; +import javax.swing.JSeparator; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.basic.BasicSliderUI; import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.NumberFormatter; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -59,7 +80,6 @@ public class JSliderPane extends JPanel { private static final Color BACK_COLOR = new Color(245, 245, 247); public int showValue = 100; public double resolutionTimes = 1.0; - private static JSliderPane THIS; private UITextField showVal; private JSpinner showValSpinner; private UISlider slider; @@ -70,12 +90,14 @@ public class JSliderPane extends JPanel { private UISliderButton showValButton; private UIRadioButton twoHundredButton; private UIRadioButton oneHundredButton; - private UIRadioButton SevenFiveButton; + private UIRadioButton sevenFiveButton; private UIRadioButton fiveTenButton; private UIRadioButton twoFiveButton; private UIRadioButton selfAdaptButton; private UIRadioButton customButton; - //拖动条处理和button、直接输入不一样 + /** + * 拖动条处理和button、直接输入不一样 + */ private boolean isButtonOrIsTxt = true; private PopupPane dialog; private int upButtonX; @@ -91,7 +113,7 @@ public class JSliderPane extends JPanel { showValSpinner.setEditor(editor); JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); textField.setEditable(true); - DefaultFormatterFactory factory = (DefaultFormatterFactory) textField .getFormatterFactory(); + DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory(); NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); formatter.setAllowsInvalid(false); @@ -99,7 +121,7 @@ public class JSliderPane extends JPanel { initShowValButton(); initUIRadioButton(); initPane(); - JPanel panel = new JPanel(new FlowLayout(1, 0, 0)); + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); panel.add(downButton); panel.add(slider); panel.add(upButton); @@ -109,12 +131,8 @@ public class JSliderPane extends JPanel { } - public static final JSliderPane getInstance() { -// if (THIS == null) { -// THIS = new JSliderPane(); -// } - THIS = new JSliderPane(); - return THIS; + public static JSliderPane getInstance() { + return new JSliderPane(); } private void initSlider() { @@ -178,7 +196,7 @@ public class JSliderPane extends JPanel { private void initUIRadioButton() { twoHundredButton = new UIRadioButton("200%"); oneHundredButton = new UIRadioButton("100%"); - SevenFiveButton = new UIRadioButton("75%"); + sevenFiveButton = new UIRadioButton("75%"); fiveTenButton = new UIRadioButton("50%"); twoFiveButton = new UIRadioButton("25%"); selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton")); @@ -187,7 +205,7 @@ public class JSliderPane extends JPanel { customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); twoHundredButton.addItemListener(radioButtonItemListener); oneHundredButton.addItemListener(radioButtonItemListener); - SevenFiveButton.addItemListener(radioButtonItemListener); + sevenFiveButton.addItemListener(radioButtonItemListener); fiveTenButton.addItemListener(radioButtonItemListener); twoFiveButton.addItemListener(radioButtonItemListener); customButton.addItemListener(new ItemListener() { @@ -205,7 +223,7 @@ public class JSliderPane extends JPanel { ButtonGroup bg = new ButtonGroup();// 初始化按钮组 bg.add(twoHundredButton);// 加入按钮组 bg.add(oneHundredButton); - bg.add(SevenFiveButton); + bg.add(sevenFiveButton); bg.add(fiveTenButton); bg.add(twoFiveButton); bg.add(selfAdaptButton); @@ -228,7 +246,7 @@ public class JSliderPane extends JPanel { septPane.setBackground(BACK_COLOR); twoHundredButton.setBackground(BACK_COLOR); oneHundredButton.setBackground(BACK_COLOR); - SevenFiveButton.setBackground(BACK_COLOR); + sevenFiveButton.setBackground(BACK_COLOR); fiveTenButton.setBackground(BACK_COLOR); twoFiveButton.setBackground(BACK_COLOR); selfAdaptButton.setBackground(BACK_COLOR); @@ -238,7 +256,7 @@ public class JSliderPane extends JPanel { new Component[]{septPane, null}, new Component[]{twoHundredButton, null}, new Component[]{oneHundredButton, null}, - new Component[]{SevenFiveButton, null}, + new Component[]{sevenFiveButton, null}, new Component[]{fiveTenButton, null}, new Component[]{twoFiveButton, null}, new Component[]{selfAdaptButton, null}, @@ -259,14 +277,14 @@ public class JSliderPane extends JPanel { return spinnerPanel; } - ActionListener showValButtonActionListener = new ActionListener() { + private ActionListener showValButtonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupDialog(); } }; - ChangeListener showValSpinnerChangeListener = new ChangeListener() { + private ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); @@ -289,7 +307,7 @@ public class JSliderPane extends JPanel { //定义一个监听器,用于监听所有滑动条 - ChangeListener listener = new ChangeListener() { + private ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 if (!isButtonOrIsTxt) { @@ -309,7 +327,7 @@ public class JSliderPane extends JPanel { } }; - ItemListener radioButtonItemListener = new ItemListener() { + private ItemListener radioButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { JRadioButton temp = (JRadioButton) e.getSource(); @@ -325,7 +343,7 @@ public class JSliderPane extends JPanel { slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); } else if (showValue < HUNDRED) { slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); - } else if (showValue == HUNDRED) { + } else { slider.setValue(HALF_HUNDRED); } } @@ -343,7 +361,7 @@ public class JSliderPane extends JPanel { return this.showValue; } - public void reset(){ + public void reset() { this.showValSpinner.setValue(HUNDRED); } @@ -353,7 +371,7 @@ public class JSliderPane extends JPanel { return b1.divide(b2, scale).doubleValue(); } - ActionListener buttonActionListener = new ActionListener() { + private ActionListener buttonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showValue = (int) showValSpinner.getValue(); @@ -390,7 +408,7 @@ public class JSliderPane extends JPanel { } else if (value < HALF_HUNDRED) { times = (int) Math.round(ONEPOINTEIGHT * value + TEN); } else { - times = (int) (SIX * value - TWO_HUNDRED); + times = SIX * value - TWO_HUNDRED; } } @@ -448,11 +466,9 @@ class JSliderPaneUI extends BasicSliderUI { super(b); } - /** */ /** * 绘制指示物 */ - public void paintThumb(Graphics g) { Rectangle knobBounds = thumbRect; Graphics2D g2d = (Graphics2D) g; @@ -460,7 +476,6 @@ class JSliderPaneUI extends BasicSliderUI { g2d.dispose(); } - /** */ /** * 绘制刻度轨迹 */ diff --git a/designer-base/src/com/fr/design/selection/QuickEditor.java b/designer-base/src/com/fr/design/selection/QuickEditor.java index 5220bc719..de19d64f8 100644 --- a/designer-base/src/com/fr/design/selection/QuickEditor.java +++ b/designer-base/src/com/fr/design/selection/QuickEditor.java @@ -2,7 +2,7 @@ package com.fr.design.selection; import com.fr.design.designer.TargetComponent; -import javax.swing.*; +import javax.swing.JComponent; /** * 快速编辑区域 @@ -39,11 +39,15 @@ public abstract class QuickEditor extends JComponent tc.fireTargetModified(); } + /** + * 刷新面板 + */ protected abstract void refresh(); /** - * for 关闭时候释放 + * 关闭模板时释放模板对象 + * 所有持有tc的对象也必须置空或者丢弃对于tc的引用 */ public void release() { tc = null; @@ -53,7 +57,6 @@ public abstract class QuickEditor extends JComponent @Override protected void refresh() { - } }; diff --git a/designer-form/src/com/fr/design/mainframe/WidgetToolBarPane.java b/designer-form/src/com/fr/design/mainframe/WidgetToolBarPane.java index 80b7abfe4..5599bfe16 100644 --- a/designer-form/src/com/fr/design/mainframe/WidgetToolBarPane.java +++ b/designer-form/src/com/fr/design/mainframe/WidgetToolBarPane.java @@ -10,8 +10,20 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; -import javax.swing.*; -import java.awt.*; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BasicStroke; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.Stroke; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.ImageObserver; @@ -47,7 +59,7 @@ public class WidgetToolBarPane extends BasicPane implements DesignToolbarProvide } public void refreshToolbar() { - reset(); + singleton.reset(); } public static void refresh() { diff --git a/designer-realize/src/com/fr/design/dscolumn/DSColumnBasicPane.java b/designer-realize/src/com/fr/design/dscolumn/DSColumnBasicPane.java index e5b3b7f87..43cae70dc 100644 --- a/designer-realize/src/com/fr/design/dscolumn/DSColumnBasicPane.java +++ b/designer-realize/src/com/fr/design/dscolumn/DSColumnBasicPane.java @@ -14,8 +14,9 @@ import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellExpandAttr; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import java.awt.BorderLayout; +import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -27,6 +28,29 @@ public class DSColumnBasicPane extends BasicPane { private ExpandDirectionPane expandDirectionPane; private CellElement cellElement; + private ActionListener summaryDirectionActionlistener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + if (expandDirectionPane != null) { + expandDirectionPane.setNoneRadioButtonSelected(true); + } + } + }; + private ActionListener othergroupDirectionActionlistener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + if (expandDirectionPane != null) { + expandDirectionPane.setNoneRadioButtonSelected(false); + } + } + }; + private ActionListener sdcupdateActionlistener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + selectDataColumnPane.update(cellElement); + } + }; + public DSColumnBasicPane() { this(DSColumnPane.SETTING_ALL); } @@ -78,7 +102,7 @@ public class DSColumnBasicPane extends BasicPane { this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); - this.resultSetGroupPane.addListeners(summary_direction_ActionListener, otherGroup_direction_ActionListener, sdcUpdate_ActionListener); + this.resultSetGroupPane.addListeners(summaryDirectionActionlistener, othergroupDirectionActionlistener, sdcupdateActionlistener); } @Override @@ -93,7 +117,7 @@ public class DSColumnBasicPane extends BasicPane { this.cellElement = cellElement; - selectDataColumnPane.populate(source, cellElement); + selectDataColumnPane.populate(source, cellElement, null); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); if (conditionParentPane != null) { @@ -134,29 +158,6 @@ public class DSColumnBasicPane extends BasicPane { resultSetGroupPane.update(); } - ActionListener summary_direction_ActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - if (expandDirectionPane != null) { - expandDirectionPane.setNoneRadioButtonSelected(true); - } - } - }; - ActionListener otherGroup_direction_ActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - if (expandDirectionPane != null) { - expandDirectionPane.setNoneRadioButtonSelected(false); - } - } - }; - ActionListener sdcUpdate_ActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - selectDataColumnPane.update(cellElement); - } - }; - public void putElementcase(ElementCasePane t) { if (conditionParentPane != null) { conditionParentPane.putElementcase(t); diff --git a/designer-realize/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java b/designer-realize/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java index e2e21b8e4..2da652444 100644 --- a/designer-realize/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java +++ b/designer-realize/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java @@ -6,7 +6,7 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.main.impl.WorkBook; import com.fr.report.cell.TemplateCellElement; -import java.awt.*; +import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.Iterator; @@ -17,6 +17,7 @@ public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane { super(false); } + @Override protected void initTableNameComboBox() { tableNameComboBox = new TableDataComboBox(new WorkBook()); tableNameComboBox.addItemListener(new ItemListener() { @@ -32,14 +33,14 @@ public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane { tableNameComboBox.refresh(source); tableNameComboBox.setEditable(false); tableNameComboBox.setEnabled(false); - super.populate(source, cell); + super.populate(source, cell, null); try { Iterator it = source.getTableDataNameIterator(); String name = (String) it.next(); TemplateTableDataWrapper wrapper = new TemplateTableDataWrapper(source.getTableData(name), name); tableNameComboBox.setSelectedItem(wrapper); tableNameComboBox.getModel().setSelectedItem(wrapper); - } catch (Exception e) { + } catch (Exception ignored) { } } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer-realize/src/com/fr/design/dscolumn/SelectedDataColumnPane.java index 362c28166..aec849e41 100644 --- a/designer-realize/src/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer-realize/src/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -26,14 +26,18 @@ import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.regex.Pattern; /** @@ -41,31 +45,87 @@ import java.util.regex.Pattern; * * @author yaoh.wu * @version 2017年8月3日 - * 复用对话框代码,保留对话框原始布局 + * 复用对话框代码,保留对话框原始布局 * @since 8.0 */ public class SelectedDataColumnPane extends BasicPane { + + /** + * 参数编辑器面板 + */ private UITableEditorPane editorPane; + /** + * 参数 + */ private Parameter[] ps; - + /** + * 数据集下拉框 + */ TableDataComboBox tableNameComboBox; + /** + * 动态参数注入按钮 + */ + private UIButton paramButton; + /** + * 数据列下拉框 + */ LazyComboBox columnNameComboBox; + + /** + * 数据集下拉框和数据列下拉框监听器 + */ private ItemListener itemListener; - private UIButton paramButton; - public SelectedDataColumnPane() { - this(true, false, null, null); + /** + * 当前编辑的模板面板,用于触发保存操作 + */ + private ElementCasePane casePane; + /** + * 保存当前选中的 CE + */ + private CellElement cellElement; + + private static final Pattern COLUMN_NAME_PATTERN = Pattern.compile("[^\\d]"); + + /** + * 数据集下拉框变动后修改数据列下拉框加载状态的监听器 + */ + private ItemListener isNeedReloadListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + columnNameComboBox.setLoaded(false); + } + } + }; + + /** + * 创建横向布局附带显示动态参数注入按钮的数据集数据列选择面板 + */ + SelectedDataColumnPane() { + this(true, false); } - public SelectedDataColumnPane(boolean showParameterButton) { - this(showParameterButton, false, null, null); + /** + * 创建横向布局的数据集数据列选择面板 + * + * @param showParameterButton 是否显示动态参数注入按钮 + */ + SelectedDataColumnPane(boolean showParameterButton) { + this(showParameterButton, false); } - public SelectedDataColumnPane(boolean showParameterButton, boolean verticalLayout, ElementCasePane casePane, TemplateCellElement cellElement) { + /** + * 创建数据集数据列选择面板 + * + * @param showParameterButton 是否显示动态参数注入按钮 + * @param verticalLayout 是否是垂直布局 + */ + public SelectedDataColumnPane(boolean showParameterButton, boolean verticalLayout) { if (verticalLayout) { - initComponentVerticalLayout(casePane, cellElement); + initComponentVerticalLayout(); } else { initComponent(showParameterButton); } @@ -79,7 +139,7 @@ public class SelectedDataColumnPane extends BasicPane { public void initComponent(boolean showParameterButton) { initTableNameComboBox(); if (showParameterButton) { - initWithParameterButton(); + initParameterButton(); } columnNameComboBox = new LazyComboBox() { @@ -119,9 +179,9 @@ public class SelectedDataColumnPane extends BasicPane { /** * 初始化竖直布局的组件 */ - public void initComponentVerticalLayout(ElementCasePane casePane, TemplateCellElement cellElement) { + private void initComponentVerticalLayout() { initTableNameComboBox(); - initWithParameterButton(casePane, cellElement); + initVerticalParameterButton(); columnNameComboBox = new LazyComboBox() { @Override public Object[] load() { @@ -149,13 +209,22 @@ public class SelectedDataColumnPane extends BasicPane { } - public void populate(TableDataSource source, TemplateCellElement cellElement) { + /** + * 更新面板数据 + * + * @param source 数据源 + * @param cellElement 单元格 + * @param casePane 当前编辑的模板面板 + */ + public void populate(TableDataSource source, TemplateCellElement cellElement, ElementCasePane casePane) { + tableNameComboBox.refresh(source); + this.casePane = casePane; if (cellElement == null) { return; } - if (itemListener != null) { - removeListener(itemListener); - } + this.cellElement = cellElement; + removeListener(); + Object value = cellElement.getValue(); if (!(value instanceof DSColumn)) { return; @@ -166,9 +235,14 @@ public class SelectedDataColumnPane extends BasicPane { columnNameComboBox.setSelectedItem(TableDataColumn.getColumnName(dsColumn.getColumn())); ps = dsColumn.getParameters(); - addListener(itemListener); + addListener(); } + /** + * 保存数据到单元格对象中 + * + * @param cellElement 单元格 + */ public void update(CellElement cellElement) { if (cellElement == null) { return; @@ -177,7 +251,7 @@ public class SelectedDataColumnPane extends BasicPane { if (this.tableNameComboBox.getSelectedItem() == null && this.columnNameComboBox.getSelectedItem() == null) { return; } - DSColumn dsColumn = null; + DSColumn dsColumn; if (value == null || !(value instanceof DSColumn)) { dsColumn = new DSColumn(); cellElement.setValue(dsColumn); @@ -185,18 +259,27 @@ public class SelectedDataColumnPane extends BasicPane { dsColumn = (DSColumn) cellElement.getValue(); SimpleDSColumn simpleDSColumn = updateColumnPane(); - dsColumn.setDSName(simpleDSColumn.getDsName()); + dsColumn.setDSName(Objects.requireNonNull(simpleDSColumn).getDsName()); dsColumn.setColumn(simpleDSColumn.getColumn()); dsColumn.setParameters((ps != null && ps.length > 0) ? ps : null); } + /** + * 释放模板对象 + */ + public void release() { + this.cellElement = null; + this.casePane = null; + this.tableNameComboBox.setModel(new DefaultComboBoxModel()); + } + /** * 更新面板 * * @return 更新后的值 */ - public SimpleDSColumn updateColumnPane() { + private SimpleDSColumn updateColumnPane() { SimpleDSColumn dsColumn = new SimpleDSColumn(); TableDataWrapper tableDataWrappe = this.tableNameComboBox.getSelectedItem(); if (tableDataWrappe == null) { @@ -206,9 +289,8 @@ public class SelectedDataColumnPane extends BasicPane { TableDataColumn column; String columnExp = (String) this.columnNameComboBox.getSelectedItem(); if (isColumnName(columnExp)) { - String number = columnExp.substring(1); - Pattern pattern = Pattern.compile("[^\\d]"); - if (pattern.matcher(number).find()) { + String number = Objects.requireNonNull(columnExp).substring(1); + if (COLUMN_NAME_PATTERN.matcher(number).find()) { column = TableDataColumn.createColumn(columnExp); } else { int serialNumber = Integer.parseInt(columnExp.substring(1)); @@ -221,36 +303,31 @@ public class SelectedDataColumnPane extends BasicPane { return dsColumn; } + public void setListener(ItemListener i) { + this.itemListener = i; + } + /** * 添加监听事件 - * - * @param i 监听事件 */ - public void addListener(ItemListener i) { - itemListener = i; - tableNameComboBox.addItemListener(i); - columnNameComboBox.addItemListener(i); + private void addListener() { + tableNameComboBox.addItemListener(this.itemListener); + columnNameComboBox.addItemListener(this.itemListener); + tableNameComboBox.addItemListener(this.isNeedReloadListener); } /** * 移除监听事件 - * - * @param i 监听事件 */ - public void removeListener(ItemListener i) { - tableNameComboBox.removeItemListener(i); - columnNameComboBox.removeItemListener(i); + private void removeListener() { + tableNameComboBox.removeItemListener(this.itemListener); + columnNameComboBox.removeItemListener(this.itemListener); + tableNameComboBox.removeItemListener(this.isNeedReloadListener); } protected void initTableNameComboBox() { tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); - tableNameComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - columnNameComboBox.setLoaded(false); - } - }); tableNameComboBox.setPreferredSize(new Dimension(100, 20)); } @@ -260,8 +337,8 @@ public class SelectedDataColumnPane extends BasicPane { } - private void initWithParameterButton() { - editorPane = new UITableEditorPane(new ParameterTableModel()); + private void initParameterButton() { + editorPane = new UITableEditorPane<>(new ParameterTableModel()); paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); paramButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -279,18 +356,18 @@ public class SelectedDataColumnPane extends BasicPane { }); } - private void initWithParameterButton(final ElementCasePane casePane, final TemplateCellElement cellElement) { - final SelectedDataColumnPane that = this; - editorPane = new UITableEditorPane(new ParameterTableModel()); + private void initVerticalParameterButton() { + editorPane = new UITableEditorPane<>(new ParameterTableModel()); paramButton = new UIButton(Inter.getLocText("FR-Designer-Basic_Dynamic_Parameter_Injection")); paramButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { List parameterList = editorPane.update(); ps = parameterList.toArray(new Parameter[parameterList.size()]); - that.update(cellElement); + update(SelectedDataColumnPane.this.cellElement); casePane.fireTargetModified(); } }); @@ -310,6 +387,6 @@ public class SelectedDataColumnPane extends BasicPane { if (this.tableNameComboBox.getSelectedItem() != null) { return this.tableNameComboBox.getSelectedItem().calculateColumnNameList(); } - return new ArrayList(); + return new ArrayList<>(); } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/com/fr/design/mainframe/ElementCasePane.java index ad2c91eb0..da50e13d9 100644 --- a/designer-realize/src/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/com/fr/design/mainframe/ElementCasePane.java @@ -524,6 +524,8 @@ public abstract class ElementCasePane extends Tar * 因为这边判断selection是一个selection,所以不会触发fireSelectionChanged */ public void setSelection(Selection selection) { + //旧选中内容编辑器释放模板对象 + this.getCurrentEditor().release(); if (!ComparatorUtils.equals(this.selection, selection) || !ComparatorUtils.equals(EastRegionContainerPane.getInstance().getCellAttrPane(), CellElementPropertyPane.getInstance())) { this.selection = selection; diff --git a/designer-realize/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/com/fr/design/mainframe/ReportComponentComposite.java index 1893301f2..661fb0d69 100644 --- a/designer-realize/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -127,9 +127,8 @@ public class ReportComponentComposite extends JComponent { templateStateList.add(null); } centerCardPane.editingComponet.setSelection(centerCardPane.editingComponet.getDefaultSelectElement()); - if (jSliderContainer != null){ - jSliderContainer.reset(); - } + jSliderContainer=JSliderPane.getInstance(); + jSliderContainer.reset(); } if (centerCardPane.editingComponet.elementCasePane == null) { diff --git a/designer-realize/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java b/designer-realize/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java index a56d251a7..8a3b2ded4 100644 --- a/designer-realize/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java +++ b/designer-realize/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java @@ -120,4 +120,9 @@ public abstract class AbstractDSCellEditorPane extends JPanel { scrollBar.setBlockIncrement(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP); scrollBar.setBorder(BorderFactory.createMatteBorder(0, CONTENT_PANE_WIDTH_GAP, 0, 0, this.getBackground())); } + + /** + * 释放tc + */ + protected abstract void release(); } diff --git a/designer-realize/src/com/fr/design/module/DesignerModule.java b/designer-realize/src/com/fr/design/module/DesignerModule.java index d2697fa69..0427eee31 100644 --- a/designer-realize/src/com/fr/design/module/DesignerModule.java +++ b/designer-realize/src/com/fr/design/module/DesignerModule.java @@ -150,23 +150,23 @@ public class DesignerModule extends DesignModule { */ private void registerCellEditor() { - ActionFactory.registerCellEditorClass(String.class, CellStringQuickEditor.class); - ActionFactory.registerCellEditorClass(Number.class, CellStringQuickEditor.class); - ActionFactory.registerCellEditorClass(BaseFormula.class, CellFormulaQuickEditor.class); - ActionFactory.registerCellEditorClass(SubReport.class, CellSubReportEditor.class); - ActionFactory.registerCellEditorClass(RichText.class, CellRichTextEditor.class); - ActionFactory.registerCellEditorClass(DSColumn.class, CellDSColumnEditor.class); - ActionFactory.registerCellEditorClass(Image.class, CellImageQuickEditor.class); - ActionFactory.registerCellEditorClass(BiasTextPainter.class, CellBiasTextPainterEditor.class); - ActionFactory.registerCellEditorClass(BufferedImage.class, CellImageQuickEditor.class); + ActionFactory.registerCellEditor(String.class, new CellStringQuickEditor()); + ActionFactory.registerCellEditor(Number.class, new CellStringQuickEditor()); + ActionFactory.registerCellEditor(BaseFormula.class, new CellFormulaQuickEditor()); + ActionFactory.registerCellEditor(SubReport.class, new CellSubReportEditor()); + ActionFactory.registerCellEditor(RichText.class, new CellRichTextEditor()); + ActionFactory.registerCellEditor(DSColumn.class, new CellDSColumnEditor()); + ActionFactory.registerCellEditor(Image.class, new CellImageQuickEditor()); + ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor()); + ActionFactory.registerCellEditor(BufferedImage.class, new CellImageQuickEditor()); ActionFactory.registerCellEditor(CellImagePainter.class, new CellImageQuickEditor()); - + //todo 图表编辑器populate没能实现刷新面板显示 ActionFactory.registerChartCellEditorInEditor(BasicChartQuickEditor.class); Set providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); for (ElementUIProvider provider : providers) { try { - ActionFactory.registerCellEditorClass(provider.targetObjectClass(), provider.quickEditor()); + ActionFactory.registerCellEditor(provider.targetObjectClass(), provider.quickEditor().newInstance()); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage(), e); } @@ -185,12 +185,12 @@ public class DesignerModule extends DesignModule { */ private void registerFloatEditor() { - ActionFactory.registerFloatEditorClass(String.class, FloatStringQuickEditor.class); - ActionFactory.registerFloatEditorClass(Formula.class, FloatStringQuickEditor.class); - ActionFactory.registerFloatEditorClass(Image.class, FloatImageQuickEditor.class); - ActionFactory.registerFloatEditorClass(BufferedImage.class, FloatImageQuickEditor.class); + ActionFactory.registerFloatEditor(String.class, new FloatStringQuickEditor()); + ActionFactory.registerFloatEditor(Formula.class, new FloatStringQuickEditor()); + ActionFactory.registerFloatEditor(Image.class, new FloatImageQuickEditor()); + ActionFactory.registerFloatEditor(BufferedImage.class, new FloatImageQuickEditor()); ActionFactory.registerFloatEditor(CellImagePainter.class, new FloatImageQuickEditor()); - + //todo 图表编辑器populate没能实现刷新面板显示 ActionFactory.registerChartFloatEditorInEditor(FloatChartQuickEditor.class); } diff --git a/designer-realize/src/com/fr/grid/selection/CellSelection.java b/designer-realize/src/com/fr/grid/selection/CellSelection.java index 4cf1da661..b0e905672 100644 --- a/designer-realize/src/com/fr/grid/selection/CellSelection.java +++ b/designer-realize/src/com/fr/grid/selection/CellSelection.java @@ -49,8 +49,9 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.unit.FU; -import javax.swing.*; -import java.awt.*; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -114,6 +115,7 @@ public class CellSelection extends Selection { /** * 增加选中的区域 + * * @param cellRectangle 区域 */ public void addCellRectangle(Rectangle cellRectangle) { @@ -164,6 +166,7 @@ public class CellSelection extends Selection { /** * 清除区域块 + * * @param i 区域块 */ public void clearCellRectangles(int i) { @@ -172,8 +175,9 @@ public class CellSelection extends Selection { /** * 包含单元格 - * @param column 列 - * @param row 行 + * + * @param column 列 + * @param row 行 * @return 若不包含返回-1 */ public int containsCell(int column, int row) { @@ -205,6 +209,7 @@ public class CellSelection extends Selection { /** * 转换成矩形 + * * @return 矩形 */ public Rectangle toRectangle() { @@ -213,6 +218,7 @@ public class CellSelection extends Selection { /** * 是否选择一个单元格 + * * @param ePane 区域 * @return 是则返回rue */ @@ -239,8 +245,9 @@ public class CellSelection extends Selection { /** * 作为可传输的 + * * @param transferable 传输介质 - * @param ePane 区域 + * @param ePane 区域 */ public void asTransferable(ElementsTransferable transferable, ElementCasePane ePane) { java.util.List list = new java.util.ArrayList(); @@ -251,12 +258,12 @@ public class CellSelection extends Selection { TemplateCellElement cellElement = (TemplateCellElement) cells.next(); list.add((TemplateCellElement) cellElement.deriveCellElement(cellElement.getColumn() - column, cellElement.getRow() - row)); } - FU [] columnWidth = new FU[columnSpan]; - FU [] rowHeight = new FU[rowSpan]; - for (int i = 0; i < columnSpan; i++){ + FU[] columnWidth = new FU[columnSpan]; + FU[] rowHeight = new FU[rowSpan]; + for (int i = 0; i < columnSpan; i++) { columnWidth[i] = ec.getColumnWidth(this.column + i); } - for (int j = 0; j < rowSpan; j++){ + for (int j = 0; j < rowSpan; j++) { rowHeight[j] = ec.getRowHeight(this.row + j); } transferable.addObject(new CellElementsClip(this.columnSpan, this.rowSpan, columnWidth, rowHeight, list.toArray(new TemplateCellElement[list.size()]))); @@ -264,9 +271,10 @@ public class CellSelection extends Selection { /** * 黏贴单元格 + * * @param ceClip 单元格 - * @param ePane 区域 - * @return 成功返回true + * @param ePane 区域 + * @return 成功返回true */ @Override public boolean pasteCellElementsClip(CellElementsClip ceClip, ElementCasePane ePane) { @@ -281,8 +289,9 @@ public class CellSelection extends Selection { /** * 黏贴字符串 - * @param str 字符串 - * @param ePane 区域 + * + * @param str 字符串 + * @param ePane 区域 * @return 成功返回true */ @Override @@ -329,7 +338,8 @@ public class CellSelection extends Selection { /** * 黏贴其他 - * @param ob 要黏贴的东西 + * + * @param ob 要黏贴的东西 * @param ePane 区域 * @return 成功返回true */ @@ -352,6 +362,7 @@ public class CellSelection extends Selection { /** * 是否能合并单元格 + * * @param ePane 区域 * @return 是则返回true */ @@ -363,6 +374,7 @@ public class CellSelection extends Selection { /** * 合并单元格 + * * @param ePane 区域 * @return 成功返回true */ @@ -371,7 +383,7 @@ public class CellSelection extends Selection { TemplateElementCase ec = ePane.getEditingElementCase(); Iterator cells = ec.intersect(column, row, columnSpan, rowSpan); - if (cells.hasNext() && cells.hasNext()) { // alex:有两个以上的格子在这个区域内 + if (cells.hasNext()) { // alex:有两个以上的格子在这个区域内 int returnValue = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(ePane), Inter.getLocText("Des-Merger_Cell"), Inter.getLocText("Utils-Merge_Cell"), JOptionPane.OK_CANCEL_OPTION); if (returnValue != JOptionPane.OK_OPTION) { @@ -386,6 +398,7 @@ public class CellSelection extends Selection { /** * 是否撤销合并单元格 + * * @param ePane 区域 * @return 是则返回true */ @@ -407,6 +420,7 @@ public class CellSelection extends Selection { /** * 撤销合并单元格 + * * @param ePane 区域 * @return 成功返回true */ @@ -443,6 +457,7 @@ public class CellSelection extends Selection { /** * 创建弹出菜单 + * * @param ePane 区域 * @return 菜单 */ @@ -477,7 +492,7 @@ public class CellSelection extends Selection { popup.add(DeprecatedActionManager.getPresentMenu(ePane).createJMenu()); popup.add(new CellAttributeAction().createMenuItem()); JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jTemplate.isJWorkBook()){ //表单中报表块编辑屏蔽掉 控件设置 + if (jTemplate.isJWorkBook()) { //表单中报表块编辑屏蔽掉 控件设置 popup.add(new CellWidgetAttrAction().createMenuItem()); } popup.add(new ConditionAttributesAction().createMenuItem()); @@ -497,8 +512,9 @@ public class CellSelection extends Selection { /** * 清除 - * @param type 要清除的类型 - * @param ePane 区域 + * + * @param type 要清除的类型 + * @param ePane 区域 * @return 成功返回true */ @Override @@ -581,6 +597,7 @@ public class CellSelection extends Selection { /** * 向左移动 + * * @param ePane 区域 */ public void moveLeft(ElementCasePane ePane) { @@ -592,6 +609,7 @@ public class CellSelection extends Selection { /** * 向右移动 + * * @param ePane 区域 */ public void moveRight(ElementCasePane ePane) { @@ -600,6 +618,7 @@ public class CellSelection extends Selection { /** * 向上移动 + * * @param ePane 区域 */ public void moveUp(ElementCasePane ePane) { @@ -611,6 +630,7 @@ public class CellSelection extends Selection { /** * 向下移动 + * * @param ePane 区域 */ public void moveDown(ElementCasePane ePane) { @@ -626,6 +646,7 @@ public class CellSelection extends Selection { /** * 触发删除动作 + * * @param ePane 区域 * @return 成功返回true */ @@ -657,6 +678,7 @@ public class CellSelection extends Selection { /** * 包含行列 + * * @param cr 行列 * @return 包含返回true */ @@ -716,7 +738,7 @@ public class CellSelection extends Selection { CellElementPropertyPane.getInstance().reInit(ePane); } - public void populateWidgetPropertyPane(ElementCasePane ePane){ + public void populateWidgetPropertyPane(ElementCasePane ePane) { CellWidgetPropertyPane.getInstance().reInit(ePane); } diff --git a/designer-realize/src/com/fr/grid/selection/FloatSelection.java b/designer-realize/src/com/fr/grid/selection/FloatSelection.java index 0d441a1f7..bd3b71a3b 100644 --- a/designer-realize/src/com/fr/grid/selection/FloatSelection.java +++ b/designer-realize/src/com/fr/grid/selection/FloatSelection.java @@ -5,7 +5,12 @@ import com.fr.base.FRContext; import com.fr.design.actions.cell.CleanAuthorityAction; import com.fr.design.actions.cell.FloatStyleAction; import com.fr.design.actions.core.ActionFactory; -import com.fr.design.actions.edit.*; +import com.fr.design.actions.edit.CopyAction; +import com.fr.design.actions.edit.CutAction; +import com.fr.design.actions.edit.DeleteAction; +import com.fr.design.actions.edit.EditFloatElementNameAction; +import com.fr.design.actions.edit.HyperlinkAction; +import com.fr.design.actions.edit.PasteAction; import com.fr.design.actions.edit.order.BringFloatElementForwardAction; import com.fr.design.actions.edit.order.BringFloatElementToFrontAction; import com.fr.design.actions.edit.order.SendFloatElementBackwardAction; @@ -28,10 +33,12 @@ import com.fr.stable.ColumnRow; import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPopupMenu; +import java.awt.Toolkit; + /** * the float selection + * * @editor zhou * 2012-3-22下午2:09:20 */ @@ -216,6 +223,7 @@ public class FloatSelection extends Selection { public boolean isSelectedOneCell(ElementCasePane ePane) { return false; } + //TODO:august 这儿不比较FloatElement会不会有问题啊 @Override public boolean equals(Object obj) { @@ -239,8 +247,7 @@ public class FloatSelection extends Selection { CellElementPropertyPane.getInstance().removeAll(); } - public void populateWidgetPropertyPane(ElementCasePane ePane){ - return; + public void populateWidgetPropertyPane(ElementCasePane ePane) { } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/quickeditor/FloatQuickEditor.java b/designer-realize/src/com/fr/quickeditor/FloatQuickEditor.java index 1f3d76a0e..72fd6870e 100644 --- a/designer-realize/src/com/fr/quickeditor/FloatQuickEditor.java +++ b/designer-realize/src/com/fr/quickeditor/FloatQuickEditor.java @@ -1,24 +1,32 @@ package com.fr.quickeditor; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.selection.QuickEditor; import com.fr.grid.selection.FloatSelection; import com.fr.report.cell.FloatElement; -import com.fr.design.selection.QuickEditor; /** - * * @author zhou * @since 2012-7-23下午5:17:23 */ public abstract class FloatQuickEditor extends QuickEditor { - protected FloatElement floatElement; + protected FloatElement floatElement; + + @Override + protected void refresh() { + FloatSelection fs = (FloatSelection) tc.getSelection(); + floatElement = tc.getEditingElementCase().getFloatElement(fs.getSelectedFloatName()); + refreshDetails(); + } - @Override - protected void refresh() { - FloatSelection fs = (FloatSelection)tc.getSelection(); - floatElement = tc.getEditingElementCase().getFloatElement(fs.getSelectedFloatName()); - refreshDetails(); - } + /** + * 刷新详细信息 + */ + protected abstract void refreshDetails(); - protected abstract void refreshDetails(); + @Override + public void release() { + super.release(); + floatElement = null; + } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 1ae401bc5..72e6c9ae1 100644 --- a/designer-realize/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -35,6 +35,7 @@ import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.FilterTypeEnum; import com.fr.report.cell.cellattr.core.group.SelectCount; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -74,9 +75,6 @@ public class CellDSColumnEditor extends CellQuickEditor { private static final Color TIP_FONT_COLOR = new Color(0x7F333334, true); - private JPanel dsColumnRegion; - private JPanel centerPane; - /** * 基本和高级设置 */ @@ -117,10 +115,10 @@ public class CellDSColumnEditor extends CellQuickEditor { public JComponent createCenterBody() { this.createPanes(); this.createSwitchTab(); - dsColumnRegion = new JPanel(new BorderLayout()); + JPanel dsColumnRegion = new JPanel(new BorderLayout()); dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); dsColumnRegion.add(cardContainer, BorderLayout.CENTER); - centerPane = new JPanel(new BorderLayout()); + JPanel centerPane = new JPanel(new BorderLayout()); centerPane.add(dsColumnRegion, BorderLayout.CENTER); return centerPane; } @@ -141,17 +139,6 @@ public class CellDSColumnEditor extends CellQuickEditor { } - /** - * 关闭时候释放 - */ - @Override - public void release() { - super.release(); - dsColumnRegion = null; - centerPane = null; - } - - /** * 初始化基本和高级设置切换tab */ @@ -187,6 +174,12 @@ public class CellDSColumnEditor extends CellQuickEditor { paneList.add(cellDSColumnAdvancedPane); } + @Override + public void release() { + super.release(); + cellDSColumnBasicPane.release(); + cellDSColumnAdvancedPane.release(); + } /** * 单元格元素 数据列 高级设置内容面板 @@ -252,9 +245,9 @@ public class CellDSColumnEditor extends CellQuickEditor { }; DSColumnBasicEditorPane() { - dataPane = new SelectedDataColumnPane(true, true, tc, cellElement); + dataPane = new SelectedDataColumnPane(true, true); groupPane = new ResultSetGroupDockingPane(); - dataPane.addListener(dataListener); + dataPane.setListener(dataListener); groupPane.setListener(groupListener); double[] rowSize = {P}, columnSize = {P, F}; @@ -297,13 +290,19 @@ public class CellDSColumnEditor extends CellQuickEditor { @Override public void populate() { - dataPane.populate(null, cellElement); + dataPane.populate(DesignTableDataManager.getEditingTableDataSource(), cellElement, tc); groupPane.populate(cellElement); if (tc != null) { condition.setEditingComponent(tc); } } + @Override + protected void release() { + condition.setEditingComponent(null); + dataPane.release(); + } + /** * 创建有内容的面板显示信息 @@ -330,6 +329,7 @@ public class CellDSColumnEditor extends CellQuickEditor { class DSColumnAdvancedEditorPane extends AbstractDSCellEditorPane { + /*pane begin*/ /** * 排列顺序 */ @@ -353,7 +353,7 @@ public class CellDSColumnEditor extends CellQuickEditor { /** * 补充空白数据 */ - private UICheckBox useMultiplyNumCheckBox; + private UICheckBox useMultiNumCheckBox; /** * 补充空白数据数目输入框 */ @@ -362,6 +362,75 @@ public class CellDSColumnEditor extends CellQuickEditor { * 补充空白数据数目面板 可隐藏 */ private JPanel multiPane; + /*pane end*/ + + + /*listeners begin*/ + private UIObserverListener sortPaneFormulaChangeListener = new UIObserverListener() { + @Override + public void doChange() { + sortPane.update(cellElement); + fireTargetModified(); + } + }; + + private ChangeListener sortTypeBtnGroupChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + sortPane.update(cellElement); + fireTargetModified(); + } + }; + + private UIObserverListener filterPaneChangeListener = new UIObserverListener() { + @Override + public void doChange() { + filterPane.update(cellElement); + fireTargetModified(); + } + }; + + private UIObserverListener customValuePaneChangeListener = new UIObserverListener() { + @Override + public void doChange() { + valuePane.update(cellElement); + fireTargetModified(); + } + }; + + private ChangeListener heCheckBoxChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + cellDSColumnAdvancedPane.updateExtendConfig(); + fireTargetModified(); + } + }; + + private ChangeListener veCheckBoxChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + cellDSColumnAdvancedPane.updateExtendConfig(); + fireTargetModified(); + } + }; + + private ActionListener useMultiNumCheckBoxChangeListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkButtonEnabled(); + cellDSColumnAdvancedPane.updateMultipleConfig(); + fireTargetModified(); + } + }; + + private ChangeListener multiNumSpinnerChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + cellDSColumnAdvancedPane.updateMultipleConfig(); + fireTargetModified(); + } + }; + /*listeners end*/ public DSColumnAdvancedEditorPane() { @@ -397,6 +466,7 @@ public class CellDSColumnEditor extends CellQuickEditor { @Override public void populate() { if (cellElement != null) { + disableListener(); sortPane.populate(cellElement); valuePane.populate(cellElement); filterPane.populate(cellElement); @@ -406,6 +476,7 @@ public class CellDSColumnEditor extends CellQuickEditor { cellElement.setCellExpandAttr(cellExpandAttr); } // extendable + //noinspection Duplicates switch (cellExpandAttr.getExtendable()) { case CellExpandAttr.Both_EXTENDABLE: heCheckBox.setSelected(true); @@ -425,15 +496,23 @@ public class CellDSColumnEditor extends CellQuickEditor { } } if (cellExpandAttr.getMultipleNumber() == -1) { - useMultiplyNumCheckBox.setSelected(false); + useMultiNumCheckBox.setSelected(false); + // 默认值 + multiNumSpinner.setValue(1); } else { - useMultiplyNumCheckBox.setSelected(true); + useMultiNumCheckBox.setSelected(true); multiNumSpinner.setValue(cellExpandAttr.getMultipleNumber()); } this.checkButtonEnabled(); + enableListener(); } } + @Override + protected void release() { + + } + /** * 更新单元格扩展属性 */ @@ -443,6 +522,7 @@ public class CellDSColumnEditor extends CellQuickEditor { cellExpandAttr = new CellExpandAttr(); cellElement.setCellExpandAttr(cellExpandAttr); } + //noinspection Duplicates if (heCheckBox.isSelected()) { if (veCheckBox.isSelected()) { cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); @@ -463,12 +543,11 @@ public class CellDSColumnEditor extends CellQuickEditor { */ private void updateMultipleConfig() { CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); - if (this.useMultiplyNumCheckBox.isSelected()) { + if (this.useMultiNumCheckBox.isSelected()) { cellExpandAttr.setMultipleNumber((int) multiNumSpinner.getValue()); } else { cellExpandAttr.setMultipleNumber(-1); } - } /** @@ -479,68 +558,29 @@ public class CellDSColumnEditor extends CellQuickEditor { @Override protected JPanel createContentPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + //结果集排序 sortPane = new ResultSetSortConfigPane(); - sortPane.addListener(new UIObserverListener() { - @Override - public void doChange() { - sortPane.update(cellElement); - fireTargetModified(); - } - }, new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - sortPane.update(cellElement); - fireTargetModified(); - } - } - ); + //结果筛选 filterPane = new ResultSetFilterConfigPane(); - filterPane.addListener(new UIObserverListener() { - @Override - public void doChange() { - filterPane.update(cellElement); - fireTargetModified(); - } - } - ); + //自定义值显示 valuePane = new CustomValuePane(); - valuePane.addListener(new UIObserverListener() { - @Override - public void doChange() { - valuePane.update(cellElement); - fireTargetModified(); - } - }); //可扩展性 JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); extendableDirectionPane.add(heCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); extendableDirectionPane.add(veCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); - heCheckBox.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateExtendConfig(); - fireTargetModified(); - } - }); - veCheckBox.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateExtendConfig(); - fireTargetModified(); - } - }); - JPanel multiNumPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); //补充空白数据 - useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Fill_blank_Data")); + JPanel multiNumPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); + useMultiNumCheckBox = new UICheckBox(Inter.getLocText("Fill_blank_Data")); JPanel checkBoxPane = new JPanel(new BorderLayout()); - checkBoxPane.add(useMultiplyNumCheckBox, BorderLayout.WEST); + checkBoxPane.add(useMultiNumCheckBox, BorderLayout.WEST); multiNumPane.add(checkBoxPane); multiNumSpinner = new UISpinner(1, 10000, 1, 1); + //数据倍数 UILabel multipleLabel = new UILabel(Inter.getLocText("Column_Multiple")); multiPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ @@ -551,25 +591,11 @@ public class CellDSColumnEditor extends CellQuickEditor { ); multiPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); multiNumPane.add(multiPane); - useMultiplyNumCheckBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkButtonEnabled(); - cellDSColumnAdvancedPane.updateMultipleConfig(); - fireTargetModified(); - } - }); - multiNumSpinner.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateMultipleConfig(); - fireTargetModified(); - } - }); + + enableListener(); double[] rowSize = {P, P, P, P, P, P}; double[] columnSize = {F}; - Component[][] components = new Component[][]{ {sortPane}, {filterPane}, @@ -580,9 +606,29 @@ public class CellDSColumnEditor extends CellQuickEditor { return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); } + public void enableListener() { + sortPane.addListener(sortPaneFormulaChangeListener, sortTypeBtnGroupChangeListener); + filterPane.addListener(filterPaneChangeListener); + valuePane.addListener(customValuePaneChangeListener); + heCheckBox.addChangeListener(heCheckBoxChangeListener); + veCheckBox.addChangeListener(veCheckBoxChangeListener); + useMultiNumCheckBox.addActionListener(useMultiNumCheckBoxChangeListener); + multiNumSpinner.addChangeListener(multiNumSpinnerChangeListener); + } + + public void disableListener() { + sortPane.removeListener(sortTypeBtnGroupChangeListener); + filterPane.removeListener(); + valuePane.removeListener(); + heCheckBox.removeChangeListener(heCheckBoxChangeListener); + veCheckBox.removeChangeListener(veCheckBoxChangeListener); + useMultiNumCheckBox.removeActionListener(useMultiNumCheckBoxChangeListener); + multiNumSpinner.removeChangeListener(multiNumSpinnerChangeListener); + } + private void checkButtonEnabled() { - if (useMultiplyNumCheckBox.isSelected()) { + if (useMultiNumCheckBox.isSelected()) { multiNumSpinner.setEnabled(true); multiPane.setVisible(true); } else { @@ -659,7 +705,7 @@ public class CellDSColumnEditor extends CellQuickEditor { public void populate(TemplateCellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { this.formulaField.populateElement(cellElement); DSColumn dSColumn = (DSColumn) value; int sort = dSColumn.getOrder(); @@ -676,6 +722,8 @@ public class CellDSColumnEditor extends CellQuickEditor { String sortFormula = dSColumn.getSortFormula(); if (sortFormula != null && sortFormula.length() >= 1) { this.formulaField.populate(sortFormula); + } else { + this.formulaField.populate(DEFAULT_VALUE); } } } @@ -689,8 +737,8 @@ public class CellDSColumnEditor extends CellQuickEditor { public void update(CellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + if (value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) value; dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); dSColumn.setSortFormula(this.formulaField.getFormulaText()); } @@ -707,6 +755,16 @@ public class CellDSColumnEditor extends CellQuickEditor { formulaField.addListener(formulaChangeListener); sortTypePane.addChangeListener(changeListener); } + + /** + * 去除事件监听器 + * + * @param changeListener 排序类型下拉框改动事件监听器 + */ + public void removeListener(ChangeListener changeListener) { + formulaField.removeListener(); + sortTypePane.removeChangeListener(changeListener); + } } /** @@ -852,13 +910,18 @@ public class CellDSColumnEditor extends CellQuickEditor { rsComboBox.removeActionListener(actionListener); if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) (cellElement.getValue()); SelectCount selectCount = dSColumn.getSelectCount(); this.topFormulaPane.populateElement(cellElement); this.bottomFormulaPane.populateElement(cellElement); CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); + // 重置默认值 + this.topFormulaPane.populate(DEFAULT_VALUE); + this.bottomFormulaPane.populate(DEFAULT_VALUE); + this.serialTextField.setText(StringUtils.EMPTY); + if (selectCount != null) { int selectCountType = selectCount.getType(); this.rsComboBox.setSelectedIndex(selectCountType); @@ -927,6 +990,7 @@ public class CellDSColumnEditor extends CellQuickEditor { TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); } } else { + this.rsComboBox.setSelectedIndex(0); //未定义 setCardPaneLayout.show(setCardPane, UNDEFINE.name()); tipCardPaneLayout.show(tipCardPane, UNDEFINE.name()); @@ -944,8 +1008,8 @@ public class CellDSColumnEditor extends CellQuickEditor { public void update(CellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + if (value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) value; int selectedFilterIndex = this.rsComboBox.getSelectedIndex(); if (selectedFilterIndex == 0) { dSColumn.setSelectCount(null); @@ -953,6 +1017,7 @@ public class CellDSColumnEditor extends CellQuickEditor { SelectCount selectCount = new SelectCount(); selectCount.setType(selectedFilterIndex); dSColumn.setSelectCount(selectCount); + //noinspection Duplicates if (selectedFilterIndex == TOP.getValue()) { selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); } else if (selectedFilterIndex == BOTTOM.getValue()) { @@ -976,6 +1041,16 @@ public class CellDSColumnEditor extends CellQuickEditor { rsComboBox.registerChangeListener(formulaListener); serialTextField.registerChangeListener(formulaListener); } + + /** + * 去除事件监听器 + */ + public void removeListener() { + topFormulaPane.removeListener(); + bottomFormulaPane.removeListener(); + rsComboBox.removeChangeListener(); + serialTextField.registerChangeListener(null); + } } /** @@ -1029,6 +1104,13 @@ public class CellDSColumnEditor extends CellQuickEditor { this.formulaTextField.registerChangeListener(listener); } + /** + * 取消事件监听器 + */ + public void removeListener() { + this.formulaTextField.registerChangeListener(null); + } + private ActionListener formulaButtonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { @@ -1042,7 +1124,7 @@ public class CellDSColumnEditor extends CellQuickEditor { final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { DSColumn dsColumn = (DSColumn) value; String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); formulaPane.populate(valueFormula, new CustomVariableResolver(displayNames, true)); @@ -1086,12 +1168,14 @@ public class CellDSColumnEditor extends CellQuickEditor { public void populate(CellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) value; //formula String valueFormula = dSColumn.getResult(); if (valueFormula != null) { formulaField.populate(valueFormula); + } else { + formulaField.populate(DEFAULT_VALUE); } formulaField.populateElement(cellElement); @@ -1102,7 +1186,7 @@ public class CellDSColumnEditor extends CellQuickEditor { public void update(CellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) (cellElement.getValue()); dSColumn.setResult(this.formulaField.getFormulaText()); } @@ -1117,6 +1201,13 @@ public class CellDSColumnEditor extends CellQuickEditor { public void addListener(UIObserverListener formulaListener) { this.formulaField.addListener(formulaListener); } + + /** + * 移除事件监听器 + */ + public void removeListener() { + this.formulaField.removeListener(); + } } } diff --git a/designer-realize/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java b/designer-realize/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java index 461dee3ee..456bfdeb1 100644 --- a/designer-realize/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java +++ b/designer-realize/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java @@ -3,7 +3,6 @@ package com.fr.quickeditor.cellquick; import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.insert.cell.RichTextCellAction; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.Inter; @@ -13,7 +12,6 @@ import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; /** * 单元格元素富文本编辑器 @@ -58,4 +56,9 @@ public class CellRichTextEditor extends CellQuickEditor { return true; } + @Override + public void release() { + super.release(); + richTextButton.setAction(null); + } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java b/designer-realize/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java index e8f79166a..e90e27715 100644 --- a/designer-realize/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java +++ b/designer-realize/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java @@ -3,7 +3,6 @@ package com.fr.quickeditor.cellquick; import com.fr.base.BaseFormula; import com.fr.base.Style; import com.fr.base.TextFormat; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.grid.GridKeyListener; import com.fr.grid.selection.CellSelection; @@ -18,7 +17,6 @@ import javax.swing.JPanel; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.BorderLayout; -import java.awt.Dimension; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; diff --git a/designer-realize/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java b/designer-realize/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java index cfa362cb3..b33deff88 100644 --- a/designer-realize/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java +++ b/designer-realize/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java @@ -56,4 +56,10 @@ public class CellSubReportEditor extends CellQuickEditor { public boolean isScrollAll() { return true; } + + @Override + public void release() { + super.release(); + subReportButton.setAction(null); + } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/quickeditor/floatquick/FloatImageQuickEditor.java b/designer-realize/src/com/fr/quickeditor/floatquick/FloatImageQuickEditor.java index a243195c1..57a487603 100644 --- a/designer-realize/src/com/fr/quickeditor/floatquick/FloatImageQuickEditor.java +++ b/designer-realize/src/com/fr/quickeditor/floatquick/FloatImageQuickEditor.java @@ -14,8 +14,10 @@ import com.fr.general.Inter; import com.fr.quickeditor.FloatQuickEditor; import com.fr.report.cell.cellattr.CellImage; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -73,8 +75,6 @@ public class FloatImageQuickEditor extends FloatQuickEditor { @Override protected void refreshDetails() { - // TODO Auto-generated method stub - } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java b/designer-realize/src/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java index 1f5718a9e..eae3e81dc 100644 --- a/designer-realize/src/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java +++ b/designer-realize/src/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java @@ -12,10 +12,16 @@ import com.fr.quickeditor.FloatQuickEditor; import com.fr.report.ReportHelper; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JTextArea; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -27,6 +33,25 @@ public class FloatStringQuickEditor extends FloatQuickEditor { private boolean reserveInResult = false; private boolean reserveOnWriteOrAnaly = true; + private DocumentListener documentListener = new DocumentListener() { + + @Override + public void insertUpdate(DocumentEvent e) { + changeReportPaneCell(stringTextField.getText().trim()); + } + + @Override + public void removeUpdate(DocumentEvent e) { + changeReportPaneCell(stringTextField.getText().trim()); + } + + @Override + public void changedUpdate(DocumentEvent e) { + changeReportPaneCell(stringTextField.getText().trim()); + } + + }; + public FloatStringQuickEditor() { super(); stringTextField = new JTextArea(); @@ -34,11 +59,17 @@ public class FloatStringQuickEditor extends FloatQuickEditor { formulaButton = new UIButton(); formulaButton.setPreferredSize(new Dimension(25, 23)); formulaButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); + ActionListener getFormulaActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ((ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane()).getGrid().startEditing(); + } + }; formulaButton.addActionListener(getFormulaActionListener); JPanel pane = new JPanel(new BorderLayout(5, 0)); pane.add(stringTextField, BorderLayout.CENTER); pane.add(formulaButton, BorderLayout.EAST); - pane.setBorder(BorderFactory.createEmptyBorder(0,0,0,5)); + pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); formulaButton.setVisible(false); this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); @@ -55,16 +86,10 @@ public class FloatStringQuickEditor extends FloatQuickEditor { stringTextField.setBackground(Color.WHITE); } - ActionListener getFormulaActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - ((ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane()).getGrid().startEditing(); - } - }; @Override protected void refreshDetails() { - String str = null; + String str; Object value = floatElement.getValue(); if (value == null) { str = StringUtils.EMPTY; @@ -89,26 +114,8 @@ public class FloatStringQuickEditor extends FloatQuickEditor { stringTextField.getDocument().addDocumentListener(documentListener); } - DocumentListener documentListener = new DocumentListener() { - - @Override - public void insertUpdate(DocumentEvent e) { - changeReportPaneCell(stringTextField.getText().trim()); - } - - @Override - public void removeUpdate(DocumentEvent e) { - changeReportPaneCell(stringTextField.getText().trim()); - } - - @Override - public void changedUpdate(DocumentEvent e) { - changeReportPaneCell(stringTextField.getText().trim()); - } - - }; - protected void changeReportPaneCell(String tmpText) { + private void changeReportPaneCell(String tmpText) { if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { BaseFormula textFormula = BaseFormula.createFormulaBuilder().build(tmpText); textFormula.setReserveInResult(reserveInResult); @@ -125,5 +132,4 @@ public class FloatStringQuickEditor extends FloatQuickEditor { fireTargetModified(); stringTextField.requestFocus(); } - } \ No newline at end of file From 304449fd195ac4cd3ef40caea36fa885c75e7b27 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 14:45:51 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=97=A0=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E5=86=B3=E7=AD=96=E6=8A=A5=E8=A1=A8=E7=BC=96=E8=BE=91=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E5=9D=97=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/ElementCasePane.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/com/fr/design/mainframe/ElementCasePane.java index da50e13d9..25622d179 100644 --- a/designer-realize/src/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/com/fr/design/mainframe/ElementCasePane.java @@ -524,8 +524,13 @@ public abstract class ElementCasePane extends Tar * 因为这边判断selection是一个selection,所以不会触发fireSelectionChanged */ public void setSelection(Selection selection) { - //旧选中内容编辑器释放模板对象 - this.getCurrentEditor().release(); + try { + //旧选中内容编辑器释放模板对象 + this.getCurrentEditor().release(); + } catch (UnsupportedOperationException e) { + FRContext.getLogger().info("Nothing to release"); + } + if (!ComparatorUtils.equals(this.selection, selection) || !ComparatorUtils.equals(EastRegionContainerPane.getInstance().getCellAttrPane(), CellElementPropertyPane.getInstance())) { this.selection = selection; From 7b12c56f9963e02fb52f55e3edc58e0d1c27451c Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 15:18:59 +0800 Subject: [PATCH 03/11] =?UTF-8?q?REPORT-6096=20TAB=E9=A1=B5=E4=B8=AD?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=9C=A8=E5=A4=8D=E5=88=B6=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E5=90=8E=E4=BC=9A=E4=BD=8D=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/FormSelectionUtils.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java b/designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java index ebf7328a2..86a7536e2 100644 --- a/designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer-form/src/com/fr/design/mainframe/FormSelectionUtils.java @@ -12,6 +12,7 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWScaleLayout; import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; @@ -107,6 +108,7 @@ public class FormSelectionUtils { designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Large_To_Paste")); return; } + resetTabSub2RealSize(copiedCreator); boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y); if (addSuccess) { designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); @@ -121,6 +123,34 @@ public class FormSelectionUtils { } + /** + * REPORT-6096 复制得到的是显示的大小,如果因屏幕分辨率问题存在缩放的话,显示大小和实际大小会有区别,粘贴后tab内部调整大小时会再次缩放导致问题。 + * 因此在粘贴之前将tab内部的组件调整成实际的大小。 + * + * @param copiedCreator 复制的组件 + */ + private static void resetTabSub2RealSize(XCreator copiedCreator) { + ArrayList childrenList = copiedCreator.getTargetChildrenList(); + if (!childrenList.isEmpty()) { + for (Object aChildrenList : childrenList) { + XWTabFitLayout tabLayout = (XWTabFitLayout) aChildrenList; + double percent = tabLayout.getContainerPercent(); + Component[] components = tabLayout.getComponents(); + for (Component component : components) { + Rectangle show = component.getBounds(); + component.setBounds(new Rectangle((int) (show.x * percent), (int) (show.y * percent), (int) (show.width * percent), (int) (show.height * percent))); + } + } + } + Component[] components = copiedCreator.getComponents(); + for (Component component : components) { + try { + resetTabSub2RealSize((XCreator) component); + } catch (ClassCastException ignored) { + } + } + } + /** * 相对布局粘贴 */ @@ -178,9 +208,9 @@ public class FormSelectionUtils { */ private static Point getPasteLocation(AbstractLayoutAdapter layoutAdapter, XCreator copiedCreator, int x, int y) { //当宽度为奇数时 设置偏移 - int xoffset = (copiedCreator.getWidth() & 1) == 1 ? 1 : 0; + int xoffset = copiedCreator.getWidth() & 1; //当高度为奇数时 设置偏移 - int yoffset = (copiedCreator.getHeight() & 1) == 1 ? 1 : 0; + int yoffset = copiedCreator.getHeight() & 1; if (!layoutAdapter.accept(copiedCreator, x, y)) { XLayoutContainer container = layoutAdapter.getContainer(); From 41a03ac1e4657b114286f7a8825e1ea88d37eeb9 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 17:24:45 +0800 Subject: [PATCH 04/11] =?UTF-8?q?REPORT-5856=20=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=96=B0=E5=88=86=E7=B1=BB=20=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=88=86=E7=B1=BB=E8=BF=87=E6=BB=A4=E5=A4=B1?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java b/designer-base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java index 4b4bddab4..db10437fd 100644 --- a/designer-base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java +++ b/designer-base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java @@ -23,7 +23,7 @@ public class GetPluginFromStoreExecutor implements Executor { private String scope; public GetPluginFromStoreExecutor(JSONObject info) { - this.category = info.optString("category"); + this.category = info.optString("categories"); this.fee = info.optString("fee"); this.seller = info.optString("seller"); this.scope = info.optString("scope"); From 5c7c5acef3a2d60d3c567e900c484c9cc075bf4f Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 18:55:24 +0800 Subject: [PATCH 05/11] =?UTF-8?q?REPORT-6868=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=97=E5=8D=95=E5=85=83=E6=A0=BC=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=A2=91=E7=B9=81=E5=BC=B9=E5=87=BAsql=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=AF=B9=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/demo/ComboBoxDemo.java | 48 +-- .../design/gui/demo/SwingComponentsDemo.java | 17 +- .../fr/design/gui/icombobox/LazyComboBox.java | 338 ++++++++---------- .../fr/design/gui/icombobox/UIComboBox.java | 70 ++-- .../com/fr/design/dscolumn/DSColumnPane.java | 156 ++++---- 5 files changed, 307 insertions(+), 322 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/demo/ComboBoxDemo.java b/designer-base/src/com/fr/design/gui/demo/ComboBoxDemo.java index a47ea5b0c..a29d78dd0 100644 --- a/designer-base/src/com/fr/design/gui/demo/ComboBoxDemo.java +++ b/designer-base/src/com/fr/design/gui/demo/ComboBoxDemo.java @@ -1,34 +1,37 @@ package com.fr.design.gui.demo; -import java.awt.BorderLayout; -import java.awt.Component; -import java.util.ArrayList; - -import javax.swing.DefaultListCellRenderer; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JTree; -import javax.swing.ListCellRenderer; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreePath; - import com.fr.base.FRContext; -import com.fr.design.gui.icombobox.filter.Filter; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.icombobox.ComboCheckBox; import com.fr.design.gui.icombobox.DictionaryComboBox; import com.fr.design.gui.icombobox.ExtendedComboBox; import com.fr.design.gui.icombobox.FRTreeComboBox; import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.icombobox.LazyComboBox; +import com.fr.design.gui.icombobox.filter.Filter; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.parameter.ParameterInputPane; import com.fr.general.Inter; +import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.ListCellRenderer; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreeCellRenderer; +import javax.swing.tree.TreePath; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.ArrayList; + /** * Created by IntelliJ IDEA. * User: Richer @@ -42,12 +45,12 @@ public class ComboBoxDemo extends JPanel { double f = TableLayout.FILL; Component[][] coms = new Component[][]{ - {new UILabel(Inter.getLocText("Form-ComboCheckBox")+":"), createComboCheckBox()}, - {new UILabel(Inter.getLocText(new String[]{"DS-Dictionary", "Form-ComboBox"})+":"), createDictComboBox()}, - {new UILabel(Inter.getLocText("long_data_can_not_show_fully")+":"), createExtendedComboBox()}, - {new UILabel(Inter.getLocText(new String[]{"Filter", "Form-ComboBox"})+":"), createFilterComboBox()}, - {new UILabel(Inter.getLocText("Form-ComboBox")+":"), createTreeComboBox()}, - {new UILabel(Inter.getLocText(new String[]{"Delay", "Load", "Form-ComboBox"})+":"), createLazyComboBox()} + {new UILabel(Inter.getLocText("Form-ComboCheckBox") + ":"), createComboCheckBox()}, + {new UILabel(Inter.getLocText(new String[]{"DS-Dictionary", "Form-ComboBox"}) + ":"), createDictComboBox()}, + {new UILabel(Inter.getLocText("long_data_can_not_show_fully") + ":"), createExtendedComboBox()}, + {new UILabel(Inter.getLocText(new String[]{"Filter", "Form-ComboBox"}) + ":"), createFilterComboBox()}, + {new UILabel(Inter.getLocText("Form-ComboBox") + ":"), createTreeComboBox()}, + {new UILabel(Inter.getLocText(new String[]{"Delay", "Load", "Form-ComboBox"}) + ":"), createLazyComboBox()} }; double[] rowSize = new double[coms.length]; double[] columnSize = {p, f}; @@ -165,6 +168,7 @@ public class ComboBoxDemo extends JPanel { // 睡5秒 try { Thread.sleep(5000); + } catch (InterruptedException e) { FRContext.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/com/fr/design/gui/demo/SwingComponentsDemo.java b/designer-base/src/com/fr/design/gui/demo/SwingComponentsDemo.java index 6a08e38b0..a3771ce23 100644 --- a/designer-base/src/com/fr/design/gui/demo/SwingComponentsDemo.java +++ b/designer-base/src/com/fr/design/gui/demo/SwingComponentsDemo.java @@ -1,16 +1,15 @@ package com.fr.design.gui.demo; -import java.awt.BorderLayout; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; - -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.utils.DesignUtils; -import com.fr.design.utils.gui.GUICoreUtils; +import java.awt.BorderLayout; /** * Created by IntelliJ IDEA. @@ -19,10 +18,10 @@ import com.fr.design.utils.gui.GUICoreUtils; * Time: 下午4:54 */ public class SwingComponentsDemo extends JFrame { - public SwingComponentsDemo() { - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + private SwingComponentsDemo() { + this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); init(); - JPanel contentPane = (JPanel)getContentPane(); + JPanel contentPane = (JPanel) getContentPane(); contentPane.setLayout(FRGUIPaneFactory.createBorderLayout()); JTabbedPane tab = new JTabbedPane(); contentPane.add(tab, BorderLayout.CENTER); @@ -40,12 +39,12 @@ public class SwingComponentsDemo extends JFrame { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { JFrame f = new SwingComponentsDemo(); f.setSize(500, 500); f.setVisible(true); GUICoreUtils.centerWindow(f); - f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } }); } diff --git a/designer-base/src/com/fr/design/gui/icombobox/LazyComboBox.java b/designer-base/src/com/fr/design/gui/icombobox/LazyComboBox.java index fa4464cfc..2ec5590f6 100644 --- a/designer-base/src/com/fr/design/gui/icombobox/LazyComboBox.java +++ b/designer-base/src/com/fr/design/gui/icombobox/LazyComboBox.java @@ -3,212 +3,190 @@ */ package com.fr.design.gui.icombobox; -import java.awt.Dimension; -import java.util.ArrayList; -import java.util.List; +import com.fr.general.FRLogger; +import com.fr.general.Inter; -import javax.swing.*; +import javax.swing.DefaultComboBoxModel; +import javax.swing.SwingWorker; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; -import javax.swing.plaf.basic.BasicComboPopup; - -import com.fr.general.Inter; +import java.awt.Dimension; +import java.util.concurrent.ExecutionException; /** * @author richer + * @version 2018年2月6日14点43分 by @yaoh.wu * @since 6.5.5 创建于2011-6-15 延迟加载的下拉框 */ public abstract class LazyComboBox extends UIComboBox implements PopupMenuListener { - protected boolean loaded = false; - private List ls = new ArrayList(); - private Object initialSelected = null; - private static final int NUM=80; - - public static final Object PENDING = new Object() { - - @Override - public String toString() { - return Inter.getLocText("Loading") + "..."; - } - }; - - public LazyComboBox() { - super(); - this.setEditor(new FilterComboBoxEditor()); - addPopupMenuListener(this); -// updateUI(); - } - - public void setLoaded(boolean loaded) { - this.loaded = loaded; - } - - public abstract Object[] load(); - - public void setSelectedItem(Object anObject) { - initialSelected = anObject; - if (loaded) { - super.setSelectedItem(anObject); - } else { - - setModel(new DefaultComboBoxModel(new Object[] { anObject })); - super.setSelectedItem(anObject); - } - } - - /** - * 通过调用该方法,在点击下拉框按钮之前就加载好数据 - */ - public void loadInstant() { - if (loaded) { - return; - } - setModel(new DefaultComboBoxModel(load())); - loaded = true; - } - - @Override - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + + private static final int NUM = 80; + private static final String[] PENDING_CONTENT = new String[]{"", Inter.getLocText("Loading") + "..."}; + + /** + * 是否加载完成 + */ + protected boolean loaded = false; + + /** + * 初始化选项 + */ + private Object initialSelected = null; + + + protected LazyComboBox() { + super(); + this.setEditor(new FilterComboBoxEditor()); + addPopupMenuListener(this); + } + + public void setLoaded(boolean loaded) { + this.loaded = loaded; + } + + /** + * 加载下拉框中的选项 + * + * @return 下拉框中的选项 + */ + public abstract Object[] load(); + + @Override + public void setSelectedItem(Object anObject) { + initialSelected = anObject; + if (loaded) { + super.setSelectedItem(anObject); + } else { + this.setModel(new DefaultComboBoxModel<>(new Object[]{anObject})); + super.setSelectedItem(anObject); + } + } + + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { if (loaded) { return; } - DefaultComboBoxModel loadingModel = new DefaultComboBoxModel(new String[]{"", Inter.getLocText("Loading") + "..."}); - LazyComboBox.this.setModel(loadingModel); - new SwingWorker() { + DefaultComboBoxModel loadingModel = new DefaultComboBoxModel<>(PENDING_CONTENT); + this.setModel(loadingModel); + new SwingWorker() { @Override - protected Void doInBackground() throws Exception { - final Object selectedObj = getSelectedItem(); - loadList(); - return null; + protected Object[] doInBackground() { + return load(); } @Override public void done() { - LazyComboBox.this.updateUI(); - LazyComboBox.this.fireEvent(); + try { + LazyComboBox.this.loadList(get()); + } catch (InterruptedException | ExecutionException exception) { + FRLogger.getLogger().debug(exception.getMessage()); + } LazyComboBox.this.showPopup(); } - }.execute(); + } + /** + * 加载下拉列表 + */ + public void loadList() { + DefaultComboBoxModel model = new DefaultComboBoxModel<>(load()); + model.setSelectedItem(initialSelected); + this.setModel(model); + this.selectedItemReminder = initialSelected; + loaded = true; } - /** - * 计算加载下拉列表 - */ - public void loadList() { - DefaultComboBoxModel model = new DefaultComboBoxModel(load()); + /** + * 加载下拉列表 + * + * @param contents 下拉列表内容 + */ + private void loadList(Object[] contents) { + DefaultComboBoxModel model = new DefaultComboBoxModel<>(contents); model.setSelectedItem(initialSelected); - LazyComboBox.this.setModel(model); - LazyComboBox.this.selectedItemReminder = initialSelected ; - loaded = true; - } - - @Override - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - - } - - @Override - public void popupMenuCanceled(PopupMenuEvent e) { - - } - - public void addClickListener(EventListener l) { - if (ls == null) { - ls = new ArrayList(); - } - ls.add(l); - } - - public void fireEvent() { - for (int i = 0, n = ls.size(); i < n; i++) { - ls.get(i).fireEvent(); - } - } - - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.width = NUM; - return dim; - } - - private static class LazyPopMenu extends BasicComboPopup { - - public LazyPopMenu(final JComboBox combo) { - super(combo); - LazyComboBox comboc = (LazyComboBox) combo; - comboc.addClickListener(new EventListener() { - - @Override - public void fireEvent() { - LazyPopMenu.this.show(); - combo.showPopup(); - } - }); - } - } - - private interface EventListener { - void fireEvent(); - } - - class FilterComboBoxEditor extends UIComboBoxEditor implements DocumentListener { - private Object item; - private volatile boolean filtering = false; - private volatile boolean setting = false; - - public FilterComboBoxEditor() { - super(); - textField.getDocument().addDocumentListener(this); - } - - public void setItem(Object item) { - if (filtering) { - return; - } - this.item = item; - - this.setting = true; - textField.setSetting(true); - String newText = (item == null) ? "" : item.toString(); - textField.setText(newText); - textField.setSetting(false); - this.setting = false; - } - - public Object getItem() { - return this.item; - } - - public void insertUpdate(DocumentEvent e) { - handleChange(); - } - - public void removeUpdate(DocumentEvent e) { - handleChange(); - } - - public void changedUpdate(DocumentEvent e) { - handleChange(); - } - - protected void handleChange() { - if (setting) { - return; - } - filtering = true; - String xx = textField.getText(); - LazyComboBox.this.setSelectedItem(xx); - this.item = textField.getText(); - - setPopupVisible(true); - filtering = false; - } - } + this.setModel(model); + this.selectedItemReminder = initialSelected; + loaded = true; + } + + @Override + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + + } + + @Override + public void popupMenuCanceled(PopupMenuEvent e) { + + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + dim.width = NUM; + return dim; + } + + class FilterComboBoxEditor extends UIComboBoxEditor implements DocumentListener { + private Object item; + private volatile boolean filtering = false; + private volatile boolean setting = false; + + public FilterComboBoxEditor() { + super(); + textField.getDocument().addDocumentListener(this); + } + + @Override + public void setItem(Object item) { + if (filtering) { + return; + } + this.item = item; + this.setting = true; + textField.setSetting(true); + String newText = (item == null) ? "" : item.toString(); + textField.setText(newText); + textField.setSetting(false); + this.setting = false; + } + + @Override + public Object getItem() { + return this.item; + } + + @Override + public void insertUpdate(DocumentEvent e) { + handleChange(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + handleChange(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + handleChange(); + } + + void handleChange() { + if (setting) { + return; + } + filtering = true; + String xx = textField.getText(); + LazyComboBox.this.setSelectedItem(xx); + this.item = textField.getText(); + + setPopupVisible(true); + filtering = false; + } + } } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/gui/icombobox/UIComboBox.java b/designer-base/src/com/fr/design/gui/icombobox/UIComboBox.java index f9ce6b78f..14a90da7b 100644 --- a/designer-base/src/com/fr/design/gui/icombobox/UIComboBox.java +++ b/designer-base/src/com/fr/design/gui/icombobox/UIComboBox.java @@ -4,12 +4,13 @@ import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; -import com.fr.design.utils.gui.GUICoreUtils; -import javax.swing.*; +import javax.swing.ComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.ListCellRenderer; import javax.swing.plaf.ComboBoxUI; import javax.swing.plaf.basic.ComboPopup; -import java.awt.*; +import java.awt.Dimension; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; @@ -112,8 +113,6 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser public void setRenderer(ListCellRenderer aRenderer) { if (aRenderer instanceof UIComboBoxRenderer) { super.setRenderer(aRenderer); - } else { - //throw new IllegalArgumentException("Must be UIComboBoxRenderer"); } } @@ -121,13 +120,15 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser return null; } + @Override public void setGlobalName(String name) { comboBoxName = name; } @Override public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width + SIZE5, SIZE);//加5的原因在于:render里,每一个项前面了空了一格,要多几像素 + //加5的原因在于:render里,每一个项前面了空了一格,要多几像素 + return new Dimension(super.getPreferredSize().width + SIZE5, SIZE); } /** @@ -144,70 +145,53 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser } - /** - * - */ + /** + * + */ + @Override public void updateUI() { setUI(getUIComboBoxUI()); } - /** - * - * @param listener 观察者监听事件 - */ + /** + * @param listener 观察者监听事件 + */ + @Override public void registerChangeListener(UIObserverListener listener) { uiObserverListener = listener; } - public void removeChangeListener(){ + public void removeChangeListener() { uiObserverListener = null; } - public UIObserverListener getUiObserverListener(){ + public UIObserverListener getUiObserverListener() { return uiObserverListener; } /** - * @return + * @return 是否响应变更事件 */ + @Override public boolean shouldResponseChangeListener() { return true; } - /** - * - * @param listener 观察者监听事件 - */ + /** + * @param listener 观察者监听事件 + */ + @Override public void registerNameListener(GlobalNameListener listener) { globalNameListener = listener; } - /** - * - * @return - */ - public boolean shouldResponseNameListener() { - return true; - } - - /** - * @param args + * @return 是否响应名称事件 */ - public static void main(String... args) { - LayoutManager layoutManager = null; - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(layoutManager); - UIComboBox bb = new UIComboBox(new String[]{"", "jerry", "kunsnat", "richer"}); - bb.setEditable(true); - bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); - content.add(bb); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 400); - jf.setVisible(true); + @Override + public boolean shouldResponseNameListener() { + return true; } diff --git a/designer-realize/src/com/fr/design/dscolumn/DSColumnPane.java b/designer-realize/src/com/fr/design/dscolumn/DSColumnPane.java index 2e5d25189..af48fb853 100644 --- a/designer-realize/src/com/fr/design/dscolumn/DSColumnPane.java +++ b/designer-realize/src/com/fr/design/dscolumn/DSColumnPane.java @@ -1,26 +1,30 @@ package com.fr.design.dscolumn; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - import com.fr.base.FRContext; import com.fr.data.TableDataSource; +import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; -import com.fr.general.Inter; import com.fr.design.mainframe.ElementCasePane; +import com.fr.general.Inter; import com.fr.report.cell.CellElement; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** + * @author null + * @version 2018年2月9日13点47分 + * @since 8.0 + */ public class DSColumnPane extends BasicPane { private TableDataSource tplEC; @@ -29,17 +33,56 @@ public class DSColumnPane extends BasicPane { private DSColumnConditionsPane conditionPane = null; private DSColumnAdvancedPane advancedPane = null; private TemplateCellElement cellElement; - protected Component lastSelectedComponent; - + private Component lastSelectedComponent; + public static final int SETTING_ALL = 2; public static final int SETTING_DSRELATED = 1; - + + + private ChangeListener appliedWizardTabChangeListener = new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent evt) { + try { + if (lastSelectedComponent == null) { + lastSelectedComponent = basicPane; + } + // selectTabComponent是正要切换到的那个Pane + Component selectTabComponent = tabbedPane.getSelectedComponent(); + // denny: 如果切换Tab时上一个Pane是basicPane, 则刷新一下其他Pane, + // 因为选择的数据列可能改变, 导致后面过滤和使用公式用到的数据项改变 + if (lastSelectedComponent == basicPane) { + basicPane.update(cellElement); + + // denny_GUI: 刷新其他面板 + refreshOtherTabs(); + } + // 切换标签的时候就,确认是否有没有添加到列表中的条件 + lastSelectedComponent = selectTabComponent; + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + + } + }; + /** + * cellElement 改变时,刷新一下 + * 比如:上边切换Tab时,basicPane Update了一下,可能会改变Field cellElement的值 + */ + private PropertyChangeListener myPropertyChangeListener = new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + refreshOtherTabs(); + } + }; + public DSColumnPane() { - this.initComponents(SETTING_ALL); + this(SETTING_ALL); } - + public DSColumnPane(int setting) { - this.initComponents(setting); + this.initComponents(setting); } protected void initComponents(int setting) { @@ -65,18 +108,22 @@ public class DSColumnPane extends BasicPane { this.setPreferredSize(new Dimension(610, 400)); } - + @Override protected String title4PopupWindow() { - return Inter.getLocText("ExpandD-Data_Column"); + return Inter.getLocText("ExpandD-Data_Column"); } - /* - * populate + /** + * 更新面板信息 + * + * @param tds 数据源 + * @param cellElement 单元格 + * @throws Exception e */ public void populate(TableDataSource tds, TemplateCellElement cellElement) throws Exception { - this.tplEC = tds; - + this.tplEC = tds; + if (tds == null || cellElement == null) { // _denny: 我不认为这种情况应该出现,以防万一 this.cellElement = new DefaultTemplateCellElement(); @@ -85,15 +132,18 @@ public class DSColumnPane extends BasicPane { // _denny: 这边需要克隆一下,因为在设置时,可能改变字段cellElement,但改变真实值是不被期望的 try { this.cellElement = (TemplateCellElement) cellElement.clone(); - } catch (CloneNotSupportedException ce) { + } catch (CloneNotSupportedException ignored) { } + //REPORT-7744 9.0里面过滤条件和高级设置可以通过其他地方设置,populate的时候需要更新所有面板的信息,防止设置丢失 this.basicPane.populate(tds, this.cellElement); this.conditionPane.populate(tds, this.cellElement); this.advancedPane.populate(this.cellElement); } - /* - * update + /** + * update 保存 + * + * @return 单元格信息 */ public CellElement update() { this.basicPane.update(cellElement); @@ -101,54 +151,24 @@ public class DSColumnPane extends BasicPane { this.advancedPane.update(cellElement); return cellElement; } - public ChangeListener appliedWizardTabChangeListener = new ChangeListener() { - - public void stateChanged(ChangeEvent evt) { - try { - if (lastSelectedComponent == null) { - lastSelectedComponent = basicPane; - } - //selectTabComponent是正要切换到的那个Pane - Component selectTabComponent = tabbedPane.getSelectedComponent(); - // _denny: 如果切换Tab时上一个Pane是basicPane, 则刷新一下其他Pane, - // 因为选择的数据列可能改变, 导致后面过滤和使用公式用到的数据项改变 - if (lastSelectedComponent == basicPane) { - basicPane.update(cellElement); - - // denny_GUI: 刷新其他面板 - refrushOtherTabs(); - } - // 切换标签的时候就,确认是否有没有添加到列表中的条件 - lastSelectedComponent = selectTabComponent; - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - } - }; - // cellElement 改变时,刷新一下 - // 比如:上边切换Tab时,basicPane Update了一下,可能会改变Field cellElement的值 - PropertyChangeListener myPropertyChangeListener = new PropertyChangeListener() { - - public void propertyChange(PropertyChangeEvent evt) { - refrushOtherTabs(); - } - }; - - //_denny:当数据tab中的数据发生变化的时候刷新后面的tab - public void refrushOtherTabs() { - // ——deny:当JTabPane中加入一个Pane时,后面的Pane可能还没有初始化 + /** + * denny:当数据tab中的数据发生变化的时候刷新后面的tab + */ + private void refreshOtherTabs() { + // deny:当JTabPane中加入一个Pane时,后面的Pane可能还没有初始化 if (conditionPane == null || advancedPane == null) { return; } this.conditionPane.populate(tplEC, cellElement); this.advancedPane.populate(cellElement); } - public void putElementcase(ElementCasePane t){ - basicPane.putElementcase(t); + + public void putElementcase(ElementCasePane t) { + basicPane.putElementcase(t); } - public void putCellElement(TemplateCellElement tplCE) { - basicPane.putCellElement(tplCE); - } + public void putCellElement(TemplateCellElement tplCE) { + basicPane.putCellElement(tplCE); + } } \ No newline at end of file From 2eaeba9f964ea531d19d43be00cedc7340fc932f Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 19:04:24 +0800 Subject: [PATCH 06/11] =?UTF-8?q?REPORT-6949=20=E6=9D=A1=E4=BB=B6=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=9A=84=E8=B6=85=E7=BA=A7=E9=93=BE=E6=8E=A5=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E5=90=8E=E4=BC=9A=E8=87=AA=E5=8A=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E8=B6=85=E7=BA=A7=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/frpane/HyperlinkGroupPane.java | 34 +++++++++----- .../HyperlinkGroupPaneActionProvider.java | 14 ++++++ .../gui/xpane/FormHyperlinkGroupPane.java | 47 ++++++++++--------- .../mainframe/ElementCasePaneDelegate.java | 36 +++++++------- .../ReportHyperlinkGroupPaneNoPop.java | 5 ++ 5 files changed, 84 insertions(+), 52 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer-base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java index 5e7ce6627..17a33419e 100644 --- a/designer-base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java +++ b/designer-base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java @@ -44,15 +44,12 @@ public abstract class HyperlinkGroupPane extends UIListControlPane { @Override public void on(PluginEvent event) { - - refreshNameableCreator(createNameableCreators()); - + refreshNameableCreator(createNameableCreators()); } }, new PluginFilter() { @Override public boolean accept(PluginContext context) { - return context.contain(HyperlinkProvider.XML_TAG); } }); @@ -63,6 +60,7 @@ public abstract class HyperlinkGroupPane extends UIListControlPane { * * @return 返回Nameable按钮数组. */ + @Override public NameableCreator[] createNameableCreators() { Map nameCreators = new ListMap<>(); NameableCreator[] creators = DesignModuleFactory.getHyperlinkGroupType().getHyperlinkCreators(); @@ -82,6 +80,7 @@ public abstract class HyperlinkGroupPane extends UIListControlPane { * * @return 返回标题字符串. */ + @Override public String title4PopupWindow() { return Inter.getLocText("FR-Designer_Hyperlink"); } @@ -91,11 +90,11 @@ public abstract class HyperlinkGroupPane extends UIListControlPane { return Inter.getLocText("FR-Designer_Add_Hyperlink"); } - public void populate(NameJavaScriptGroup nameHyperlink_array) { - java.util.List list = new ArrayList(); - if (nameHyperlink_array != null) { - for (int i = 0; i < nameHyperlink_array.size(); i++) { - list.add(new NameObject(nameHyperlink_array.getNameHyperlink(i).getName(), nameHyperlink_array.getNameHyperlink(i).getJavaScript())); + public void populate(NameJavaScriptGroup hyperlinkArray) { + java.util.List list = new ArrayList<>(); + if (hyperlinkArray != null) { + for (int i = 0; i < hyperlinkArray.size(); i++) { + list.add(new NameObject(hyperlinkArray.getNameHyperlink(i).getName(), hyperlinkArray.getNameHyperlink(i).getJavaScript())); } } @@ -113,20 +112,29 @@ public abstract class HyperlinkGroupPane extends UIListControlPane { */ public NameJavaScriptGroup updateJSGroup() { Nameable[] res = this.update(); - NameJavaScript[] res_array = new NameJavaScript[res.length]; + NameJavaScript[] resArray = new NameJavaScript[res.length]; for (int i = 0; i < res.length; i++) { NameObject no = (NameObject) res[i]; - res_array[i] = new NameJavaScript(no.getName(), (JavaScript) no.getObject()); + resArray[i] = new NameJavaScript(no.getName(), (JavaScript) no.getObject()); } - return new NameJavaScriptGroup(res_array); + return new NameJavaScriptGroup(resArray); } @Override public void saveSettings() { - if (isPopulating) { + if (isPopulating || !needAutoSave()) { return; } hyperlinkGroupPaneActionProvider.saveSettings(this); } + + /** + * 是否需要自动保存到超级链接属性中 + * + * @return 是否需要自动保存 + */ + public boolean needAutoSave() { + return true; + } } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java b/designer-base/src/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java index a5f7ae9a6..525bb5b79 100644 --- a/designer-base/src/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java +++ b/designer-base/src/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java @@ -3,9 +3,23 @@ package com.fr.design.gui.frpane; import com.fr.design.designer.TargetComponent; /** + * @author plough * Created by plough on 2017/7/26. */ public interface HyperlinkGroupPaneActionProvider { + + /** + * 刷新面板展示 + * + * @param hyperlinkGroupPane 超链面板 + * @param elementCasePane 模板 + */ void populate(HyperlinkGroupPane hyperlinkGroupPane, TargetComponent elementCasePane); + + /** + * 保存到文件 + * + * @param hyperlinkGroupPane 超联面板 + */ void saveSettings(HyperlinkGroupPane hyperlinkGroupPane); } diff --git a/designer-form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java b/designer-form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java index 2f879792e..e96eef26e 100644 --- a/designer-form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java +++ b/designer-form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java @@ -1,42 +1,43 @@ package com.fr.design.gui.xpane; +import com.fr.design.form.javascript.FormEmailPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.HyperlinkGroupPane; -import com.fr.design.form.javascript.FormEmailPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.js.EmailJavaScript; -public class FormHyperlinkGroupPane extends HyperlinkGroupPane{ - private static FormHyperlinkGroupPane singleton; +public class FormHyperlinkGroupPane extends HyperlinkGroupPane { + private static FormHyperlinkGroupPane singleton; - protected FormHyperlinkGroupPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { - super(hyperlinkGroupPaneActionProvider); - } + protected FormHyperlinkGroupPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + super(hyperlinkGroupPaneActionProvider); + } - public synchronized static FormHyperlinkGroupPane getInstance(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { - if (singleton == null) { - singleton = new FormHyperlinkGroupPane(hyperlinkGroupPaneActionProvider); - } - return singleton; - } + public synchronized static FormHyperlinkGroupPane getInstance(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + if (singleton == null) { + singleton = new FormHyperlinkGroupPane(hyperlinkGroupPaneActionProvider); + } + return singleton; + } - /** + /** * 生成添加按钮的NameableCreator * 由于表单报表块的单元格超链和单元格条件属性超链中的emailPane都要用表单的emailPane,这里调整下 * * @return 返回Nameable按钮数组. */ - public NameableCreator[] createNameableCreators() { - NameableCreator[] creators = super.createNameableCreators(); - for (int i=0; i { CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); QuickEditorRegion.getInstance().populate(getCurrentEditor()); JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + // 模板初始化完成后,才能初始化超级链接面板 if (editingTemplate != null && !editingTemplate.isUpMode()) { Selection editingSelection = getSelection(); - // 模板初始化完成后,才能初始化超级链接面板 + // 获取超级链接面板并刷新显示 HyperlinkGroupPane hyperlinkGroupPane = editingTemplate.getHyperLinkPane(HyperlinkGroupPaneActionImpl.getInstance()); - hyperlinkGroupPane.populate(ElementCasePaneDelegate.this); if (editingSelection instanceof FloatSelection) { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_FLOAT); JPanel floatPane = new JPanel(new BorderLayout()); diff --git a/designer-realize/src/com/fr/design/mainframe/ReportHyperlinkGroupPaneNoPop.java b/designer-realize/src/com/fr/design/mainframe/ReportHyperlinkGroupPaneNoPop.java index 451c89975..91c8b65d8 100644 --- a/designer-realize/src/com/fr/design/mainframe/ReportHyperlinkGroupPaneNoPop.java +++ b/designer-realize/src/com/fr/design/mainframe/ReportHyperlinkGroupPaneNoPop.java @@ -24,4 +24,9 @@ public class ReportHyperlinkGroupPaneNoPop extends ReportHyperlinkGroupPane{ protected boolean isNewStyle() { return false; } + + @Override + public boolean needAutoSave() { + return false; + } } From e06c49e5c539ad5b381d8049b1eeee1565a91240 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 19:17:35 +0800 Subject: [PATCH 07/11] =?UTF-8?q?REPORT-6973=20=E6=A8=A1=E6=9D=BF=E7=9F=AD?= =?UTF-8?q?=E4=BF=A1=E4=BA=8B=E4=BB=B6=20=E6=8F=92=E4=BB=B6=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/LoginDialog.java | 17 +++- .../com/fr/design/extra/WebViewDlgHelper.java | 53 ++++++++--- .../fr/design/mainframe/bbs/UserInfoPane.java | 90 +++++++++++-------- .../src/com/fr/start/Designer.java | 2 +- 4 files changed, 110 insertions(+), 52 deletions(-) diff --git a/designer-base/src/com/fr/design/extra/LoginDialog.java b/designer-base/src/com/fr/design/extra/LoginDialog.java index 6ae8a63f9..33983baf2 100644 --- a/designer-base/src/com/fr/design/extra/LoginDialog.java +++ b/designer-base/src/com/fr/design/extra/LoginDialog.java @@ -4,8 +4,12 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StableUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Frame; /** * Created by vito on 2017/5/5. @@ -15,6 +19,15 @@ public class LoginDialog extends UIDialog { public LoginDialog(Frame frame, Component pane) { super(frame); + init(pane); + } + + public LoginDialog(Dialog dialog, Component pane) { + super(dialog); + init(pane); + } + + private void init(Component pane) { if (StableUtils.getMajorJavaVersion() == 8) { setUndecorated(true); } diff --git a/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java index 59fb61276..461f950bd 100644 --- a/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java @@ -22,6 +22,9 @@ import javax.swing.JOptionPane; import javax.swing.SwingWorker; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; @@ -133,18 +136,22 @@ public class WebViewDlgHelper { if (StableUtils.getMajorJavaVersion() == VERSION_8) { File file = new File(StableUtils.pathJoin(installHome, "scripts")); if (!file.exists()) { - int rv = JOptionPane.showConfirmDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE - ); - if (rv == JOptionPane.OK_OPTION) { - downloadShopScripts(SHOP_SCRIPTS); - } + confirmDownLoadShopJS(); } else { - showLoginDlg(); + showLoginDlg(DesignerContext.getDesignerFrame()); + updateShopScripts(SHOP_SCRIPTS); + } + } + } + + + public static void createLoginDialog(Window parent) { + if (StableUtils.getMajorJavaVersion() == VERSION_8) { + File file = new File(StableUtils.pathJoin(installHome, "scripts")); + if (!file.exists()) { + confirmDownLoadShopJS(); + } else { + showLoginDlg(parent); updateShopScripts(SHOP_SCRIPTS); } } @@ -164,6 +171,20 @@ public class WebViewDlgHelper { } } + + private static void confirmDownLoadShopJS() { + int rv = JOptionPane.showConfirmDialog( + null, + Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + downloadShopScripts(SHOP_SCRIPTS); + } + } + private static void showPluginDlg(String mainJsPath) { try { Class clazz = Class.forName("com.fr.design.extra.PluginWebPane"); @@ -179,13 +200,17 @@ public class WebViewDlgHelper { } } - private static void showLoginDlg() { + private static void showLoginDlg(Window window) { try { Class clazz = Class.forName("com.fr.design.extra.LoginWebPane"); Constructor constructor = clazz.getConstructor(String.class); Component webPane = (Component) constructor.newInstance(installHome); - - UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), webPane); + UIDialog qqdlg; + if (window instanceof Dialog) { + qqdlg = new LoginDialog((Dialog) window, webPane); + } else { + qqdlg = new LoginDialog((Frame) window, webPane); + } LoginWebBridge.getHelper().setDialogHandle(qqdlg); qqdlg.setVisible(true); } catch (Throwable ignored) { diff --git a/designer-realize/src/com/fr/design/mainframe/bbs/UserInfoPane.java b/designer-realize/src/com/fr/design/mainframe/bbs/UserInfoPane.java index 3fae72f92..69392dd39 100644 --- a/designer-realize/src/com/fr/design/mainframe/bbs/UserInfoPane.java +++ b/designer-realize/src/com/fr/design/mainframe/bbs/UserInfoPane.java @@ -11,7 +11,6 @@ import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.mainframe.DesignerContext; import com.fr.general.DateUtils; -import com.fr.general.FRLogger; import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.stable.EnvChangedListener; @@ -32,27 +31,42 @@ import java.util.Date; */ public class UserInfoPane extends BasicPane { - //默认未登录颜色 + /** + * 默认未登录颜色 + */ private static final Color UN_LOGIN_BACKGROUND = UIConstants.TEMPLATE_TAB_PANE_BACKGROUND; private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242); private static final int WIDTH = 104; private static final int HEIGHT = 24; - //登录成功 + /** + * 登录成功 + */ private static final String LOGININ = "0"; - // 登录框弹出间隔时间 + /** + * 登录框弹出间隔时间 + */ private static final int LOGIN_DIFF_DAY = 7; - // 等待国际化等相关初始化工作完成之后再弹出登录框 + /** + * 等待国际化等相关初始化工作完成之后再弹出登录框 + */ private static final int WAIT_TIME = 10000; private UserInfoLabel userInfoLabel; + private static UserInfoPane instance = new UserInfoPane(); + + + public static UserInfoPane getInstance() { + return instance; + } + /** * 构造函数 */ - public UserInfoPane() { + private UserInfoPane() { this.setPreferredSize(new Dimension(WIDTH, HEIGHT)); this.setLayout(new BorderLayout()); @@ -73,6 +87,34 @@ public class UserInfoPane extends BasicPane { this.userInfoLabel = userInfoLabel; } + + /** + * 标志未登录状态, 面板设置为灰色 + */ + public void markUnSignIn() { + this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); + this.userInfoLabel.setOpaque(true); + this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND); + this.userInfoLabel.resetUserName(); + } + + /** + * 标志登陆状态, 面包设置为蓝色 + * + * @param userName 用户名 + */ + public void markSignIn(String userName) { + this.userInfoLabel.setText(userName); + this.userInfoLabel.setUserName(userName); + this.userInfoLabel.setOpaque(true); + this.userInfoLabel.setBackground(LOGIN_BACKGROUND); + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + private void addEnvChangedListener() { GeneralContext.addEnvChangedListener(new EnvChangedListener() { @Override @@ -90,11 +132,15 @@ public class UserInfoPane extends BasicPane { } - // 计算xml保存的上次弹框时间和当前时间的时间差 + /** + * 计算xml保存的上次弹框时间和当前时间的时间差 + * + * @return 时间差 + */ private int getDiffFromLastLogin() { String lastBBSTime = DesignerEnvManager.getEnvManager().getLastShowBBSTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Date lastBBSDate = null; + Date lastBBSDate; try { if (lastBBSTime != null) { synchronized (this) { @@ -108,7 +154,7 @@ public class UserInfoPane extends BasicPane { return dayNew - dayOld; } } catch (ParseException e) { - FRLogger.getLogger().error(e.getMessage()); + FRContext.getLogger().error(e.getMessage()); } return 1; } @@ -153,31 +199,5 @@ public class UserInfoPane extends BasicPane { showBBSThread.start(); } - /** - * 标志未登录状态, 面板设置为灰色 - */ - public void markUnSignIn() { - this.userInfoLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); - this.userInfoLabel.setOpaque(true); - this.userInfoLabel.setBackground(UN_LOGIN_BACKGROUND); - this.userInfoLabel.resetUserName(); - } - - /** - * 标志登陆状态, 面包设置为蓝色 - * - * @param userName 用户名 - */ - public void markSignIn(String userName) { - this.userInfoLabel.setText(userName); - this.userInfoLabel.setUserName(userName); - this.userInfoLabel.setOpaque(true); - this.userInfoLabel.setBackground(LOGIN_BACKGROUND); - } - - @Override - protected String title4PopupWindow() { - return StringUtils.EMPTY; - } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index af2ababb1..7ee3e6f35 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -369,7 +369,7 @@ public class Designer extends BaseDesigner { @Override public Component createBBSLoginPane() { if (userInfoPane == null) { - userInfoPane = new UserInfoPane(); + userInfoPane = UserInfoPane.getInstance(); } return userInfoPane; } From fe9584ccfe4861372923c937644e6311e344dc5a Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 19:30:13 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E6=97=A0=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E5=81=9A=E7=9F=AD=E4=BF=A1=E4=BA=8B=E4=BB=B6=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=8F=91=E7=8E=B0=E7=9A=84=E8=AE=BE=E8=AE=A1=E5=99=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/editor/editor/ColumnRowEditor.java | 125 +++++++++--------- .../fr/design/editor/editor/TextEditor.java | 34 +++-- 2 files changed, 91 insertions(+), 68 deletions(-) diff --git a/designer-base/src/com/fr/design/editor/editor/ColumnRowEditor.java b/designer-base/src/com/fr/design/editor/editor/ColumnRowEditor.java index d596b8c6e..2da3bc310 100644 --- a/designer-base/src/com/fr/design/editor/editor/ColumnRowEditor.java +++ b/designer-base/src/com/fr/design/editor/editor/ColumnRowEditor.java @@ -4,71 +4,78 @@ import com.fr.design.gui.columnrow.ColumnRowPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.stable.ColumnRow; -import java.awt.*; +import java.awt.BorderLayout; /** * the editor to edit ColumnRow * - * @editor zhou + * @author zhou * @since 2012-3-29下午6:01:37 */ public class ColumnRowEditor extends Editor { - private ColumnRowPane crPane; - - public ColumnRowEditor() { - this(""); - } - - public ColumnRowEditor(String name) { - this(null, name); - } - - - public ColumnRowEditor(ColumnRow value) { - this(value, ""); - } - - public ColumnRowEditor(ColumnRow value, String name) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - crPane = new ColumnRowPane(); - this.add(crPane, BorderLayout.CENTER); - this.setValue(value); - this.setName(name); - } - - @Override - public ColumnRow getValue() { - return this.crPane.update(); - } - - @Override - public void setValue(ColumnRow value) { - if (value == null) { - value = ColumnRow.valueOf(0, 0); - } - - this.crPane.populate(value); - } - - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - - this.crPane.setEnabled(enabled); - } - - @Override - public void requestFocus() { - this.crPane.requestFocus(); - } - - public String getIconName() { - return "cell"; - } - - @Override - public boolean accept(Object object) { - return object instanceof ColumnRow; - } + private ColumnRowPane crPane; + + public ColumnRowEditor() { + this(""); + } + + public ColumnRowEditor(String name) { + this(null, name); + } + + + public ColumnRowEditor(ColumnRow value) { + this(value, ""); + } + + public ColumnRowEditor(ColumnRow value, String name) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + crPane = new ColumnRowPane(); + this.add(crPane, BorderLayout.CENTER); + this.setValue(value); + this.setName(name); + } + + @Override + public ColumnRow getValue() { + return this.crPane.update(); + } + + @Override + public void setValue(ColumnRow value) { + if (value == null) { + value = ColumnRow.valueOf(0, 0); + } + + this.crPane.populate(value); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + + this.crPane.setEnabled(enabled); + } + + @Override + public void requestFocus() { + this.crPane.requestFocus(); + } + + @Override + public String getIconName() { + return "cell"; + } + + @Override + public boolean accept(Object object) { + return object instanceof ColumnRow; + } + + @Override + public void clearData() { + super.clearData(); + this.setValue(null); + } } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/editor/editor/TextEditor.java b/designer-base/src/com/fr/design/editor/editor/TextEditor.java index 8700db078..630f6956a 100644 --- a/designer-base/src/com/fr/design/editor/editor/TextEditor.java +++ b/designer-base/src/com/fr/design/editor/editor/TextEditor.java @@ -3,26 +3,31 @@ */ package com.fr.design.editor.editor; -import java.awt.BorderLayout; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; - import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.Inter; import com.fr.stable.StringUtils; +import java.awt.BorderLayout; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + /** * CellEditor used to edit String object. * - * @editor zhou + * @author zhou * @since 2012-3-29下午6:00:43 */ public class TextEditor extends Editor { - private UITextField textField; // text field. - // the old value of text field. + /** + * text field. + */ + private UITextField textField; + /** + * the old value of text field. + */ private String oldValue = StringUtils.EMPTY; /** @@ -93,7 +98,7 @@ public class TextEditor extends Editor { value = StringUtils.EMPTY; } - oldValue = value.toString(); + oldValue = value; this.textField.setText(oldValue); } @@ -110,6 +115,7 @@ public class TextEditor extends Editor { /** * 请求焦点 */ + @Override public void requestFocus() { this.textField.requestFocus(); } @@ -133,10 +139,12 @@ public class TextEditor extends Editor { /** * 被选中时文本输入框请求焦点 */ + @Override public void selected() { this.textField.requestFocus(); } + @Override public String getIconName() { return "type_string"; } @@ -147,7 +155,15 @@ public class TextEditor extends Editor { * @param object 需要判断的object * @return 是字符类型则返回true */ + @Override public boolean accept(Object object) { return object instanceof String; } + + @Override + public void clearData() { + super.clearData(); + this.textField.setText(StringUtils.EMPTY); + this.oldValue = StringUtils.EMPTY; + } } \ No newline at end of file From b215a6abed009074e0c66d37bdaa801a845c155b Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 19:32:01 +0800 Subject: [PATCH 09/11] =?UTF-8?q?REPORT-7261=20=E5=8F=B3=E4=BE=A7=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E7=BC=96=E8=BE=91=E9=9D=A2=E6=9D=BF=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/controlpane/UIControlPane.java | 64 +++++++++++++++---- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/controlpane/UIControlPane.java b/designer-base/src/com/fr/design/gui/controlpane/UIControlPane.java index bc37a2549..d0a4c12c5 100644 --- a/designer-base/src/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer-base/src/com/fr/design/gui/controlpane/UIControlPane.java @@ -17,10 +17,34 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSplitPane; import javax.swing.border.EmptyBorder; -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; /** * Created by plough on 2017/7/21. @@ -47,7 +71,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH } public UIControlPane(BasePlot plot) { - this.plot =plot; + this.plot = plot; this.initComponentPane(); } @@ -145,8 +169,8 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH this.checkButtonEnabled(); } - protected void getPopupEditDialog (JPanel cardPane) { - popupEditDialog = new PopupEditDialog(cardPane); + protected void getPopupEditDialog(JPanel cardPane) { + popupEditDialog = new PopupEditDialog(cardPane); } protected abstract JPanel createControlUpdatePane(); @@ -169,7 +193,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH toolbarDef.addShortCut(sj.getShortCut()); } toolBar = ToolBarDef.createJToolBar(); - toolBar.setUI(new UIToolBarUI(){ + toolBar.setUI(new UIToolBarUI() { @Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g; @@ -186,7 +210,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH leftContentPane.add(toolBarPane, BorderLayout.NORTH); // 顶部标签及add按钮 - topToolBar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI(){ + topToolBar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI() { @Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g; @@ -207,15 +231,15 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH return leftPane; } - protected JPanel getLeftTopPane (UIToolbar topToolBar) { + protected JPanel getLeftTopPane(UIToolbar topToolBar) { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = { p, f, isNewStyle() ? TOP_TOOLBAR_WIDTH : TOP_TOOLBAR_WIDTH_SHORT}; + double[] columnSize = {p, f, isNewStyle() ? TOP_TOOLBAR_WIDTH : TOP_TOOLBAR_WIDTH_SHORT}; double[] rowSize = {TOP_TOOLBAR_HEIGHT}; Component[][] components = new Component[][]{ new Component[]{new UILabel(getAddItemText()), new JPanel(), topToolBar}, }; - return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } /** @@ -336,6 +360,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH initListener(); } + @Override public void setTitle(String title) { popupToolPane.setTitle(title); } @@ -349,10 +374,21 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH } // 如果有可见模态对话框,则不隐藏 for (Window window : DesignerContext.getDesignerFrame().getOwnedWindows()) { - if (window instanceof JDialog && window.isVisible() && ((JDialog)window).isModal()) { + if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) { return; } } + + // 要隐藏 先检查有没有非法输入 + // 非法输入检查放在最后,因为可能出现面板弹出新弹框而失去焦点的情况,比如 输入公式时,弹出公式编辑对话框 + try { + checkValid(); + } catch (Exception exp) { + // 存在非法输入 拒绝隐藏 + JOptionPane.showMessageDialog(UIControlPane.this.controlUpdatePane, exp.getMessage()); + this.requestFocus(); + return; + } saveSettings(); setVisible(false); } @@ -361,7 +397,6 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH addWindowFocusListener(new WindowAdapter() { @Override public void windowLostFocus(WindowEvent e) { - super.windowLostFocus(e); hideDialog(); } }); @@ -389,6 +424,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH } repaint(); } + @Override public void mouseReleased(MouseEvent e) { mouseDownCompCoords = null; @@ -396,6 +432,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH contentPane.setBackground(originColor); } } + @Override public void mousePressed(MouseEvent e) { mouseDownCompCoords = e.getPoint(); @@ -409,6 +446,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH contentPane.setBackground(UIConstants.POPUP_TITLE_BACKGROUND); repaint(); } + @Override public void mouseDragged(MouseEvent e) { if (mouseDownCompCoords != null) { From 108372f534fa23b1028a458f08b457def20c2746 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 19:39:55 +0800 Subject: [PATCH 10/11] =?UTF-8?q?REPORT-8105=20=E4=BF=AE=E6=94=B9=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E7=94=BB=E5=B8=83=E5=9D=97=E7=BC=A9=E6=94=BE=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/designer/creator/XWAbsoluteLayout.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index 58c5f74dd..6a03f48c5 100644 --- a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -292,6 +292,11 @@ public class XWAbsoluteLayout extends XLayoutContainer { this.setLayout(new FRAbsoluteLayout()); } + @Override + protected void initStyle() { + // do nothing + } + /** * 是否支持标题样式 * From 501ea1fb40ac0d645cc1074cefeda0ba5940f044 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 29 May 2018 19:48:25 +0800 Subject: [PATCH 11/11] =?UTF-8?q?REPORT-8114=20=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E5=AD=97=E5=85=B8=20=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=97=A0?= =?UTF-8?q?=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/ChoosePane.java | 110 +++++++++++------- 1 file changed, 71 insertions(+), 39 deletions(-) diff --git a/designer-base/src/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/com/fr/design/data/datapane/ChoosePane.java index 5e9c16bde..281a61de5 100644 --- a/designer-base/src/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/com/fr/design/data/datapane/ChoosePane.java @@ -37,7 +37,11 @@ import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.SwingWorker; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.PopupMenuEvent; @@ -48,7 +52,9 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; @@ -85,6 +91,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha private PopupMenuListener popupMenuListener = new PopupMenuListener() { + @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { new Thread() { @Override @@ -94,26 +101,41 @@ public class ChoosePane extends BasicBeanPane implements Refresha }.start(); } + @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } + @Override public void popupMenuCanceled(PopupMenuEvent e) { } }; private PopupMenuListener listener = new PopupMenuListener() { + @Override public void popupMenuCanceled(PopupMenuEvent e) { } + @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } + @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { executePopulateWorker(); } }; + private FocusAdapter focusAdapter = new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + if (schemaBox.getSelectedIndex() == -1) { + schemaBox.updateUI(); + schemaBox.showPopup(); + } + } + }; + public ChoosePane() { this(null); } @@ -146,6 +168,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha private void initBoxListener() { addDSBoxListener(); schemaBox.addItemListener(new ItemListener() { + @Override public void itemStateChanged(ItemEvent evt) { tableNameComboBox.setSelectedItem(""); } @@ -176,16 +199,9 @@ public class ChoosePane extends BasicBeanPane implements Refresha } protected void addFocusListener() { - schemaBox.addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - if (schemaBox.getSelectedIndex() == -1) { - schemaBox.updateUI(); - schemaBox.showPopup(); - } - } - }); } + @SuppressWarnings("unchecked") protected void initDsNameComboBox() { dsNameComboBox.setRefreshingModel(true); ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); @@ -233,12 +249,18 @@ public class ChoosePane extends BasicBeanPane implements Refresha } populateWorker = new SwingWorker() { - protected com.fr.data.impl.Connection doInBackground() throws Exception { + @SuppressWarnings("unchecked") + @Override + protected com.fr.data.impl.Connection doInBackground() { + schemaBox.setRefreshingModel(true); schemaBox.addItem(Inter.getLocText("FR-Designer_Loading") + "..."); schemaBox.setSelectedItem(null); + schemaBox.setRefreshingModel(false); return getConnection(); } + @SuppressWarnings("unchecked") + @Override public void done() { try { com.fr.data.impl.Connection selectedDatabase = get(); @@ -267,6 +289,8 @@ public class ChoosePane extends BasicBeanPane implements Refresha schemaBox.removePopupMenuListener(listener); schemaBox.setPopupVisible(true); schemaBox.addPopupMenuListener(listener); + schemaBox.removeFocusListener(focusAdapter); + schemaBox.addFocusListener(focusAdapter); } }; populateWorker.execute(); @@ -292,7 +316,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha return null; // peter:选中了当前的零长度的节点,直接返回. } ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); - for (Map.Entry entry: connectionConfig.getConnections().entrySet()) { + for (Map.Entry entry : connectionConfig.getConnections().entrySet()) { if (ComparatorUtils.equals(selectedDSName, entry.getKey())) { return entry.getValue(); } @@ -303,6 +327,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** * 刷新没多大用。而且要刷新也不是这儿刷新。 */ + @Override public void refresh() { DBUtils.refreshDatabase(); String schema = StringUtils.isEmpty(schemaBox.getSelectedItem()) ? null : schemaBox.getSelectedItem(); @@ -312,6 +337,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } TreeCellRenderer tableNameTreeRenderer = new DefaultTreeCellRenderer() { + @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); if (value instanceof DefaultMutableTreeNode) { @@ -328,6 +354,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha }; public static UIComboBoxRenderer listCellRenderer = new UIComboBoxRenderer() { + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof TreePath) { @@ -344,16 +371,18 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** - * 添加项目监听事件 - * @param aListener 事件监听器 + * 添加项目监听事件 + * + * @param aListener 事件监听器 */ public void addItemListener(ItemListener aListener) { this.tableNameComboBox.addItemListener(aListener); } /** - * 删除项目监听事件 - * @param aListener 事件监听器 + * 删除项目监听事件 + * + * @param aListener 事件监听器 */ public void removeItemListener(ItemListener aListener) { this.tableNameComboBox.removeItemListener(aListener); @@ -398,9 +427,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } } ((DefaultTreeModel) tree.getModel()).reload(); - /** - * daniel 展开所有tree - */ + // daniel 展开所有tree TreeNode root = (TreeNode) tree.getModel().getRoot(); TreePath parent = new TreePath(root); TreeNode node = (TreeNode) parent.getLastPathComponent(); @@ -416,42 +443,41 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** * 创建选中的数据集数据 - * @return 数据集数据 + * + * @return 数据集数据 */ public TableData createSelectTableData() { DataBaseItems paras = this.updateBean(); boolean connect = false; com.fr.data.impl.Connection database = DBUtils.checkDBConnection(paras.getDatabaseName()); if (database == null) { - failedToFindTable(); + failedToFindTable(); return TableData.EMPTY_TABLEDATA; } try { connect = FRContext.getCurrentEnv().testConnection(database); - } catch (Exception e1) { - connect = false; + } catch (Exception ignored) { } if (!connect) { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); JOptionPane.showMessageDialog(designerFrame, Inter.getLocText("Datasource-Connection_failed"), - Inter.getLocText("FR-Designer_Failed"), JOptionPane.INFORMATION_MESSAGE); - failedToFindTable(); + Inter.getLocText("FR-Designer_Failed"), JOptionPane.INFORMATION_MESSAGE); + failedToFindTable(); return null; } // 显示Table数据. TableData tableData = null; if (FRContext.getCurrentEnv() instanceof LocalEnv) { - TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), + tableData = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName()))); - tableData = tableDataLocal; } else { try { TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName()))); tableData = FRContext.getCurrentEnv().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP, DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow()); } catch (Exception e) { - failedToFindTable(); + failedToFindTable(); FRContext.getLogger().error(e.getMessage(), e); } } @@ -463,8 +489,8 @@ public class ChoosePane extends BasicBeanPane implements Refresha return this.dsNameComboBox.getSelectedItem(); } - protected void failedToFindTable() { - } + protected void failedToFindTable() { + } protected String getTableName() { String tableName = ""; @@ -485,7 +511,8 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** * 得到当前的ColumnName[] - * @return 返回当前的ColumnName[] + * + * @return 返回当前的ColumnName[] */ public String[] currentColumnNames() { String[] colNames = null; @@ -493,21 +520,19 @@ public class ChoosePane extends BasicBeanPane implements Refresha DataBaseItems paras = this.updateBean(); String selectedDSName = paras.getDatabaseName(); if (StringUtils.isBlank(selectedDSName)) { - return colNames = new String[0]; // peter:选中了当前的零长度的节点,直接返回. + // peter:选中了当前的零长度的节点,直接返回. + return new String[0]; } String selectedTableObject = paras.getTableName(); if (StringUtils.isEmpty(selectedTableObject)) { - return colNames = new String[0]; + return new String[0]; } - java.sql.Connection conn = null; try { // daniel:增加参数 colNames = FRContext.getCurrentEnv().getColumns(selectedDSName, paras.getSchemaName(), selectedTableObject); } catch (Exception e2) { FRContext.getLogger().error(e2.getMessage(), e2); - } finally { - DBUtils.closeConnection(conn); } if (colNames == null) { @@ -517,9 +542,10 @@ public class ChoosePane extends BasicBeanPane implements Refresha } /** - * 预览key value对应的数据 + * 预览key value对应的数据 + * * @param key 键 - * @param value 值 + * @param value 值 */ public void preview(int key, int value) { PreviewTablePane.previewTableData(createSelectTableData(), key, value); @@ -528,6 +554,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** * 默认预览 */ + @Override public void preview() { preview(-1, -1); } @@ -540,10 +567,12 @@ public class ChoosePane extends BasicBeanPane implements Refresha } /** - *注册listener,相应数据集改变 + * 注册listener,相应数据集改变 */ + @Override public void registerDSChangeListener() { DesignTableDataManager.addDsChangeListener(new ChangeListener() { + @Override public void stateChanged(ChangeEvent e) { initDsNameComboBox(); } @@ -578,6 +607,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha this.refreshingModel = refreshingModel; } + @Override public void setSelectedItem(Object ob) { this.getModel().setSelectedItem(ob); if (ob != null && StringUtils.isEmpty(ob.toString())) { @@ -591,11 +621,13 @@ public class ChoosePane extends BasicBeanPane implements Refresha private class ComboBoxEditor extends UIComboBoxEditor { private Object item; + @Override public void setItem(Object item) { this.item = item; textField.setText((item == null) ? "" : item.toString()); } + @Override public Object getItem() { return this.item; }