diff --git a/designer-base/src/main/resources/com/fr/design/images/replace/change_normal.svg b/designer-base/src/main/resources/com/fr/design/images/replace/change_normal.svg new file mode 100644 index 000000000..88d9e7772 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/images/replace/change_normal.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fr/design/images/replace/replace.png b/designer-base/src/main/resources/com/fr/design/images/replace/replace.png index e73604272..b9a41125c 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/replace/replace.png and b/designer-base/src/main/resources/com/fr/design/images/replace/replace.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/replace/replace_normal.svg b/designer-base/src/main/resources/com/fr/design/images/replace/replace_normal.svg index efe176cea..f11cdc07b 100644 --- a/designer-base/src/main/resources/com/fr/design/images/replace/replace_normal.svg +++ b/designer-base/src/main/resources/com/fr/design/images/replace/replace_normal.svg @@ -1,3 +1,6 @@ - + + + + diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 9a2f5c8de..4e31314e4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -55,6 +55,7 @@ public class ITReplaceMainDialog extends UIDialog { private String searchStr; private static final int FIRST_ROW = 0; public static int selectCount = 0; + public static int MAIN_PANEL_WIDTH = 929; public ITReplaceMainDialog() { super(DesignerContext.getDesignerFrame()); @@ -97,8 +98,8 @@ public class ITReplaceMainDialog extends UIDialog { int width = jTemplate.getWidth(); Point point = jTemplate.getLocationOnScreen(); setModal(false); - setMaximumSize(new Dimension(jTemplate.getWidth(), jTemplate.getHeight())); - setMinimumSize(new Dimension(jTemplate.getWidth(), 240)); + setMaximumSize(new Dimension(width, jTemplate.getHeight())); + setMinimumSize(new Dimension(width, 240)); setSize(width, height); setLocation(new Point(point.x, point.y + jTemplate.getHeight() / 2 + jTemplate.getHeight() / 2 - 385)); @@ -124,7 +125,7 @@ public class ITReplaceMainDialog extends UIDialog { replaceComboBox.setEnabled(false); replaceComboBox.setEditable(true); northPane.getReplaceButton().setEnabled(false); - + westPanel.getLeftPanel().setPreferredSize(new Dimension(ITReplaceWestPanel.LEFT_WIDTH, this.getHeight())); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Input")); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index a4fe1fef0..909ce7112 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -1,5 +1,6 @@ package com.fr.design.actions.replace.ui; +import com.fr.base.svg.IconUtils; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; @@ -9,7 +10,9 @@ import com.fr.design.i18n.Toolkit; import com.fr.stable.StringUtils; +import javax.swing.BorderFactory; import javax.swing.ComboBoxEditor; +import javax.swing.Icon; import javax.swing.JCheckBox; import javax.swing.JPanel; import javax.swing.ScrollPaneConstants; @@ -34,20 +37,28 @@ public class ITReplaceNorthPanel { private UIComboBox findCombobox; private UIComboBox rangeCombobox; private JCheckBox matchRadioButton; + private UILabel iconLabel; private UIComboBox findInputCombobox; private UIComboBox replaceInputCombobox; private UIScrollPane scrollPane; private UIButton replaceButton; private UIButton searchButton; + private static double rate = 1.00; //存储的5次最近输入 private int maxItemCount = 5; - private static final int LIMIT_WIDTH = 1250; + private static int limit_width = 800; private static final int HEIGHT = 161; - private static final int BUTTON_WIDTH = 60; - private static final int BUTTON_GAP = 20; + private static final int BUTTON_WIDTH = 44; + private static final int GAP = 20; + private static final int BUTTON_GAP = 10; private static final int MATCH_WIDTH = 70; + private static final int COMPONENT_HEIGHT = 25; + private static final int FIRST_Y = 15, SECOND_Y = 50, THIRD_Y = 85, FOURTH_Y = 120; + private static final int FIRST_X = 20, SECOND_X = 80; + private static final int LABEL_WIDTH = 60; + private static final Icon CHANGE_ICON = IconUtils.readIcon("/com/fr/design/images/replace/change_normal.svg"); private int findLabelX, findLabelY, findLabelWidth, findLabelHeight; @@ -60,7 +71,8 @@ public class ITReplaceNorthPanel { private int replaceInputComboBoxX, replaceInputComboBoxY, replaceInputComboBoxWidth, replaceInputComboBoxHeight; private int replaceButtonX, replaceButtonY, replaceButtonHeight; private int searchButtonX, searchButtonY, searchButtonHeight; - + private int iconX, iconY, iconWidth, iconHeight; + private int inputLength; public static ArrayList findItems = new ArrayList<>(); public static ArrayList findInputItems = new ArrayList<>(); @@ -81,6 +93,7 @@ public class ITReplaceNorthPanel { findLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element")); rangeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range")); + iconLabel = new UILabel(CHANGE_ICON); resultLabel = new UILabel(); String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; @@ -109,7 +122,7 @@ public class ITReplaceNorthPanel { replaceButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); searchButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button")); - upPanel.setPreferredSize(new Dimension(LIMIT_WIDTH, HEIGHT)); + upPanel.setPreferredSize(new Dimension(limit_width, HEIGHT)); scrollPane = new UIScrollPane(upPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); upPanel.add(findLabel); upPanel.add(rangeLabel); @@ -121,6 +134,8 @@ public class ITReplaceNorthPanel { upPanel.add(matchRadioButton); upPanel.add(replaceButton); upPanel.add(searchButton); + upPanel.add(iconLabel); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); } /** @@ -129,9 +144,8 @@ public class ITReplaceNorthPanel { * @param width */ public void setLimitSize(int width) { - width = Math.max(LIMIT_WIDTH, width); - upPanel.setMaximumSize(new Dimension(width, 161)); - upPanel.setPreferredSize(new Dimension(width, 161)); + upPanel.setMaximumSize(new Dimension(limit_width, 161)); + upPanel.setPreferredSize(new Dimension(limit_width, 161)); } @@ -144,21 +158,22 @@ public class ITReplaceNorthPanel { */ public void fitScreen(int x, int y, int templateWidth) { - templateWidth = Math.max(templateWidth, LIMIT_WIDTH); - - setFindLabelBounds(x, y, templateWidth); - setRangeLabelBounds(x, y, templateWidth); - setResultLabelBounds(x, y, templateWidth); + templateWidth = Math.max(ITReplaceMainDialog.MAIN_PANEL_WIDTH, templateWidth); + templateWidth = templateWidth - ITReplaceWestPanel.LEFT_WIDTH; + inputLength = (templateWidth - GAP * 5) / 2; - setFindComboboxBounds(x, y, templateWidth); - setRangeComboboxBounds(x, y, templateWidth); - setFindInputComboboxBounds(x, y, templateWidth); - setReplaceInputComboboxBounds(x, y, templateWidth); - - setUIRadioButtonBounds(x, y, templateWidth); - setReplaceButtonBounds(x, y, templateWidth); - setSearchButtonBounds(x, y, templateWidth); + setFindLabelBounds(); + setResultLabelBounds(templateWidth); + setFindComboboxBounds(); + setFindInputComboboxBounds(); + setReplaceInputComboboxBounds(templateWidth); + setRangeLabelBounds(); + setRangeComboboxBounds(); + setUIRadioButtonBounds(); + setReplaceButtonBounds(); + setSearchButtonBounds(); + setIconLabelBounds(); } @@ -214,87 +229,94 @@ public class ITReplaceNorthPanel { this.scrollPane = scrollPane; } + private void setIconLabelBounds() { + iconX = inputLength + GAP; + iconY = SECOND_Y; + iconWidth = GAP; + iconHeight = COMPONENT_HEIGHT; + iconLabel.setBounds(iconX, iconY, iconWidth, iconHeight); + } - private void setSearchButtonBounds(int x, int y, int templateWidth) { - searchButtonHeight = 25; - searchButtonY = resultLabelY; + private void setSearchButtonBounds() { + searchButtonHeight = COMPONENT_HEIGHT; + searchButtonY = FOURTH_Y; searchButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH * 2 - BUTTON_GAP; searchButton.setBounds(searchButtonX, searchButtonY, BUTTON_WIDTH, searchButtonHeight); } - private void setReplaceButtonBounds(int x, int y, int templateWidth) { - replaceButtonHeight = 25; - replaceButtonY = resultLabelY; + private void setReplaceButtonBounds() { + replaceButtonHeight = COMPONENT_HEIGHT; + replaceButtonY = FOURTH_Y; replaceButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH; replaceButton.setBounds(replaceButtonX, replaceButtonY, BUTTON_WIDTH, replaceButtonHeight); } - private void setReplaceInputComboboxBounds(int x, int y, int templateWidth) { - replaceInputComboBoxX = x + templateWidth / 2 + templateWidth / 60; - replaceInputComboBoxY = y + 55; - replaceInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2; - replaceInputComboBoxHeight = 25; + private void setReplaceInputComboboxBounds(int templateWidth) { + replaceInputComboBoxX = templateWidth - inputLength - GAP * 2; + replaceInputComboBoxY = SECOND_Y; + replaceInputComboBoxWidth = inputLength; + replaceInputComboBoxHeight = COMPONENT_HEIGHT; replaceInputCombobox.setBounds(replaceInputComboBoxX, replaceInputComboBoxY, replaceInputComboBoxWidth, replaceInputComboBoxHeight); } - private void setFindInputComboboxBounds(int x, int y, int templateWidth) { - findInputComboBoxX = x + templateWidth / 60; - findInputComboBoxY = y + 55; - findInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2; - findInputComboBoxHeight = 25; + private void setFindInputComboboxBounds() { + findInputComboBoxX = FIRST_X; + findInputComboBoxY = SECOND_Y; + findInputComboBoxWidth = inputLength - GAP; + findInputComboBoxHeight = COMPONENT_HEIGHT; findInputCombobox.setBounds(findInputComboBoxX, findInputComboBoxY, findInputComboBoxWidth, findInputComboBoxHeight); } - private void setUIRadioButtonBounds(int x, int y, int templateWidth) { - matchX = x + templateWidth / 60; - matchY = y + 90; + private void setUIRadioButtonBounds() { + matchX = FIRST_X; + matchY = THIRD_Y; matchWidth = MATCH_WIDTH; - matchHeight = 25; + matchHeight = COMPONENT_HEIGHT; matchRadioButton.setBounds(matchX, matchY, matchWidth, matchHeight); } - private void setRangeComboboxBounds(int x, int y, int templateWidth) { - rangeComboBoxX = x + templateWidth / 2 + templateWidth / 15; - rangeComboBoxY = y + 20; - rangeComboBoxWidth = templateWidth / 3 + templateWidth / 60; - rangeComboBoxHeight = 25; + private void setRangeComboboxBounds() { + rangeComboBoxX = rangeLabelX + rangeLabelWidth; + rangeComboBoxY = FIRST_Y; + rangeComboBoxWidth = inputLength - 3 * GAP; + rangeComboBoxHeight = COMPONENT_HEIGHT; rangeCombobox.setBounds(rangeComboBoxX, rangeComboBoxY, rangeComboBoxWidth, rangeComboBoxHeight); } - private void setFindComboboxBounds(int x, int y, int templateWidth) { - findComboBoxX = x + templateWidth / 30 * 2; - findComboBoxY = y + 20; - findComboBoxWidth = templateWidth / 3 + templateWidth / 60; - findComboBoxHeight = 25; + private void setFindComboboxBounds() { + findComboBoxX = SECOND_X; + findComboBoxY = FIRST_Y; + findComboBoxWidth = inputLength - 4 * GAP; + findComboBoxHeight = COMPONENT_HEIGHT; findCombobox.setBounds(findComboBoxX, findComboBoxY, findComboBoxWidth, findComboBoxHeight); } - private void setResultLabelBounds(int x, int y, int templateWidth) { - resultLabelX = findLabelX; - resultLabelY = y + 125; + private void setResultLabelBounds(int templateWidth) { + resultLabelX = FIRST_X; + resultLabelY = FOURTH_Y; resultLabelWidth = templateWidth; - resultLabelHeight = 25; + resultLabelHeight = COMPONENT_HEIGHT; resultLabel.setBounds(resultLabelX, resultLabelY, resultLabelWidth, resultLabelHeight); } - private void setRangeLabelBounds(int x, int y, int templateWidth) { - rangeLabelX = x + templateWidth / 2 + templateWidth / 60; - rangeLabelY = y + 20; - rangeLabelWidth = findLabelWidth; - rangeLabelHeight = 25; + private void setRangeLabelBounds() { + rangeLabelX = replaceInputComboBoxX; + rangeLabelY = FIRST_Y; + rangeLabelWidth = LABEL_WIDTH; + rangeLabelHeight = COMPONENT_HEIGHT; rangeLabel.setBounds(rangeLabelX, rangeLabelY, rangeLabelWidth, rangeLabelHeight); } - private void setFindLabelBounds(int x, int y, int templateWidth) { - findLabelX = x + templateWidth / 60; - findLabelY = y + 20; - findLabelWidth = templateWidth / 20; - findLabelHeight = 25; + private void setFindLabelBounds() { + findLabelX = FIRST_X; + findLabelY = FIRST_Y; + findLabelWidth = LABEL_WIDTH; + findLabelHeight = COMPONENT_HEIGHT; findLabel.setBounds(findLabelX, findLabelY, findLabelWidth, findLabelHeight); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index a240eba96..997013592 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -1,5 +1,6 @@ package com.fr.design.actions.replace.ui; +import javax.swing.BorderFactory; import javax.swing.RowSorter; import javax.swing.table.TableRowSorter; import java.awt.Color; @@ -18,17 +19,21 @@ public class ITReplaceSouthPanel { public static final int CHECKBOX_INDEX = 0; //ITContent在表格的列索引 public static final int CONTENT_INDEX = 6; + public static final int TABLE_GAP = 20; public ITReplaceSouthPanel() { itTableEditor = new ITTableEditor(); tableEditorPane = new ITTableEditorPane<>(itTableEditor); - RowSorter sorter = new TableRowSorter(itTableEditor){ + //左右两边间距20 + tableEditorPane.setBorder(BorderFactory.createEmptyBorder(0, TABLE_GAP, 0, TABLE_GAP)); + RowSorter sorter = new TableRowSorter(itTableEditor) { @Override public boolean isSortable(int column) { return column != CHECKBOX_INDEX || column != CONTENT_INDEX; } }; tableEditorPane.getEditTable().setRowSorter(sorter); + tableEditorPane.getEditTable().setBorder(BorderFactory.createEmptyBorder()); tableEditorPane.getEditTable().setSelectionBackground(new Color(217, 235, 254)); tableEditorPane.getEditTable().setRowHeight(tableEditorPane.getEditTable().getRowHeight() / 2 + tableEditorPane.getEditTable().getRowHeight()); tableEditorPane.makeFace(tableEditorPane.getEditTable()); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index a58091a06..0804efa23 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -12,9 +12,12 @@ import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; +import javax.swing.SwingConstants; import java.awt.Color; import java.awt.Cursor; import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.MouseEvent; /** @@ -29,7 +32,9 @@ public class ITReplaceWestPanel { private UILabel iconLabel; private static final Icon HELP_ICON = IconUtils.readIcon("com/fr/design/images/buttonicon/replace_help.svg"); private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("design.replace.help", "https://help.fanruan.com/finereport/doc-view-4954.html?source=3"); - private static final int FILL_COUNT = 13; + private static final int FILL_COUNT = 12; + public static final int LEFT_WIDTH = 100; + public static final String CONTENT_TEXT = "" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""; public ITReplaceWestPanel() { @@ -37,6 +42,18 @@ public class ITReplaceWestPanel { iconLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Report_Community_Help") + ""); UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + contentButton.setText(CONTENT_TEXT); + contentButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (!contentButton.isSelected()) { + contentButton.setText(CONTENT_TEXT); + } else { + contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + } + } + }); + leftPanel.setBackground(Color.WHITE); contentButton.setSelected(true); contentButton.setBorderPainted(false); leftPanel.add(contentButton); @@ -47,8 +64,8 @@ public class ITReplaceWestPanel { } //添加帮助文档按钮及超链 - iconLabel.setIcon(HELP_ICON); iconLabel.setToolTipText(Toolkit.i18nText("Fine-Design_Replace_Tooltip")); + iconLabel.setHorizontalAlignment(SwingConstants.CENTER); //设置游标 iconLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); iconLabel.addMouseListener(new MouseClickListener() { @@ -58,6 +75,7 @@ public class ITReplaceWestPanel { } }); leftPanel.add(iconLabel); + leftPanel.add(new UILabel(StringUtils.EMPTY)); } public JPanel getLeftPanel() {