Browse Source

REPORT-75998 优化魔术数

feature/x
Destiny.Lin 2 years ago
parent
commit
b583847db8
  1. 6
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java
  2. 6
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java
  3. 10
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java
  4. 20
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

6
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java

@ -14,6 +14,10 @@ import java.awt.Color;
public class ITReplaceSouthPanel {
ITTableEditorPane tableEditorPane;
ITTableEditor itTableEditor;
//勾选框索引
public static final int CHECKBOX_INDEX = 0;
//ITContent在表格的列索引
public static final int CONTENT_INDEX = 6;
public ITReplaceSouthPanel() {
itTableEditor = new ITTableEditor();
@ -21,7 +25,7 @@ public class ITReplaceSouthPanel {
RowSorter<ITTableEditor> sorter = new TableRowSorter<ITTableEditor>(itTableEditor){
@Override
public boolean isSortable(int column) {
return column != 0 || column != 6;
return column != CHECKBOX_INDEX || column != CONTENT_INDEX;
}
};
tableEditorPane.getEditTable().setRowSorter(sorter);

6
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java

@ -48,8 +48,8 @@ public class ITTableEditor extends UITableModelAdapter {
this.setDefaultEditor(ITTableButton.class, new ITTableButton());
this.setDefaultRenderer(ITTableButton.class, new ITTableButton());
this.createTable().getColumnModel().getColumn(6).setMaxWidth(50);
this.createTable().getColumnModel().getColumn(0).setMaxWidth(50);
this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CONTENT_INDEX).setMaxWidth(50);
this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CHECKBOX_INDEX).setMaxWidth(50);
}
@ -81,7 +81,7 @@ public class ITTableEditor extends UITableModelAdapter {
*/
@Override
public boolean isCellEditable(int row, int col) {
return col == 6 || col == 0;
return col == ITReplaceSouthPanel.CONTENT_INDEX || col == ITReplaceSouthPanel.CHECKBOX_INDEX;
}
/**

10
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java

@ -70,8 +70,8 @@ public class ITTableEditorPane<T> extends BasicPane {
public void mouseClicked(MouseEvent e) {
int row = ((JTable) e.getSource()).rowAtPoint(e.getPoint());
int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint());
if (col == 0) {
ITContent content = (ITContent) editTable.getValueAt(row, 6);
if (col == ITReplaceSouthPanel.CHECKBOX_INDEX) {
ITContent content = (ITContent) editTable.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
if (content.isSelected()) {
content.setSelected(false);
editTable.setValueAt(content.isSelected(), row, col);
@ -116,7 +116,7 @@ public class ITTableEditorPane<T> extends BasicPane {
if (e.getClickCount() > 0) {
//获得选中列
int selectColumn = tableHeader.columnAtPoint(e.getPoint());
if (selectColumn == 0) {
if (selectColumn == ITReplaceSouthPanel.CHECKBOX_INDEX) {
boolean value = !selectBox.isSelected();
selectBox.setSelected(value);
selectAllOrNull(value);
@ -152,7 +152,7 @@ public class ITTableEditorPane<T> extends BasicPane {
label.setHorizontalAlignment(SwingConstants.LEFT);
selectBox.setHorizontalAlignment(SwingConstants.CENTER);
selectBox.setBorderPainted(true);
JComponent component = (column == 0) ? selectBox : label;
JComponent component = (column == ITReplaceSouthPanel.CHECKBOX_INDEX) ? selectBox : label;
component.setForeground(tableHeader.getForeground());
component.setBackground(tableHeader.getBackground());
component.setFont(tableHeader.getFont());
@ -187,7 +187,7 @@ public class ITTableEditorPane<T> extends BasicPane {
*/
public static void selectAllOrNull(Boolean value) {
for (int i = 0; i < getEditTable().getRowCount(); i++) {
((ITContent) (getEditTable().getValueAt(i, 6))).setSelected(value);
((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX))).setSelected(value);
}
}

20
designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

@ -79,18 +79,18 @@ public class ShowValueUtils {
/**
* 转换正则表达式
*
* @param regex
* @param regexStr
* @return
*/
public static String changeRegex(String regex) {
public static String changeRegex(String regexStr) {
String change = "\\";
for (int i = 0; i < specialCharList.size(); i++) {
regex = regex.replace(specialCharList.get(i), change + specialCharList.get(i));
regexStr = regexStr.replace(specialCharList.get(i), change + specialCharList.get(i));
}
regex = regex.replace(NUMBER, NUMBER_REGEX);
regex = regex.replace(ENGLISH, ENGLISH_REGEX);
regex = regex.replace(ANY_THING, ANY_THING_REGEX);
return regex;
regexStr = regexStr.replace(NUMBER, NUMBER_REGEX);
regexStr = regexStr.replace(ENGLISH, ENGLISH_REGEX);
regexStr = regexStr.replace(ANY_THING, ANY_THING_REGEX);
return regexStr;
}
/**
@ -170,13 +170,13 @@ public class ShowValueUtils {
* 支持正则表达式的indexOf
*
* @param str
* @param regex
* @param regexStr
* @return
*/
public static int indexOf(String str, String regex) {
public static int indexOf(String str, String regexStr) {
CharSequence inputStr = str;
int failReturn = -1;
String patternStr = changeRegex(regex);
String patternStr = changeRegex(regexStr);
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
if (matcher.find()) {

Loading…
Cancel
Save