diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
index 0ddd3e22d2..8162c7ba86 100644
--- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
+++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
@@ -139,6 +139,15 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
return true;
}
+ /**
+ * 获取UICheckBox的UI层,可以用于设置UI
+ *
+ * @return UICheckBoxUI
+ */
+ public UICheckBoxUI getUICheckBoxUI(){
+ return new UICheckBoxUI();
+ }
+
private class UICheckBoxUI extends MetalCheckBoxUI {
@Override
public synchronized void paint(Graphics g, JComponent c) {
@@ -186,9 +195,9 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC);
}
- if (model.isSelected()) {
- UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2);
- }
+ if (model.isSelected()) {
+ UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2);
+ }
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
// Draw the Text
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 4e31314e4e..f80609e39d 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
@@ -3,6 +3,7 @@ package com.fr.design.actions.replace.ui;
import com.fr.design.actions.replace.action.ShowSearchResultAction;
+import com.fr.design.actions.replace.action.setting.SettingController;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.utils.ShowValueUtils;
@@ -42,7 +43,8 @@ import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable;
* created by Destiny.Lin on 2022-08-10
*/
public class ITReplaceMainDialog extends UIDialog {
- List extends Info> searchResultList = new ArrayList<>();
+ private static List extends Info> searchContentResultList = new ArrayList<>();
+ private static List extends Info> searchSettingResultList = new ArrayList<>();
private static boolean ITReplaceFlag = false;
private static boolean matched = false;
private static volatile ITReplaceMainDialog instance = null;
@@ -53,9 +55,19 @@ public class ITReplaceMainDialog extends UIDialog {
private ITReplaceWestPanel westPanel;
private boolean searchFlag;
private String searchStr;
+ private String settingInputStr;
+ private String settingExtraStr;
private static final int FIRST_ROW = 0;
+ private static final int NONE = 0;
public static int selectCount = 0;
public static int MAIN_PANEL_WIDTH = 929;
+ public static int replaceContentNum = 0;
+ public static int replaceSettingNum = 0;
+ public static int contentReplaceCount = 0;
+ public static int contentReplaceFailedCount = 0;
+ public static int settingReplaceCount = 0;
+ public static int settingReplaceFailedCount = 0;
+
public ITReplaceMainDialog() {
super(DesignerContext.getDesignerFrame());
@@ -131,15 +143,14 @@ public class ITReplaceMainDialog extends UIDialog {
((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- search();
+ search4Content();
}
});
northPane.getSearchButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- search();
-
+ search4Content();
}
});
@@ -147,11 +158,24 @@ public class ITReplaceMainDialog extends UIDialog {
@Override
public void actionPerformed(ActionEvent e) {
if (isSearchFlag()) {
- replace();
+ replace4Content();
}
}
});
- center.add(northPane.getScrollPane(), BorderLayout.NORTH);
+
+ northPane.getSearchSettingButton().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ search4Setting();
+ }
+ });
+ northPane.getReplaceSettingButton().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ replace4Setting();
+ }
+ });
+ center.add(ITReplaceNorthPanel.getCardPanel(), BorderLayout.NORTH);
center.add(southPanel.getTableEditorPane(), BorderLayout.CENTER);
add(westPanel.getLeftPanel(), BorderLayout.WEST);
//主体部分
@@ -162,24 +186,27 @@ public class ITReplaceMainDialog extends UIDialog {
/**
* 替换
*/
- private void replace() {
+ private void replace4Content() {
String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText();
String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText();
- //替换内容为空需要触发搜索
- if (isITReplaceValid() && checkTemplateChanged(searchResultList)) {
+ clearContentCount();
+ if (isITReplaceValid() && checkTemplateChanged(searchContentResultList)) {
if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true);
- for (Info info : searchResultList) {
- if (info.getContent().isSelected()) {
+ for (Info info : searchContentResultList) {
+ if (isAllow2Replace(info)) {
info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray());
+ info.getContent().setReplaced(true);
+ contentReplaceCount++;
}
}
+ northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount));
southPanel.getTableEditorPane().update();
northPane.refreshReplaceInputComboBoxItems();
ITTableEditorPane.getEditTable().repaint();
- setSearchFlag(false);
+ } else {
+ search4Content();
}
- search();
} else {
Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")};
int optionSelected = FineJOptionPane.showOptionDialog(
@@ -195,16 +222,25 @@ public class ITReplaceMainDialog extends UIDialog {
);
//如果选择了重新查找,则再查找一遍
if (optionSelected == 0) {
- search();
+ search4Content();
}
}
+ }
-
+ /**
+ * 是否能够替换
+ *
+ * @param info 存储信息的数据结构
+ * @return 能则返回true
+ */
+ private boolean isAllow2Replace(Info info) {
+ return info.getContent().isSelected() && !info.getContent().isReplaced();
}
+
private Boolean checkTemplateChanged(List extends Info> searchResultList) {
for (Info info : searchResultList) {
- if (!info.checkValid()) {
+ if (!info.getContent().isReplaced() && !info.checkValid()) {
return false;
}
}
@@ -281,10 +317,11 @@ public class ITReplaceMainDialog extends UIDialog {
}
/**
- * 搜索
+ * 搜索模板内容
*/
- public void search() {
+ public void search4Content() {
ITTableEditor itTableEditor = southPanel.getItTableEditor();
+ clearContentCount();
if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID();
@@ -299,24 +336,25 @@ public class ITReplaceMainDialog extends UIDialog {
ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem()));
//搜索
if (searchAction != null) {
- searchResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate));
- itTableEditor.add(searchResultList);
- northPane.getResultLabel().setText("" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "" + searchResultList.size() + "" + Toolkit.i18nText("Fine-Design_Replace_Result"));
+ searchContentResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate));
+ itTableEditor.add(searchContentResultList);
+ northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount));
}
+ replaceContentNum = 0;
ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer();
//刷新表头,并且重新勾选中表头全选框
renderer.refreshHeader(getEditTable(), true);
itTableEditor.fireTableDataChanged();
northPane.refreshFindInputComboBoxItems();
setSearchFlag(true);
- selectCount = searchResultList.size();
+ selectCount = searchContentResultList.size();
//如果有结果,默认选中第一行
- if (searchResultList.size() > 0) {
+ if (searchContentResultList.size() > 0) {
getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW);
}
//更新替换按钮可用性
- if (StringUtils.isEmpty(searchStr) || searchResultList.size() == 0) {
+ if (StringUtils.isEmpty(searchStr) || searchContentResultList.size() == 0) {
northPane.getReplaceButton().setEnabled(false);
} else {
northPane.getReplaceButton().setEnabled(true);
@@ -330,6 +368,126 @@ public class ITReplaceMainDialog extends UIDialog {
}
+ /**
+ * 搜索设置项
+ */
+ public void search4Setting() {
+ ITTableEditor settingEditor = southPanel.getItTableEditor();
+ templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID();
+ templateName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName();
+ clearSettingCount();
+ if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) {
+ String firstStr = GeneralUtils.objectToString(northPane.getFindSettingComboBox().getSelectedItem());
+ String secondStr = GeneralUtils.objectToString(northPane.getFindSettingInputComboBox().getSelectedItem());
+ String thirdStr = GeneralUtils.objectToString(northPane.getFindExtraSettingComboBox().getSelectedItem());
+ setSettingInputStr(secondStr);
+ setSettingExtraStr(thirdStr);
+ SettingController controller = SettingController.match(firstStr);
+ if (controller != null) {
+ searchSettingResultList = controller.addMatchResult(controller.showSearchValue(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()), secondStr, thirdStr);
+ settingEditor.clear();
+ settingEditor.add(searchSettingResultList);
+ ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer();
+ renderer.refreshHeader(getEditTable(), true);
+ settingEditor.fireTableDataChanged();
+ }
+ //如果有结果,默认选中第一行
+ if (searchSettingResultList.size() > 0) {
+ getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW);
+ }
+ northPane.getSettingResultLabel().setText(ShowValueUtils.getResultTip(searchSettingResultList.size(), settingReplaceCount, settingReplaceFailedCount));
+
+ }
+ }
+
+ /**
+ * 替换设置项
+ */
+ public void replace4Setting() {
+ String firstStr = GeneralUtils.objectToString(northPane.getFindSettingComboBox().getSelectedItem());
+ String inputStr = GeneralUtils.objectToString(northPane.getFindSettingInputComboBox().getSelectedItem());
+ String extraStr = GeneralUtils.objectToString(northPane.getFindExtraSettingComboBox().getSelectedItem());
+ clearSettingCount();
+ if (isITReplaceValid() && !isSettingEverChanged(searchSettingResultList, firstStr, inputStr, extraStr)) {
+ if (isInputStrValid(inputStr, extraStr)) {
+ String secondStr = GeneralUtils.objectToString(northPane.getReplaceSettingInputComboBox().getSelectedItem());
+ String thirdStr = GeneralUtils.objectToString(northPane.getReplaceExtraSettingComboBox().getSelectedItem());
+ HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true);
+ for (Info info : searchSettingResultList) {
+ if (info.getContent().isSelected()) {
+ SettingController controller = SettingController.match(firstStr);
+ if (controller != null) {
+ controller.replace(info, secondStr, thirdStr);
+ info.getContent().setReplaced(true);
+ settingReplaceCount++;
+ }
+ }
+ }
+ northPane.getSettingResultLabel().setText(ShowValueUtils.getResultTip(searchSettingResultList.size(), settingReplaceCount, settingReplaceFailedCount));
+ southPanel.getTableEditorPane().update();
+ ITTableEditorPane.getEditTable().repaint();
+ HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified();
+ } else {
+ search4Setting();
+ }
+ } else {
+ Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")};
+ int optionSelected = FineJOptionPane.showOptionDialog(
+ ITReplaceMainDialog.this,
+ Toolkit.i18nText("Fine-Design_Replace_Message"),
+ Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
+ JOptionPane.YES_NO_CANCEL_OPTION,
+ JOptionPane.ERROR_MESSAGE,
+ null,
+ // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框)
+ options,
+ options[0]
+ );
+ //如果选择了重新查找,则再查找一遍
+ if (isSelectSearch(optionSelected)) {
+ search4Setting();
+ }
+ }
+ }
+
+ private boolean isSelectSearch(int optionSelected) {
+ return optionSelected == NONE;
+ }
+
+
+ /**
+ * 用户的输入是否更改
+ *
+ * @param inputStr 用户的一级输入框
+ * @param extraStr 用户的二级输入框
+ * @return 没更改过返回true
+ */
+ public boolean isInputStrValid(String inputStr, String extraStr) {
+ return StringUtils.equals(inputStr, getSettingInputStr()) && StringUtils.equals(extraStr, getSettingExtraStr());
+ }
+
+ /**
+ * 设置项的内容是否更改过
+ *
+ * @param searchSettingResultList 数据
+ * @param controllerMatch controller的类型
+ * @param inputStr 用户的一级输入框
+ * @param extraStr 用户的二级输入框
+ * @return 更改过返回true
+ */
+ public boolean isSettingEverChanged(List extends Info> searchSettingResultList, String controllerMatch, String inputStr, String extraStr) {
+ for (Info info : searchSettingResultList) {
+ if (info.getContent().isSelected() && !info.getContent().isReplaced()) {
+ SettingController controller = SettingController.match(controllerMatch);
+ if (controller != null && controller.isEverChanged(info, inputStr, extraStr)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
public ITReplaceSouthPanel getSouthPanel() {
return southPanel;
}
@@ -346,10 +504,58 @@ public class ITReplaceMainDialog extends UIDialog {
this.northPane = northPane;
}
+ public String getSettingInputStr() {
+ return settingInputStr;
+ }
+
+ public void setSettingInputStr(String settingInputStr) {
+ this.settingInputStr = settingInputStr;
+ }
+
+ public String getSettingExtraStr() {
+ return settingExtraStr;
+ }
+
+ public void setSettingExtraStr(String settingExtraStr) {
+ this.settingExtraStr = settingExtraStr;
+ }
+
/**
* 检测结果是否合法
*/
@Override
public void checkValid() throws Exception {
}
+
+ public static List extends Info> getSearchContentResultList() {
+ return searchContentResultList;
+ }
+
+ public void setSearchContentResultList(List extends Info> searchContentResultList) {
+ this.searchContentResultList = searchContentResultList;
+ }
+
+ public static List extends Info> getSearchSettingResultList() {
+ return searchSettingResultList;
+ }
+
+ public void setSearchSettingResultList(List extends Info> searchSettingResultList) {
+ this.searchSettingResultList = searchSettingResultList;
+ }
+
+ /**
+ * 重置计数
+ */
+ public void clearContentCount() {
+ contentReplaceCount = NONE;
+ contentReplaceFailedCount = NONE;
+ }
+
+ /**
+ * 重置计数
+ */
+ public void clearSettingCount() {
+ settingReplaceCount = NONE;
+ settingReplaceFailedCount = NONE;
+ }
}
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 909ce7112a..60300de2a9 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,12 +1,16 @@
package com.fr.design.actions.replace.ui;
import com.fr.base.svg.IconUtils;
+import com.fr.design.actions.replace.action.setting.SettingContent;
+import com.fr.design.actions.replace.action.setting.SettingController;
+import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
+import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
@@ -16,11 +20,15 @@ import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.ScrollPaneConstants;
+import java.awt.CardLayout;
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.Collections;
+import java.util.List;
/**
* 上面板
@@ -30,7 +38,12 @@ import java.util.Collections;
* created by Destiny.Lin on 2022-09-01
*/
public class ITReplaceNorthPanel {
- private JPanel upPanel;
+ private JPanel upContentPanel;
+ private JPanel upSettingPanel;
+ private static JPanel cardPanel;
+ private static CardLayout cardLayout;
+
+ //content
private UILabel findLabel;
private UILabel rangeLabel;
private UILabel resultLabel;
@@ -38,12 +51,28 @@ public class ITReplaceNorthPanel {
private UIComboBox rangeCombobox;
private JCheckBox matchRadioButton;
private UILabel iconLabel;
-
private UIComboBox findInputCombobox;
private UIComboBox replaceInputCombobox;
- private UIScrollPane scrollPane;
+ private UIScrollPane contentScrollPane;
+ private UIScrollPane settingScrollPane;
private UIButton replaceButton;
private UIButton searchButton;
+
+ //setting
+ private UILabel iconSettingLabel;
+ private UILabel findSettingLabel;
+ private UILabel rangeSettingLabel;
+ private UILabel settingResultLabel;
+ private UIComboBox rangeSettingComboBox;
+ private UIComboBox findSettingComboBox;
+ private UIComboBox findSettingInputComboBox;
+ private UIComboBox replaceSettingInputComboBox;
+ private UIComboBox findExtraSettingComboBox;
+ private UIComboBox replaceExtraSettingComboBox;
+ private TableDataComboBox tableDataComboBox;
+ private UIButton replaceSettingButton;
+ private UIButton searchSettingButton;
+
private static double rate = 1.00;
//存储的5次最近输入
@@ -59,6 +88,10 @@ public class ITReplaceNorthPanel {
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 static final String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")};
+
+ public static final String CARD_CONTENT = "Content";
+ public static final String CARD_SETTING = "setting";
private int findLabelX, findLabelY, findLabelWidth, findLabelHeight;
@@ -74,9 +107,14 @@ public class ITReplaceNorthPanel {
private int iconX, iconY, iconWidth, iconHeight;
private int inputLength;
- public static ArrayList findItems = new ArrayList<>();
- public static ArrayList findInputItems = new ArrayList<>();
- public static ArrayList replaceInputItems = new ArrayList<>();
+ public static List findItems = new ArrayList<>();
+ public static List findSettingItems = new ArrayList<>();
+ public static List findInputItems = new ArrayList<>();
+ public static List replaceInputItems = new ArrayList<>();
+ public static List formatItems = new ArrayList<>();
+ public static List digitItems = new ArrayList<>();
+ public static List groupItems = new ArrayList<>();
+ public static List dsColumnItems = new ArrayList<>();
static {
findItems.add(Toolkit.i18nText("Fine-Design_Basic_Cell"));
@@ -86,17 +124,66 @@ public class ITReplaceNorthPanel {
findItems.add(Toolkit.i18nText("Fine-Design_Replace_Component"));
findItems.add(Toolkit.i18nText("Fine-Design_Basic_Widget"));
findItems.add(Toolkit.i18nText("Fine-Design_Basic_Formula"));
+
+
+ findSettingItems.add(SettingContent.CELL_FORMAT_NAME);
+ findSettingItems.add(SettingContent.CELL_DATA_SETTING_NAME);
+ findSettingItems.add(SettingContent.CELL_DS_COLUMN_NAME);
+ findSettingItems.add(SettingContent.DATASOURCE_CONNECTION_NAME);
+ findSettingItems.add(SettingContent.DATASOURCE_COLLECT_NAME);
+
+ formatItems.add(SettingContent.FORMAT_COMMON);
+ formatItems.add(SettingContent.FORMAT_NUMBER);
+ formatItems.add(SettingContent.FORMAT_MONEY);
+ formatItems.add(SettingContent.FORMAT_PERCENT);
+ formatItems.add(SettingContent.FORMAT_PERMILLAGE);
+ formatItems.add(SettingContent.FORMAT_SCIENCE);
+ formatItems.add(SettingContent.FORMAT_DATE);
+ formatItems.add(SettingContent.FORMAT_TIME);
+ formatItems.add(SettingContent.FORMAT_TEXT);
+
+ digitItems.add(SettingContent.DIGIT_SETTING_GROUP);
+ digitItems.add(SettingContent.DIGIT_SETTING_LIST);
+ digitItems.add(SettingContent.DIGIT_SETTING_SUM);
+
+ groupItems.add(SettingContent.GROUP_COMMON);
+ groupItems.add(SettingContent.GROUP_CONTINUUM);
+
+ dsColumnItems.add(SettingContent.CONNECTION_TEMPLATE);
}
public ITReplaceNorthPanel() {
- upPanel = new JPanel(null);
+ cardLayout = new CardLayout();
+ cardPanel = new JPanel(cardLayout);
+ upContentPanel = new JPanel(null);
+ upSettingPanel = new JPanel(null);
+
+ initContentPanel();
+ initSettingPanel();
+
+
+ cardPanel.add(contentScrollPane, CARD_CONTENT);
+ cardPanel.add(upSettingPanel, CARD_SETTING);
+ }
+
+ /**
+ * 限制尺寸
+ *
+ * @param width
+ */
+ public void setLimitSize(int width) {
+ upContentPanel.setMaximumSize(new Dimension(limit_width, HEIGHT));
+ upContentPanel.setPreferredSize(new Dimension(limit_width, HEIGHT));
+ }
+ /**
+ * 初始化模板内容查找面板
+ */
+ public void initContentPanel() {
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")};
String[] replaceInputItems = new String[]{StringUtils.EMPTY};
findCombobox = new UIComboBox(findItems.toArray());
rangeCombobox = new UIComboBox(rangeItems);
@@ -122,32 +209,198 @@ 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));
- scrollPane = new UIScrollPane(upPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- upPanel.add(findLabel);
- upPanel.add(rangeLabel);
- upPanel.add(resultLabel);
- upPanel.add(findCombobox);
- upPanel.add(rangeCombobox);
- upPanel.add(findInputCombobox);
- upPanel.add(replaceInputCombobox);
- upPanel.add(matchRadioButton);
- upPanel.add(replaceButton);
- upPanel.add(searchButton);
- upPanel.add(iconLabel);
- scrollPane.setBorder(BorderFactory.createEmptyBorder());
+ upContentPanel.setPreferredSize(new Dimension(limit_width, HEIGHT));
+ contentScrollPane = new UIScrollPane(upContentPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ upContentPanel.add(findLabel);
+ upContentPanel.add(rangeLabel);
+ upContentPanel.add(resultLabel);
+ upContentPanel.add(findCombobox);
+ upContentPanel.add(rangeCombobox);
+ upContentPanel.add(findInputCombobox);
+ upContentPanel.add(replaceInputCombobox);
+ upContentPanel.add(matchRadioButton);
+ upContentPanel.add(replaceButton);
+ upContentPanel.add(searchButton);
+ upContentPanel.add(iconLabel);
+ contentScrollPane.setBorder(BorderFactory.createEmptyBorder());
}
/**
- * 限制尺寸
+ * 初始化设置项查找面板
+ */
+ public void initSettingPanel() {
+ findSettingLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element"));
+ rangeSettingLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range"));
+ settingResultLabel = new UILabel();
+ findSettingComboBox = new UIComboBox(findSettingItems.toArray());
+ rangeSettingComboBox = new UIComboBox(rangeItems);
+ findSettingInputComboBox = new UIComboBox(formatItems.toArray()) {
+ @Override
+ public void setEditor(ComboBoxEditor anEditor) {
+ super.setEditor(new ITComboBoxEditor());
+ }
+ };
+ findSettingInputComboBox.setSelectedIndex(-1);
+ replaceSettingInputComboBox = new UIComboBox(formatItems.toArray()) {
+ @Override
+ public void setEditor(ComboBoxEditor anEditor) {
+ super.setEditor(new ITComboBoxEditor());
+ }
+ };
+ replaceSettingInputComboBox.setSelectedIndex(-1);
+
+
+ ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + SettingContent.CELL_FORMAT_NAME);
+ findSettingInputComboBox.setEditable(true);
+ ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false);
+ ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Replace") + SettingContent.CELL_FORMAT_NAME);
+ replaceSettingInputComboBox.setEditable(true);
+ ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false);
+
+
+ iconSettingLabel = new UILabel(CHANGE_ICON);
+ findExtraSettingComboBox = new UIComboBox(groupItems.toArray());
+ findExtraSettingComboBox.setVisible(false);
+ replaceExtraSettingComboBox = new UIComboBox(groupItems.toArray());
+ replaceExtraSettingComboBox.setVisible(false);
+ searchSettingButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button"));
+ replaceSettingButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button"));
+
+ replaceSettingButton.setEnabled(false);
+
+ upSettingPanel.add(findSettingLabel);
+ upSettingPanel.add(rangeSettingLabel);
+ upSettingPanel.add(findSettingComboBox);
+ upSettingPanel.add(rangeSettingComboBox);
+ upSettingPanel.add(findSettingInputComboBox);
+ upSettingPanel.add(replaceSettingInputComboBox);
+ upSettingPanel.add(iconSettingLabel);
+ upSettingPanel.add(findExtraSettingComboBox);
+ upSettingPanel.add(replaceExtraSettingComboBox);
+ upSettingPanel.add(searchSettingButton);
+ upSettingPanel.add(replaceSettingButton);
+ upSettingPanel.add(settingResultLabel);
+ settingScrollPane = new UIScrollPane(upSettingPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ settingScrollPane.setBorder(BorderFactory.createEmptyBorder());
+
+ initListener();
+
+ }
+
+ /**
+ * 初始化事件
+ */
+ private void initListener() {
+ findSettingComboBox.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ replaceSettingInputComboBox.clearBoxItems();
+ findSettingInputComboBox.clearBoxItems();
+ String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
+ ((UITextField) findSettingInputComboBox.getEditor().getEditorComponent()).setText(StringUtils.EMPTY);
+ refreshSettingComboBox(SettingController.getSettingRefreshItems(str));
+ setDataSourceComboBoxStatus(isAllow2Replace());
+ replaceSettingButton.setEnabled(false);
+
+ }
+ });
+
+ findSettingInputComboBox.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ refreshExtraComboBox(findSettingInputComboBox, findExtraSettingComboBox);
+
+ }
+ });
+
+ replaceSettingInputComboBox.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ refreshExtraComboBox(replaceSettingInputComboBox, replaceExtraSettingComboBox);
+ }
+ });
+ }
+
+ /**
+ * 刷新替换按钮状态
+ */
+ public void refreshSettingReplaceButtonStatus() {
+ replaceSettingButton.setEnabled(isAllChoose());
+ }
+
+ /**
+ * 是否各个选项都有选中内容
*
- * @param width
+ * @return 是则返回true
*/
- public void setLimitSize(int width) {
- upPanel.setMaximumSize(new Dimension(limit_width, 161));
- upPanel.setPreferredSize(new Dimension(limit_width, 161));
+ public boolean isAllChoose() {
+ String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
+ String findInputStr = GeneralUtils.objectToString(findSettingInputComboBox.getSelectedItem());
+ String replaceInputStr = GeneralUtils.objectToString(replaceSettingInputComboBox.getSelectedItem());
+ String findExtraStr = GeneralUtils.objectToString(findExtraSettingComboBox.getSelectedItem());
+ String replaceExtraStr = GeneralUtils.objectToString(replaceExtraSettingComboBox.getSelectedItem());
+ return (!StringUtils.equals(str, SettingContent.DATASOURCE_COLLECT_NAME) && !StringUtils.equals(str, SettingContent.DATASOURCE_CONNECTION_NAME))
+ && StringUtils.isNotEmpty(findInputStr)
+ && StringUtils.isNotEmpty(replaceInputStr)
+ && StringUtils.isNotEmpty(findExtraStr)
+ && StringUtils.isNotEmpty(replaceExtraStr);
}
+ /**
+ * 是否支持替换
+ *
+ * @return 支持返回true
+ */
+ public boolean isAllow2Replace() {
+ String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
+ return !StringUtils.equals(str, SettingContent.DATASOURCE_CONNECTION_NAME) && !StringUtils.equals(str, SettingContent.DATASOURCE_COLLECT_NAME);
+ }
+
+ /**
+ * 设置数据集相关情况下的替换框的状态
+ *
+ * @param status
+ */
+ public void setDataSourceComboBoxStatus(boolean status) {
+ replaceSettingButton.setEnabled(status);
+ replaceSettingInputComboBox.setEnabled(status);
+ replaceExtraSettingComboBox.setEnabled(status);
+ }
+
+ /**
+ * 刷新延展出的下拉框(第三层)
+ *
+ * @param settingComboBox
+ * @param extraComboBox
+ */
+ public void refreshExtraComboBox(UIComboBox settingComboBox, UIComboBox extraComboBox) {
+ String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
+ String parent = GeneralUtils.objectToString(settingComboBox.getSelectedItem());
+ if (StringUtils.isNotEmpty(parent) && SettingController.match(str) != null && SettingController.match(str).hasExpand(str, parent)) {
+ extraComboBox.clearBoxItems();
+ extraComboBox.setVisible(true);
+ extraComboBox.refreshBoxItems(SettingController.getSettingExtraRefreshItems(str, parent));
+ extraComboBox.setSelectedIndex(0);
+ } else {
+ extraComboBox.setVisible(false);
+ }
+ refreshSettingReplaceButtonStatus();
+ }
+
+ /**
+ * 刷新用户选择的输入框(第二层)
+ *
+ * @param list
+ */
+ public void refreshSettingComboBox(List list) {
+ findSettingInputComboBox.clearBoxItems();
+ findSettingInputComboBox.refreshBoxItems(list);
+ replaceSettingInputComboBox.clearBoxItems();
+ replaceSettingInputComboBox.refreshBoxItems(list);
+ replaceExtraSettingComboBox.setVisible(false);
+ findExtraSettingComboBox.setVisible(false);
+
+ }
/**
* 适配屏幕
@@ -162,7 +415,50 @@ public class ITReplaceNorthPanel {
templateWidth = templateWidth - ITReplaceWestPanel.LEFT_WIDTH;
inputLength = (templateWidth - GAP * 5) / 2;
+ fitContentScreen(templateWidth);
+ fitSettingScreen(templateWidth);
+
+
+ }
+ /**
+ * 适配屏幕
+ *
+ * @param templateWidth 当前设计器宽度
+ */
+ private void fitSettingScreen(int templateWidth) {
+ findSettingLabel.setBounds(FIRST_X, FIRST_Y, LABEL_WIDTH, COMPONENT_HEIGHT);
+ findSettingComboBox.setBounds(SECOND_X, FIRST_Y, inputLength - 4 * GAP, COMPONENT_HEIGHT);
+ rangeSettingLabel.setBounds(replaceInputComboBoxX, FIRST_Y, LABEL_WIDTH, COMPONENT_HEIGHT);
+ rangeSettingComboBox.setBounds(rangeLabelX + rangeLabelWidth, FIRST_Y, inputLength - 3 * GAP, COMPONENT_HEIGHT);
+ findSettingInputComboBox.setBounds(FIRST_X, SECOND_Y, inputLength - GAP, COMPONENT_HEIGHT);
+ replaceSettingInputComboBox.setBounds(templateWidth - inputLength - GAP * 2, SECOND_Y, inputLength, COMPONENT_HEIGHT);
+ iconSettingLabel.setBounds(iconX, iconY, iconWidth, iconHeight);
+ searchSettingButton.setBounds(searchButtonX, searchButtonY, BUTTON_WIDTH, searchButtonHeight);
+ replaceSettingButton.setBounds(replaceButtonX, replaceButtonY, BUTTON_WIDTH, replaceButtonHeight);
+ settingResultLabel.setBounds(resultLabelX, resultLabelY, resultLabelWidth, resultLabelHeight);
+ setExtraBounds(templateWidth);
+
+
+ }
+
+ /**
+ * 设置额外的输入框
+ *
+ * @param templateWidth 当前设计器宽度
+ */
+ private void setExtraBounds(int templateWidth) {
+ findExtraSettingComboBox.setBounds(FIRST_X, THIRD_Y, inputLength - GAP, COMPONENT_HEIGHT);
+ replaceExtraSettingComboBox.setBounds(templateWidth - inputLength - GAP * 2, THIRD_Y, inputLength, COMPONENT_HEIGHT);
+ }
+
+
+ /**
+ * 模板内容查找面板适配屏幕
+ *
+ * @param templateWidth 当前设计器宽度
+ */
+ private void fitContentScreen(int templateWidth) {
setFindLabelBounds();
setResultLabelBounds(templateWidth);
setFindComboboxBounds();
@@ -174,7 +470,6 @@ public class ITReplaceNorthPanel {
setReplaceButtonBounds();
setSearchButtonBounds();
setIconLabelBounds();
-
}
@@ -221,12 +516,12 @@ public class ITReplaceNorthPanel {
}
- public UIScrollPane getScrollPane() {
- return scrollPane;
+ public UIScrollPane getContentScrollPane() {
+ return contentScrollPane;
}
- public void setScrollPane(UIScrollPane scrollPane) {
- this.scrollPane = scrollPane;
+ public void setContentScrollPane(UIScrollPane contentScrollPane) {
+ this.contentScrollPane = contentScrollPane;
}
private void setIconLabelBounds() {
@@ -320,12 +615,12 @@ public class ITReplaceNorthPanel {
findLabel.setBounds(findLabelX, findLabelY, findLabelWidth, findLabelHeight);
}
- public JPanel getUpPanel() {
- return upPanel;
+ public JPanel getUpContentPanel() {
+ return upContentPanel;
}
- public void setUpPanel(JPanel upPanel) {
- this.upPanel = upPanel;
+ public void setUpContentPanel(JPanel upContentPanel) {
+ this.upContentPanel = upContentPanel;
}
public UILabel getFindLabel() {
@@ -407,4 +702,77 @@ public class ITReplaceNorthPanel {
public void setSearchButton(UIButton searchButton) {
this.searchButton = searchButton;
}
+
+ public static CardLayout getCardLayout() {
+ return cardLayout;
+ }
+
+ public static JPanel getCardPanel() {
+ return cardPanel;
+ }
+
+
+ public UIButton getReplaceSettingButton() {
+ return replaceSettingButton;
+ }
+
+ public void setReplaceSettingButton(UIButton replaceSettingButton) {
+ this.replaceSettingButton = replaceSettingButton;
+ }
+
+ public UIButton getSearchSettingButton() {
+ return searchSettingButton;
+ }
+
+ public void setSearchSettingButton(UIButton searchSettingButton) {
+ this.searchSettingButton = searchSettingButton;
+ }
+
+ public UIComboBox getFindSettingInputComboBox() {
+ return findSettingInputComboBox;
+ }
+
+ public void setFindSettingInputComboBox(UIComboBox findSettingInputComboBox) {
+ this.findSettingInputComboBox = findSettingInputComboBox;
+ }
+
+ public UIComboBox getReplaceSettingInputComboBox() {
+ return replaceSettingInputComboBox;
+ }
+
+ public void setReplaceSettingInputComboBox(UIComboBox replaceSettingInputComboBox) {
+ this.replaceSettingInputComboBox = replaceSettingInputComboBox;
+ }
+
+ public UIComboBox getFindExtraSettingComboBox() {
+ return findExtraSettingComboBox;
+ }
+
+ public void setFindExtraSettingComboBox(UIComboBox findExtraSettingComboBox) {
+ this.findExtraSettingComboBox = findExtraSettingComboBox;
+ }
+
+ public UIComboBox getReplaceExtraSettingComboBox() {
+ return replaceExtraSettingComboBox;
+ }
+
+ public void setReplaceExtraSettingComboBox(UIComboBox replaceExtraSettingComboBox) {
+ this.replaceExtraSettingComboBox = replaceExtraSettingComboBox;
+ }
+
+ public UIComboBox getFindSettingComboBox() {
+ return findSettingComboBox;
+ }
+
+ public void setFindSettingComboBox(UIComboBox findSettingComboBox) {
+ this.findSettingComboBox = findSettingComboBox;
+ }
+
+ public UILabel getSettingResultLabel() {
+ return settingResultLabel;
+ }
+
+ public void setSettingResultLabel(UILabel settingResultLabel) {
+ this.settingResultLabel = settingResultLabel;
+ }
}
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 997013592d..24c441b9a3 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
@@ -14,11 +14,11 @@ import java.awt.Color;
*/
public class ITReplaceSouthPanel {
ITTableEditorPane tableEditorPane;
- ITTableEditor itTableEditor;
+ public static ITTableEditor itTableEditor;
//勾选框索引
public static final int CHECKBOX_INDEX = 0;
//ITContent在表格的列索引
- public static final int CONTENT_INDEX = 6;
+ public static final int CONTENT_INDEX = 7;
public static final int TABLE_GAP = 20;
public ITReplaceSouthPanel() {
@@ -47,7 +47,7 @@ public class ITReplaceSouthPanel {
this.tableEditorPane = tableEditorPane;
}
- public ITTableEditor getItTableEditor() {
+ public static ITTableEditor getItTableEditor() {
return itTableEditor;
}
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 0804efa23b..1c9ed16523 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
@@ -1,6 +1,7 @@
package com.fr.design.actions.replace.ui;
import com.fr.base.svg.IconUtils;
+import com.fr.design.actions.replace.info.Info;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
@@ -19,6 +20,7 @@ import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
+import java.util.List;
/**
* 左侧面板
@@ -30,33 +32,59 @@ import java.awt.event.MouseEvent;
public class ITReplaceWestPanel {
private JPanel leftPanel;
private UILabel iconLabel;
+ private UIToggleButton contentButton;
+ private UIToggleButton settingButton;
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 = 12;
+ private static final int FILL_COUNT = 11;
public static final int LEFT_WIDTH = 100;
public static final String CONTENT_TEXT = "" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + "";
+ public static final String SETTING_TEXT = "" + Toolkit.i18nText("Fine-Design_Replace_Setting") + "";
public ITReplaceWestPanel() {
leftPanel = new JPanel(new GridLayout(15, 1, 0, 0));
iconLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Report_Community_Help") + "");
- UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
+ contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
+ settingButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Replace_Setting"));
contentButton.setText(CONTENT_TEXT);
contentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!contentButton.isSelected()) {
- contentButton.setText(CONTENT_TEXT);
+ showSelectPanel(ITReplaceNorthPanel.CARD_CONTENT, ITReplaceMainDialog.getSearchContentResultList());
} else {
- contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
+ showSelectPanel(ITReplaceNorthPanel.CARD_SETTING, ITReplaceMainDialog.getSearchSettingResultList());
}
+ changeColor4SelectContent();
+ settingButton.setSelected(contentButton.isSelected());
+
+ }
+ });
+
+ settingButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (!settingButton.isSelected()) {
+ showSelectPanel(ITReplaceNorthPanel.CARD_SETTING, ITReplaceMainDialog.getSearchSettingResultList());
+ } else {
+ showSelectPanel(ITReplaceNorthPanel.CARD_CONTENT, ITReplaceMainDialog.getSearchContentResultList());
+ }
+ changeColor4SelectContent();
+ contentButton.setSelected(settingButton.isSelected());
+
}
});
leftPanel.setBackground(Color.WHITE);
+ //默认选中模板内容
contentButton.setSelected(true);
+ settingButton.setSelected(false);
+ //去除按钮的边框
contentButton.setBorderPainted(false);
+ settingButton.setBorderPainted(false);
leftPanel.add(contentButton);
+ leftPanel.add(settingButton);
leftPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, new Color(218, 218, 221)));
//填充一下面板
for (int i = 0; i < FILL_COUNT; i++) {
@@ -85,4 +113,30 @@ public class ITReplaceWestPanel {
public void setLeftPanel(JPanel leftPanel) {
this.leftPanel = leftPanel;
}
+
+ /**
+ * 切换面板时改变颜色
+ */
+ public void changeColor4SelectContent() {
+ if (!contentButton.isSelected()) {
+ contentButton.setText(CONTENT_TEXT);
+ settingButton.setText(Toolkit.i18nText("Fine-Design_Replace_Setting"));
+ } else {
+ contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
+ settingButton.setText(SETTING_TEXT);
+ }
+ }
+
+ /**
+ * 展示指定的面板
+ *
+ * @param str card面板的标签
+ * @param list 对应的表格数据
+ */
+ public void showSelectPanel(String str, List extends Info> list) {
+ ITReplaceNorthPanel.getCardLayout().show(ITReplaceNorthPanel.getCardPanel(), str);
+ ITReplaceSouthPanel.getItTableEditor().clear();
+ ITReplaceSouthPanel.getItTableEditor().add(list);
+ ITReplaceSouthPanel.getItTableEditor().fireTableDataChanged();
+ }
}
diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java
index c4cf47f592..ce11d184d0 100644
--- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java
+++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java
@@ -13,7 +13,6 @@ import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
-
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
@@ -42,7 +41,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
paraButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), 6);
+ ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), ITReplaceSouthPanel.CONTENT_INDEX);
if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) {
ITReplaceMainDialog.setITReplaceFlag(true);
TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString()));
@@ -67,7 +66,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
*/
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- ITContent content = (ITContent) table.getValueAt(row, 6);
+ ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
paraButton.setEnabled(content.isJumpAble());
return paraButton;
}
@@ -85,7 +84,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
*/
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- ITContent content = (ITContent) table.getValueAt(row, 6);
+ ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
paraButton.setEnabled(content.isJumpAble());
return paraButton;
}
diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java
index 0c8819abff..7f4960d21b 100644
--- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java
+++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java
@@ -3,6 +3,7 @@ package com.fr.design.actions.replace.ui;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.info.base.ITContent;
+import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
@@ -12,6 +13,14 @@ import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
+import javax.swing.BorderFactory;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.plaf.UIResource;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Color;
+import java.awt.Component;
import java.util.List;
/**
@@ -28,6 +37,7 @@ public class ITTableEditor extends UITableModelAdapter {
super(new String[]{
StringUtils.BLANK,
Toolkit.i18nText("Fine-Design_Replace_Search_Content"),
+ Toolkit.i18nText("Fine-Design_After_Replace"),
Toolkit.i18nText("Fine-Design_Replace_Template_Name"),
Toolkit.i18nText("Fine-Design_Replace_Sheet_Name"),
Toolkit.i18nText("Fine-Design_Replace_Block_Name"),
@@ -42,11 +52,14 @@ public class ITTableEditor extends UITableModelAdapter {
UILabel.class,
UILabel.class,
UILabel.class,
+ UILabel.class,
ITTableButton.class,
});
this.setDefaultEditor(ITTableButton.class, new ITTableButton());
this.setDefaultRenderer(ITTableButton.class, new ITTableButton());
+ this.setDefaultEditor(Boolean.class, new ITBooleanEditor());
+ this.setDefaultRenderer(Boolean.class, new ITBooleanRenderer());
this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CONTENT_INDEX).setMaxWidth(50);
this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CHECKBOX_INDEX).setMaxWidth(50);
@@ -106,6 +119,9 @@ public class ITTableEditor extends UITableModelAdapter {
fireTableDataChanged();
}
+ /**
+ * 选择的索引
+ */
public enum ChooseIndex {
/**
* 第一列,返回选中情况
@@ -127,9 +143,18 @@ public class ITTableEditor extends UITableModelAdapter {
}
},
/**
- * 第三列,展示模板名
+ * 第三列,展示替换后内容
*/
INDEX_2(2) {
+ @Override
+ public @Nullable Object returnContentObject(ITContent content) {
+ return content.getAfterReplaceStr();
+ }
+ },
+ /**
+ * 第四列,展示模板名
+ */
+ INDEX_3(3) {
@Override
public Object returnContentObject(ITContent content) {
return " " + content.getTemplateName();
@@ -137,9 +162,9 @@ public class ITTableEditor extends UITableModelAdapter {
},
/**
- * 第四列,展示Sheet
+ * 第五列,展示Sheet
*/
- INDEX_3(3) {
+ INDEX_4(4) {
@Override
public Object returnContentObject(ITContent content) {
return " " + content.getSheetName();
@@ -147,18 +172,18 @@ public class ITTableEditor extends UITableModelAdapter {
},
/**
- * 第五列,展示块名、组件名
+ * 第六列,展示块名、组件名
*/
- INDEX_4(4) {
+ INDEX_5(5) {
@Override
public Object returnContentObject(ITContent content) {
return " " + content.getBlockName();
}
},
/**
- * 第六列,展示路径
+ * 第七列,展示路径
*/
- INDEX_5(5) {
+ INDEX_6(6) {
@Override
public Object returnContentObject(ITContent content) {
return " " + content.getOtherPos();
@@ -166,9 +191,9 @@ public class ITTableEditor extends UITableModelAdapter {
},
/**
- * 第七列,展示定位按钮
+ * 第八列,展示定位按钮
*/
- INDEX_6(6) {
+ INDEX_7(7) {
@Override
public Object returnContentObject(ITContent content) {
return content;
@@ -209,4 +234,38 @@ public class ITTableEditor extends UITableModelAdapter {
return null;
}
}
+
+ /**
+ * 用于展示指定风格的checkbox的Editor
+ */
+ public class ITBooleanEditor extends DefaultCellEditor {
+ public ITBooleanEditor() {
+ super(new UICheckBox());
+ UICheckBox checkBox = (UICheckBox) getComponent();
+ checkBox.setHorizontalAlignment(UICheckBox.CENTER);
+ }
+ }
+
+ /**
+ * 用于展示指定风格的checkbox的渲染器
+ */
+ public class ITBooleanRenderer extends UICheckBox implements TableCellRenderer, UIResource {
+ public ITBooleanRenderer() {
+ super();
+ setHorizontalAlignment(JLabel.CENTER);
+ setBorderPainted(true);
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus, int row, int column) {
+ ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
+ setEnabled(!content.isReplaced());
+ setSelected((value != null && ((Boolean) value).booleanValue()));
+ setUI(getUICheckBoxUI());
+ setBorder(BorderFactory.createEmptyBorder());
+ setBackground(Color.WHITE);
+ return this;
+ }
+ }
}
diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java
index 0a743d34eb..f46ea95ac4 100644
--- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java
+++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java
@@ -5,6 +5,7 @@ import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
+import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
@@ -14,7 +15,6 @@ import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.stable.StringUtils;
-import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -85,27 +85,30 @@ public class ITTableEditorPane extends BasicPane {
/**
* 改变面板的各个状态(替换按钮、表头勾选框)
+ *
* @param content
* @param row
* @param col
*/
public void changeComponentStatus(ITContent content, int row, int col) {
- if (content.isSelected()) {
- content.setSelected(false);
- editTable.setValueAt(content.isSelected(), row, col);
- ITReplaceMainDialog.selectCount--;
- //如果没有选中,替换按钮需要置灰
- ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0);
- } else {
- content.setSelected(true);
- editTable.setValueAt(content.isSelected(), row, col);
- ITReplaceMainDialog.selectCount++;
- ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true);
- }
- //更新表头的勾选框状态
- if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) {
- ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer();
- renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount());
+ if (!content.isReplaced()) {
+ if (content.isSelected()) {
+ content.setSelected(false);
+ editTable.setValueAt(content.isSelected(), row, col);
+ ITReplaceMainDialog.selectCount--;
+ //如果没有选中,替换按钮需要置灰
+ ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0);
+ } else {
+ content.setSelected(true);
+ editTable.setValueAt(content.isSelected(), row, col);
+ ITReplaceMainDialog.selectCount++;
+ ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true);
+ }
+ //更新表头的勾选框状态
+ if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) {
+ ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer();
+ renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount());
+ }
}
}
@@ -125,11 +128,11 @@ public class ITTableEditorPane extends BasicPane {
*/
public static class ITHeaderRenderer implements TableCellRenderer {
JTableHeader tableHeader;
- final JCheckBox selectBox;
+ final UICheckBox selectBox;
public ITHeaderRenderer(JTable table) {
this.tableHeader = table.getTableHeader();
- selectBox = new JCheckBox();
+ selectBox = new UICheckBox();
selectBox.setSelected(true);
tableHeader.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
@@ -217,7 +220,10 @@ public class ITTableEditorPane extends BasicPane {
ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(value);
}
for (int i = 0; i < len; i++) {
- ((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX))).setSelected(value);
+ ITContent content = ((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX)));
+ if (!content.isReplaced()) {
+ content.setSelected(value);
+ }
}
}