From d1620c1355600394bb18cd490ec7c9de4478d15f Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 7 Jan 2019 17:44:55 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-14057=2010.0=E6=97=A5=E6=96=87?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= =?UTF-8?q?=3D>=E9=97=AE=E9=A2=984?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/file/PreferencePane.java | 2 ++ .../main/java/com/fr/design/gui/ilable/UILabel.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index c6aebd2a2..af6faf568 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -61,6 +61,7 @@ public class PreferencePane extends BasicPane { private static final int CACHING_MAX = 10; private static final int CACHING_DEFAULT = 5; private static final int CACHING_GAP = 5; + private static final int MEMORY_TIP_LABEL_MAX_WIDTH = 230; private static final String TYPE = "pressed"; private static final String DISPLAY_TYPE = "+"; @@ -472,6 +473,7 @@ public class PreferencePane extends BasicPane { JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template")); UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Max_Caching_Template")); UILabel memoryTipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template_Tip")); + memoryTipLabel.setLineWrapWithMaximumWidth(MEMORY_TIP_LABEL_MAX_WIDTH); memoryTipLabel.setBorder(BorderFactory.createEmptyBorder(0, CACHING_GAP, 0, 0)); cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT); JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java index 6583e8d61..aad08d398 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java @@ -64,6 +64,18 @@ public class UILabel extends JLabel { return preferredSize; } + /** + * 指定最大宽度,文字内容到达最大宽度后,自动换行 + */ + public void setLineWrapWithMaximumWidth(int width) { + String text = this.getText(); + if (StringUtils.isEmpty(text)) { + return; + } + String htmlText = "" + text; + this.setText(htmlText); + } + public static void main(String[] args) { // UILabel label = new UILabel("shishi",SwingConstants.LEFT); From 807f381feda5d4a77dc7757e4b1b08098623ca41 Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 7 Jan 2019 19:43:19 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-14057=2010.0=E6=97=A5=E6=96=87?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= =?UTF-8?q?=3D>=E9=97=AE=E9=A2=987=20=E6=8E=A7=E4=BB=B6=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/webattr/ToolBarDragPane.java | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/webattr/ToolBarDragPane.java b/designer-realize/src/main/java/com/fr/design/webattr/ToolBarDragPane.java index d339f201a..c420c04b4 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/ToolBarDragPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/ToolBarDragPane.java @@ -10,16 +10,26 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.ui.Widget; - import com.fr.report.web.Location; import com.fr.report.web.ToolBarManager; import com.fr.stable.ArrayUtils; +import com.fr.stable.GraphDrawHelper; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.Icon; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; -import java.awt.*; +import javax.swing.table.TableColumnModel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -34,6 +44,7 @@ import java.awt.image.ImageObserver; public class ToolBarDragPane extends WidgetToolBarPane { private static final int COLUMN = 4; + private static final int MIN_COLUMN_WIDTH = 15; private int row = 7; private DefaultTableModel toolbarButtonTableModel; private JTable layoutTable; @@ -169,10 +180,6 @@ public class ToolBarDragPane extends WidgetToolBarPane { layoutTable.setColumnSelectionAllowed(false); layoutTable.setRowSelectionAllowed(false); layoutTable.setBackground(Color.WHITE); - int columnWidth = Integer.parseInt(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Layout_Table_Column_Width")); - for (int i = 0; i < layoutTable.getColumnModel().getColumnCount(); i++) { - layoutTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidth); - } layoutTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1 && !(SwingUtilities.isRightMouseButton(e)) && isEnabled) { @@ -188,6 +195,23 @@ public class ToolBarDragPane extends WidgetToolBarPane { }); } + // 根据控件名称长度,设置合适的列宽 + private static void resizeColumnWidth(JTable table) { + final TableColumnModel columnModel = table.getColumnModel(); + for (int column = 0; column < table.getColumnCount(); column++) { + int width = MIN_COLUMN_WIDTH; // Min width + for (int row = 0; row < table.getRowCount(); row++) { + WidgetOption widgetOption = (WidgetOption) table.getValueAt(row, column); + if (widgetOption == null) { + continue; + } + String optionName = widgetOption.optionName(); + width = Math.max(GraphDrawHelper.getWidth(optionName), width); + } + columnModel.getColumn(column).setPreferredWidth(width); + } + } + private boolean isSelectedtable() { for (int i = 0; i < layoutTable.getColumnCount(); i++) { @@ -229,6 +253,7 @@ public class ToolBarDragPane extends WidgetToolBarPane { toolbarButtonTableModel.setValueAt(buttonArray[i], i % row, i / row); } } + resizeColumnWidth(layoutTable); } From b1d5ed6ca38f7f5f14cfcee99703e810f45d2153 Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 7 Jan 2019 19:44:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-14057=2010.0=E6=97=A5=E6=96=87?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= =?UTF-8?q?=3D>=E9=97=AE=E9=A2=988=20=E6=B5=8F=E8=A7=88=E5=99=A8=E8=83=8C?= =?UTF-8?q?=E6=99=AF=EF=BC=8C=E6=A0=87=E7=AD=BE=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/PreferencePane.java | 2 +- .../com/fr/design/gui/ilable/UILabel.java | 18 ++++++++++--- .../gradient/GradientBackgroundPane.java | 26 +++++++++---------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index af6faf568..5ddd44b60 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -473,7 +473,7 @@ public class PreferencePane extends BasicPane { JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template")); UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Max_Caching_Template")); UILabel memoryTipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template_Tip")); - memoryTipLabel.setLineWrapWithMaximumWidth(MEMORY_TIP_LABEL_MAX_WIDTH); + memoryTipLabel.setLineWrap(MEMORY_TIP_LABEL_MAX_WIDTH); memoryTipLabel.setBorder(BorderFactory.createEmptyBorder(0, CACHING_GAP, 0, 0)); cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT); JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java index aad08d398..09e7ef0a7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java @@ -65,15 +65,25 @@ public class UILabel extends JLabel { } /** - * 指定最大宽度,文字内容到达最大宽度后,自动换行 + * 到达指定宽度后换行 */ - public void setLineWrapWithMaximumWidth(int width) { + public void setLineWrap(int width) { + insertPrefixToText(""); + } + + /** + * 自动换行 + */ + public void setLineWrap() { + insertPrefixToText(""); + } + + private void insertPrefixToText(String prefix) { String text = this.getText(); if (StringUtils.isEmpty(text)) { return; } - String htmlText = "" + text; - this.setText(htmlText); + this.setText(prefix + text); } diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBackgroundPane.java index 53558f6fb..18c458963 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBackgroundPane.java @@ -1,24 +1,22 @@ package com.fr.design.style.background.gradient; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.ButtonGroup; - +import com.fr.base.background.GradientBackground; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.general.Background; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - -import com.fr.base.background.GradientBackground; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.Background; - -import com.fr.design.style.background.BackgroundDetailPane; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * 渐变色的面板,不是很pp,面板应用显得繁琐,有写可以写成控件类型,比如色彩选择的。。,可以做得花哨点 @@ -44,6 +42,8 @@ public class GradientBackgroundPane extends BackgroundDetailPane { gradientBar = new GradientBar(4, 254); blankJp.add(gradientBar); UILabel jl = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Drag_To_Select_Gradient")); + jl.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); + jl.setLineWrap(); jl.setHorizontalAlignment(SwingConstants.CENTER); gradientPanel.add(jl, BorderLayout.NORTH); gradientPanel.add(blankJp, BorderLayout.SOUTH); From 8fdae48117630a2400b8be76a7362fe9e5b4de71 Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 7 Jan 2019 19:52:06 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-14057=2010.0=E6=97=A5=E6=96=87?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= =?UTF-8?q?=3D>=E9=97=AE=E9=A2=989=E3=80=81=E9=97=AE=E9=A2=9810=20?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/webattr/WebCssPane.java | 1 + .../src/main/java/com/fr/design/webattr/WebJsPane.java | 1 + 2 files changed, 2 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java index bab14f2d2..6f9866605 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java @@ -46,6 +46,7 @@ public class WebCssPane extends BasicPane { northPane.add(chooseFile, FlowLayout.RIGHT); outnorth.add(northPane,BorderLayout.NORTH); UILabel infor = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CSS_Warning")); + infor.setLineWrap(); infor.setForeground(new Color(207, 42, 39)); outnorth.add(infor,BorderLayout.CENTER); this.add(outnorth, BorderLayout.NORTH); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java index 4aa4cf6e8..292a9d9ba 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java @@ -96,6 +96,7 @@ public class WebJsPane extends BasicPane { northPane.add(chooseFile); firstnorth.add(northPane,BorderLayout.NORTH); infor1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1")); + infor1.setLineWrap(); infor1.setForeground(new Color(207, 42, 39)); firstnorth.add(infor1,BorderLayout.CENTER);