From 4c942980414e9a99ec9e75ba31d2a80b09c3e8d4 Mon Sep 17 00:00:00 2001 From: plough Date: Wed, 6 Sep 2017 14:40:01 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-4332=20&=20REPORT-3740=209.0?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E8=A1=A8=E5=8D=95=E8=8A=B1=E5=B1=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98;[9.0=E4=B8=80=E8=BD=AE=E5=9B=9E=E5=BD=92]?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_form/src/com/fr/design/mainframe/FormArea.java | 2 -- designer_form/src/com/fr/design/mainframe/JForm.java | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index cdf92edfe..0ccae9b99 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -86,8 +86,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } this.setFocusTraversalKeysEnabled(false); this.designer.addMouseWheelListener(showValSpinnerMouseWheelListener); - this.setOpaque(true); - this.setBackground(Color.WHITE); } MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() { diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 2effa34ba..0f979a8ec 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -220,7 +220,10 @@ public class JForm extends JTemplate implements BaseJForm { formDesign = new FormDesigner(this.getTarget(), new TabChangeAction(BaseJForm.ELEMENTCASE_TAB, this)); WidgetToolBarPane.getInstance(formDesign); FormArea area = new FormArea(formDesign); - centerPane.add(area, BorderLayout.CENTER); + JPanel areaWrapper = new JPanel(new BorderLayout()); + areaWrapper.add(area, BorderLayout.CENTER); + areaWrapper.setBackground(Color.white); + centerPane.add(areaWrapper, BorderLayout.CENTER); tabCenterPane.add(centerPane, FORM_CARD, FORM_TAB); this.add(tabCenterPane, BorderLayout.CENTER); From 14518f0306dd5144e9c24f5913001bb82c5b3774 Mon Sep 17 00:00:00 2001 From: plough Date: Wed, 6 Sep 2017 19:32:35 +0800 Subject: [PATCH 2/5] =?UTF-8?q?REPORT-4334=20=E8=AE=BE=E7=BD=AE=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=9B=BE=E6=A0=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/web/CustomIconPane.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/web/CustomIconPane.java b/designer_base/src/com/fr/design/web/CustomIconPane.java index c625d1ee0..cc20fc7a2 100644 --- a/designer_base/src/com/fr/design/web/CustomIconPane.java +++ b/designer_base/src/com/fr/design/web/CustomIconPane.java @@ -6,14 +6,18 @@ import com.fr.base.Icon; import com.fr.base.IconManager; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIBasicButtonUI; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIBasicMenuItemUI; import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.utils.ColorRoutines; +import com.fr.design.utils.ThemeUtils; import com.fr.form.ui.WidgetManager; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; @@ -26,6 +30,8 @@ import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.plaf.ButtonUI; +import javax.swing.plaf.basic.BasicButtonUI; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -297,11 +303,20 @@ public class CustomIconPane extends BasicPane { this.iconImage = WidgetManager.getProviderInstance().getIconManager().getIconImage(name); this.setToolTipText(iconName); } + + @Override + public void updateUI() { + setUI(new BasicButtonUI(){ + public void paint(Graphics g, JComponent c) { + super.paint(g, c); + } + }); + } @Override public void paintComponent(Graphics g) { + super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; - // carl:这里缩放显示 16 × 16 if (iconImage != null) { g2d.drawImage(iconImage, 4, 4, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); From b82ad6f4a45bb1330ddba05e3ee38e49601f5732 Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 7 Sep 2017 09:43:18 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/FormArea.java | 26 +++++++------- .../src/com/fr/design/mainframe/JForm.java | 35 +++++++++++-------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index 0ccae9b99..81ddf6ae2 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -35,6 +35,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { private static final int ROTATIONS = 50; private static final int SHOWVALMAX = 400; private static final int SHOWVALMIN = 10; + private static final int RESIZE_PANE_GAP = 8; private FormDesigner designer; private int horizontalValue = 0; private int verticalValue = 0; @@ -119,11 +120,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent { slidePane = JFormSliderPane.getInstance(); slidePane.setPreferredSize(new Dimension(200, 20)); - - JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{ - {tipsPane, new UILabel(), widthPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel("x"), - heightPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel(), slidePane}}, - rowSize, columnSize, 8); + JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( + new JComponent[][]{{ tipsPane, new UILabel(), widthPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel("x"), + heightPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel(), slidePane }}, + rowSize, columnSize, RESIZE_PANE_GAP); this.add(FormRulerLayout.BOTTOM, resizePane); setWidgetsConfig(); // 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小 @@ -439,14 +439,13 @@ public class FormArea extends JComponent implements ScrollRulerComponent { int id = evt.getID(); switch (id) { case MouseEvent.MOUSE_WHEEL: { - int rotations = evt.getWheelRotation(); - int value = this.verScrollBar.getValue() + rotations * ROTATIONS; - value = Math.min(value, verticalMax); - value = Math.max(0, value); + int value = this.verScrollBar.getValue() + evt.getWheelRotation() * ROTATIONS; + value = Math.max(0, Math.min(value, verticalMax)); doLayout(); //加dolayout是因为每次滚动都要重置 Max的大小 this.verScrollBar.setValue(value); break; } + default: } } @@ -743,9 +742,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } private class FormRulerLayout extends RulerLayout { - private int DESIGNERWIDTH = 960; - private int DESIGNERHEIGHT = 540; - private int TOPGAP = 8; + private static final int DESIGNER_WIDTH = 960; + private static final int DESIGNER_HEIGHT = 540; + private static final int TOPGAP = 8; + + private int DESIGNERWIDTH = DESIGNER_WIDTH; + private int DESIGNERHEIGHT = DESIGNER_HEIGHT; public FormRulerLayout() { super(); diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 0f979a8ec..6a98530da 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -93,6 +93,8 @@ public class JForm extends JTemplate implements BaseJForm { @Override public void refreshEastPropertiesPane() { + // 暂时用不到,遇到的时候再加刷新右侧tab面板的代码 + return; } @Override @@ -126,7 +128,7 @@ public class JForm extends JTemplate implements BaseJForm { @Override public void setJTemplateResolution(int resolution) { - + return; } @Override @@ -270,14 +272,14 @@ public class JForm extends JTemplate implements BaseJForm { } public void setSheetCovered(boolean isCovered) { - + return; } /** * 刷新容器 */ public void refreshContainer() { - + return; } /** @@ -289,6 +291,7 @@ public class JForm extends JTemplate implements BaseJForm { @Override public void setScale(int resolution) { + return; } @Override @@ -464,12 +467,12 @@ public class JForm extends JTemplate implements BaseJForm { @Override public ShortCut[] shortcut4TemplateMenu() { if (this.index == FORM_TAB) { - return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{ + return (ShortCut[]) ArrayUtils.addAll( new ShortCut[]{ new TemplateParameterAction(this), new FormMobileAttrAction(this) }, new ShortCut[0]); } else { - return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{ + return (ShortCut[]) ArrayUtils.addAll( new ShortCut[]{ new TemplateParameterAction(this), new FormMobileAttrAction(this) }, this.elementCaseDesign.shortcut4TemplateMenu()); @@ -680,16 +683,14 @@ public class JForm extends JTemplate implements BaseJForm { return; } - if (formDesign.isReportBlockEditing()) { - if (elementCaseDesign != null) { - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.FORM_REPORT); - EastRegionContainerPane.getInstance().removeParameterPane(); - EastRegionContainerPane.getInstance().replaceCellAttrPane(elementCaseDesign.getEastDownPane()); - EastRegionContainerPane.getInstance().replaceCellElementPane(elementCaseDesign.getEastUpPane()); - EastRegionContainerPane.getInstance().replaceConditionAttrPane(elementCaseDesign.getConditionAttrPane()); - EastRegionContainerPane.getInstance().replaceHyperlinkPane(elementCaseDesign.getHyperlinkPane()); - return; - } + if (formDesign.isReportBlockEditing() && elementCaseDesign != null) { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.FORM_REPORT); + EastRegionContainerPane.getInstance().removeParameterPane(); + EastRegionContainerPane.getInstance().replaceCellAttrPane(elementCaseDesign.getEastDownPane()); + EastRegionContainerPane.getInstance().replaceCellElementPane(elementCaseDesign.getEastUpPane()); + EastRegionContainerPane.getInstance().replaceConditionAttrPane(elementCaseDesign.getConditionAttrPane()); + EastRegionContainerPane.getInstance().replaceHyperlinkPane(elementCaseDesign.getHyperlinkPane()); + return; } EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.FORM); @@ -699,6 +700,10 @@ public class JForm extends JTemplate implements BaseJForm { EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane); EastRegionContainerPane.getInstance().setParameterHeight(parameterPropertyPane.getPreferredSize().height); + refreshWidgetLibPane(); + } + + private void refreshWidgetLibPane() { if (EastRegionContainerPane.getInstance().getWidgetLibPane() == null) { new Thread() { public void run() { From 086c07354439fbb3670499aaae67ccfc0455c1ba Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 7 Sep 2017 11:42:11 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/web/CustomIconPane.java | 174 +++++++++--------- .../src/com/fr/design/mainframe/FormArea.java | 17 +- .../src/com/fr/design/mainframe/JForm.java | 10 +- 3 files changed, 96 insertions(+), 105 deletions(-) diff --git a/designer_base/src/com/fr/design/web/CustomIconPane.java b/designer_base/src/com/fr/design/web/CustomIconPane.java index cc20fc7a2..c268ae91f 100644 --- a/designer_base/src/com/fr/design/web/CustomIconPane.java +++ b/designer_base/src/com/fr/design/web/CustomIconPane.java @@ -6,18 +6,15 @@ import com.fr.base.Icon; import com.fr.base.IconManager; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.gui.ibutton.UIBasicButtonUI; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.imenu.UIBasicMenuItemUI; import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.ColorRoutines; -import com.fr.design.utils.ThemeUtils; import com.fr.form.ui.WidgetManager; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; @@ -30,7 +27,6 @@ import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.plaf.ButtonUI; import javax.swing.plaf.basic.BasicButtonUI; import java.awt.*; import java.awt.event.ActionEvent; @@ -50,14 +46,14 @@ public class CustomIconPane extends BasicPane { private ListMap iconButtonMap = null; private JPanel iconPane = null; private ButtonGroup bg; - private JScrollPane jsPane; + private UIScrollPane jsPane; // 老一次次去拿真麻烦 private IconManager iconManager = null; - private int width = 180; - private int horizontalCount = 6; - private int heightPer = 29; - private int gap = 10; + private static final int THE_WIDTH = 180; + private static final int HORIZONTAL_COUNT = 6; + private static final int HEIGHT_PER = 29; + private static final int GAP = 10; public CustomIconPane() { this.initComponents(); @@ -75,7 +71,7 @@ public class CustomIconPane extends BasicPane { // 开始加图标选择按钮 initIcons(); - jsPane = new JScrollPane(iconPane); + jsPane = new UIScrollPane(iconPane); refreshIconPane(false); jsPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); @@ -141,10 +137,7 @@ public class CustomIconPane extends BasicPane { }else { // add failed - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Inter.getLocText("FR-Designer_Custom_Icon_Message2"), - Inter.getLocText("FR-Designer_Tooltips"), - JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Custom_Icon_Message2"), Inter.getLocText("FR-Designer_Tooltips"), JOptionPane.WARNING_MESSAGE); } } }).setVisible(true); @@ -195,6 +188,7 @@ public class CustomIconPane extends BasicPane { try { oldIcon= iconManager.getIcon(selectedIconName); } catch (CloneNotSupportedException e1) { + // do nothing } if (oldIcon == null) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), @@ -221,10 +215,7 @@ public class CustomIconPane extends BasicPane { // 失败了再弄回去 iconManager.addIcon(oldIcon, true); // edit failed - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Inter.getLocText("FR-Designer_Custom_Icon_Message2"), - Inter.getLocText("FR-Designer_Tooltips"), - JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Custom_Icon_Message2"), Inter.getLocText("FR-Designer_Tooltips"), JOptionPane.WARNING_MESSAGE); } } }); @@ -278,8 +269,8 @@ public class CustomIconPane extends BasicPane { // 不知道怎么动态布局,就这么傻傻的调一下大小 private void refreshIconPane(boolean down) { - iconPane.setPreferredSize(new Dimension(width, (iconButtonMap.size() / horizontalCount + 1) * heightPer + gap)); - JScrollBar jsBar = jsPane.getVerticalScrollBar(); + iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP)); + JScrollBar jsBar = jsPane.createVerticalScrollBar(); try { if (down) { // 将滚动条滚到最后 @@ -288,16 +279,17 @@ public class CustomIconPane extends BasicPane { jsBar.setValue(0); } } catch (RuntimeException re) { + return; } } private class IconButton extends JToggleButton implements ActionListener{ private String iconName; private Image iconImage = null; + private static final int ICON_BUTTON_SIZE = 24; public IconButton(String name) { this.iconName = name; this.addActionListener(this); - this.setCursor(new Cursor(Cursor.HAND_CURSOR)); this.setBorder(null); this.iconImage = WidgetManager.getProviderInstance().getIconManager().getIconImage(name); @@ -332,7 +324,7 @@ public class CustomIconPane extends BasicPane { @Override public Dimension getPreferredSize() { - return new Dimension(24, 24); + return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE); } public void actionPerformed(ActionEvent evt) { @@ -363,75 +355,79 @@ public class CustomIconPane extends BasicPane { private String oldName = null; protected EditIconDialog() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - double p = TableLayout.PREFERRED; - double rowSize[] = {p, p}; - double columnSize[] = {p, p, p}; - - UIButton browseButton = new UIButton(Inter.getLocText("FR-Designer_Custom_Icon_SelectIcon")); - browseButton.setPreferredSize(new java.awt.Dimension(80, 25)); - browseButton.setToolTipText(Inter.getLocText("FR-Designer_Click_this_button")); - - browseButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - JFileChooser jf = new JFileChooser(); - // carl:不知道是否只要png格式,反正导出时全部都转成png了 - FileNameExtensionFilter fileFilter = new FileNameExtensionFilter("Icon Image File", "jpg", "jpeg", "png", "gif"); - jf.setFileFilter(fileFilter); + init(); + } - if (JFileChooser.APPROVE_OPTION == jf.showOpenDialog(DesignerContext.getDesignerFrame())) { - String path = jf.getSelectedFile().getAbsolutePath(); - // 将图片转化到16 × 16大小 - Image image = BaseUtils.readImage(path); - BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(IconManager.DEFAULT_ICONWIDTH, - IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB); - Graphics2D g2d = bufferedImage.createGraphics(); - g2d.drawImage(image, 0, 0, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); - bufferedImage.flush(); - g2d.dispose(); - iconImage = bufferedImage; - if (iconImage != null) { - showImageLabel.setIcon(new ImageIcon(iconImage)); - } - } - - } - }); - - nameTextField = new UITextField(20); - // 焦点丢失时看看名称是否已经存在 - nameTextField.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { + private void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + double p = TableLayout.PREFERRED; + double rowSize[] = {p, p}; + double columnSize[] = {p, p, p}; + + UIButton browseButton = new UIButton(Inter.getLocText("FR-Designer_Custom_Icon_SelectIcon")); + browseButton.setPreferredSize(new Dimension(80, 25)); + browseButton.setToolTipText(Inter.getLocText("FR-Designer_Click_this_button")); + nameTextField = new UITextField(20); + + browseButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + onBrowseButtonClicked(); } - public void focusLost(FocusEvent e) { - if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) { - return; - } - if (WidgetManager.getProviderInstance().getIconManager().contains(nameTextField.getText())) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Inter.getLocText("FR-Designer_Custom_Icon_Message3"), - Inter.getLocText("FR-Designer_Tooltips"), - JOptionPane.WARNING_MESSAGE); - } - } }); - - JPanel imagePane = new JPanel(); - imagePane.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0)); - showImageLabel = new UILabel(); - showImageLabel.setPreferredSize(new Dimension(20,20)); - imagePane.add(showImageLabel); - imagePane.add(browseButton); - Component[][] components = { - {new UILabel(Inter.getLocText("FR-Designer_Name") + ":"), nameTextField}, - {new UILabel(Inter.getLocText("FR-Designer_Icon") + ":"), imagePane} - }; - - JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - this.add(centerPane,BorderLayout.CENTER); - } - - @Override + + // 焦点丢失时看看名称是否已经存在 + nameTextField.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent e) { + } + public void focusLost(FocusEvent e) { + if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) { + return; + } + if (WidgetManager.getProviderInstance().getIconManager().contains(nameTextField.getText())) { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Inter.getLocText("FR-Designer_Custom_Icon_Message3"), + Inter.getLocText("FR-Designer_Tooltips"), + JOptionPane.WARNING_MESSAGE); + } + } + }); + + JPanel imagePane = new JPanel(); + imagePane.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0)); + showImageLabel = new UILabel(); + showImageLabel.setPreferredSize(new Dimension(20,20)); + imagePane.add(showImageLabel); + imagePane.add(browseButton); + Component[][] components = {{new UILabel(Inter.getLocText("FR-Designer_Name") + ":"), nameTextField}, {new UILabel(Inter.getLocText("FR-Designer_Icon") + ":"), imagePane}}; + + JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.add(centerPane,BorderLayout.CENTER); + } + + private void onBrowseButtonClicked() { + JFileChooser jf = new JFileChooser(); + // carl:不知道是否只要png格式,反正导出时全部都转成png了 + FileNameExtensionFilter fileFilter = new FileNameExtensionFilter("Icon Image File", "jpg", "jpeg", "png", "gif"); + jf.setFileFilter(fileFilter); + + if (JFileChooser.APPROVE_OPTION == jf.showOpenDialog(DesignerContext.getDesignerFrame())) { + String path = jf.getSelectedFile().getAbsolutePath(); + // 将图片转化到16 × 16大小 + Image image = BaseUtils.readImage(path); + BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(IconManager.DEFAULT_ICONWIDTH, +IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = bufferedImage.createGraphics(); + g2d.drawImage(image, 0, 0, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); + bufferedImage.flush(); + g2d.dispose(); + iconImage = bufferedImage; + if (iconImage != null) { + showImageLabel.setIcon(new ImageIcon(iconImage)); + } + } + } + + @Override protected String title4PopupWindow() { return Inter.getLocText(new String[]{"Add", "Icon"}); } diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index 81ddf6ae2..5174f3bb9 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -120,10 +120,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { slidePane = JFormSliderPane.getInstance(); slidePane.setPreferredSize(new Dimension(200, 20)); - JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( - new JComponent[][]{{ tipsPane, new UILabel(), widthPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel("x"), - heightPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel(), slidePane }}, - rowSize, columnSize, RESIZE_PANE_GAP); + JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{{ tipsPane, new UILabel(), widthPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel("x"), heightPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel(), slidePane }}, rowSize, columnSize, RESIZE_PANE_GAP); this.add(FormRulerLayout.BOTTOM, resizePane); setWidgetsConfig(); // 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小 @@ -439,16 +436,20 @@ public class FormArea extends JComponent implements ScrollRulerComponent { int id = evt.getID(); switch (id) { case MouseEvent.MOUSE_WHEEL: { - int value = this.verScrollBar.getValue() + evt.getWheelRotation() * ROTATIONS; - value = Math.max(0, Math.min(value, verticalMax)); - doLayout(); //加dolayout是因为每次滚动都要重置 Max的大小 - this.verScrollBar.setValue(value); + onMouseWheelScroll(evt); break; } default: } } + private void onMouseWheelScroll(MouseWheelEvent evt) { + int value = this.verScrollBar.getValue() + evt.getWheelRotation() * ROTATIONS; + value = Math.max(0, Math.min(value, verticalMax)); + doLayout(); //加dolayout是因为每次滚动都要重置 Max的大小 + this.verScrollBar.setValue(value); + } + /** * 返回表单容器的中心designer * getFormEditor. diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 6a98530da..7504a3255 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -467,15 +467,9 @@ public class JForm extends JTemplate implements BaseJForm { @Override public ShortCut[] shortcut4TemplateMenu() { if (this.index == FORM_TAB) { - return (ShortCut[]) ArrayUtils.addAll( new ShortCut[]{ - new TemplateParameterAction(this), - new FormMobileAttrAction(this) - }, new ShortCut[0]); + return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new FormMobileAttrAction(this)}, new ShortCut[0]); } else { - return (ShortCut[]) ArrayUtils.addAll( new ShortCut[]{ - new TemplateParameterAction(this), - new FormMobileAttrAction(this) - }, this.elementCaseDesign.shortcut4TemplateMenu()); + return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new FormMobileAttrAction(this)}, this.elementCaseDesign.shortcut4TemplateMenu()); } } From 017941a4ab5b78d346f9250fb55b94c2bb4ef65d Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 7 Sep 2017 11:49:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/icontainer/UIScrollPane.java | 9 +++++---- .../src/com/fr/design/web/CustomIconPane.java | 14 +++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java b/designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java index 9f2808df8..239653381 100644 --- a/designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java +++ b/designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java @@ -13,12 +13,13 @@ import java.awt.*; public class UIScrollPane extends JScrollPane { private static final long serialVersionUID = 1L; + private static final int INCREAMENT = 30; public UIScrollPane(Component c) { super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.setHorizontalScrollBar(createHorizontalScrollBar()); - this.getVerticalScrollBar().setUnitIncrement(30); - this.getVerticalScrollBar().setBlockIncrement(30); + this.getVerticalScrollBar().setUnitIncrement(INCREAMENT); + this.getVerticalScrollBar().setBlockIncrement(INCREAMENT); this.getHorizontalScrollBar().setOpaque(true); this.getHorizontalScrollBar().setBackground(Color.WHITE); this.getVerticalScrollBar().setOpaque(true); @@ -29,7 +30,7 @@ public class UIScrollPane extends JScrollPane { /** * 生成水平滚动条 */ - public JScrollBar createHorizontalScrollBar() { + public UIScrollBar createHorizontalScrollBar() { UIScrollBar sbr = new UIScrollBar(JScrollBar.HORIZONTAL); sbr.setBackground(UIConstants.NORMAL_BACKGROUND); return sbr; @@ -39,7 +40,7 @@ public class UIScrollPane extends JScrollPane { /** * 生成垂直滚动条 */ - public JScrollBar createVerticalScrollBar() { + public UIScrollBar createVerticalScrollBar() { UIScrollBar sbr = new UIScrollBar(JScrollBar.VERTICAL); sbr.setBackground(UIConstants.NORMAL_BACKGROUND); return sbr; diff --git a/designer_base/src/com/fr/design/web/CustomIconPane.java b/designer_base/src/com/fr/design/web/CustomIconPane.java index c268ae91f..b075aad43 100644 --- a/designer_base/src/com/fr/design/web/CustomIconPane.java +++ b/designer_base/src/com/fr/design/web/CustomIconPane.java @@ -9,6 +9,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; @@ -133,7 +134,7 @@ public class CustomIconPane extends BasicPane { if (iconManager.addIcon(icon, false)) { IconButton iconButton = null;//初始化 - addIcon(icon,iconButton); + addIcon(icon, iconButton); }else { // add failed @@ -209,7 +210,7 @@ public class CustomIconPane extends BasicPane { iconPane.remove(iconButton); bg.remove(iconButton); - addIcon(icon,iconButton); + addIcon(icon, iconButton); } else { // 失败了再弄回去 @@ -270,7 +271,7 @@ public class CustomIconPane extends BasicPane { // 不知道怎么动态布局,就这么傻傻的调一下大小 private void refreshIconPane(boolean down) { iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP)); - JScrollBar jsBar = jsPane.createVerticalScrollBar(); + UIScrollBar jsBar = jsPane.createVerticalScrollBar(); try { if (down) { // 将滚动条滚到最后 @@ -287,6 +288,8 @@ public class CustomIconPane extends BasicPane { private String iconName; private Image iconImage = null; private static final int ICON_BUTTON_SIZE = 24; + private static final int ICON_X = 4; + private static final int ICON_Y = 4; public IconButton(String name) { this.iconName = name; this.addActionListener(this); @@ -311,7 +314,7 @@ public class CustomIconPane extends BasicPane { Graphics2D g2d = (Graphics2D) g; // carl:这里缩放显示 16 × 16 if (iconImage != null) { - g2d.drawImage(iconImage, 4, 4, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); + g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); } if (this.iconName != null && ComparatorUtils.equals(this.iconName, selectedIconName)) { g2d.setPaint(Color.RED); @@ -378,6 +381,7 @@ public class CustomIconPane extends BasicPane { // 焦点丢失时看看名称是否已经存在 nameTextField.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { + // do nothing } public void focusLost(FocusEvent e) { if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) { @@ -401,7 +405,7 @@ public class CustomIconPane extends BasicPane { Component[][] components = {{new UILabel(Inter.getLocText("FR-Designer_Name") + ":"), nameTextField}, {new UILabel(Inter.getLocText("FR-Designer_Icon") + ":"), imagePane}}; JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - this.add(centerPane,BorderLayout.CENTER); + this.add(centerPane, BorderLayout.CENTER); } private void onBrowseButtonClicked() {