Browse Source

Merge pull request #1623 in DESIGN/design from ~HADES/design:bugfix/10.0 to bugfix/10.0

* commit '0c3d167b0fc076c69a039935ae89c6b1bc91e2e2':
  REPORT-26837 非法数据集名称
bugfix/10.0
Hades 5 years ago
parent
commit
d03f0e3539
  1. 6
      designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java
  2. 2
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  3. 36
      designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java
  4. 4
      designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java
  5. 9
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  6. 5
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  7. 44
      designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java

6
designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java

@ -42,11 +42,15 @@ public class TableDataSourceAction extends TemplateComponentAction<JTemplate<?,
populate(tds);
}
};
BasicDialog reportTableDataDialog = tableDataPane.showLargeWindow(SwingUtilities.getWindowAncestor(this.getEditingComponent()), null);
final BasicDialog reportTableDataDialog = tableDataPane.showLargeWindow(SwingUtilities.getWindowAncestor(this.getEditingComponent()), null);
reportTableDataDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
if (!tableDataPane.isNamePermitted()) {
reportTableDataDialog.setDoOKSucceed(false);
return;
}
DesignModelAdapter.getCurrentModelAdapter().renameTableData(tableDataPane.getDsNameChangedMap());
tableDataPane.update(tds);
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());

2
designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java

@ -137,6 +137,8 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
nPanel.setShowText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Stored_Procedure_Name_Tips"));
dg.setButtonEnabled(false);
}
} else if (!BasicTableDataUtils.checkName(tempName)) {
dg.setButtonEnabled(false);
} else {
nPanel.setShowText(StringUtils.BLANK);
dg.setButtonEnabled(true);

36
designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java

@ -0,0 +1,36 @@
package com.fr.design.data;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StringUtils;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/4/27
*/
public abstract class BasicTableDataUtils {
private static final int LEN = 2;
public static boolean checkName(String name) {
if (isInValidName(name)) {
FineJOptionPane.showMessageDialog(null,
Toolkit.i18nText("Fine-Design_Basic_DataSet_Rename_Warning", name),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
FineJOptionPane.WARNING_MESSAGE);
return false;
}
return true;
}
public static boolean isInValidName(String name) {
String[] values = name.split("\\.");
if (values.length == LEN) {
return (StringUtils.isNotEmpty(values[0]) && StringUtils.isNotEmpty(values[1]))
|| (StringUtils.isEmpty(values[0]) && StringUtils.isNotEmpty(values[1]));
}
return false;
}
}

4
designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java

@ -59,4 +59,8 @@ public class ReportTableDataPane extends LoadingBasicPane {
public Map<String, String> getDsNameChangedMap() {
return tdPane.getDsNameChangedMap();
}
public boolean isNamePermitted() {
return tdPane.isNamePermitted();
}
}

9
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -4,6 +4,7 @@ import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.api.StoreProcedureAssist;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.BasicTableDataUtils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.controlpane.JListControlPane;
@ -47,6 +48,14 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
Object editingType = getEditingType();
if (!BasicTableDataUtils.checkName(tempName)) {
isNamePermitted = false;
nameableList.stopEditing();
setIllegalIndex(editingIndex);
return;
}
if (StringUtils.isEmpty(tempName)) {
isNamePermitted = false;
nameableList.stopEditing();

5
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -123,8 +123,11 @@ public abstract class UIDialog extends JDialog {
// transfer focus to CurrentEditor
inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "dialogOK");
actionMap.put("dialogOK", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent evt) {
if (!okButton.isEnabled()) {
return;
}
doOK();
}
});

44
designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java

@ -0,0 +1,44 @@
package com.fr.design.data;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/4/27
*/
public class BasicTableDataUtilsTest extends TestCase {
@Test
public void testIsInValidName() {
boolean result1 = BasicTableDataUtils.isInValidName("a.b");
boolean result2 = BasicTableDataUtils.isInValidName("a.b.c");
boolean result3 = BasicTableDataUtils.isInValidName("a..b");
boolean result4 = BasicTableDataUtils.isInValidName("a.");
boolean result5 = BasicTableDataUtils.isInValidName("a.b.");
boolean result6 = BasicTableDataUtils.isInValidName("abc");
boolean result7 = BasicTableDataUtils.isInValidName(".abc");
boolean result8 = BasicTableDataUtils.isInValidName(".ab.c");
boolean result9 = BasicTableDataUtils.isInValidName("ab.c.");
boolean result10 = BasicTableDataUtils.isInValidName(".abc.");
boolean result11 = BasicTableDataUtils.isInValidName(".ab.c.");
boolean result12 = BasicTableDataUtils.isInValidName("..");
Assert.assertTrue(result1);
Assert.assertFalse(result2);
Assert.assertFalse(result3);
Assert.assertFalse(result4);
Assert.assertTrue(result5);
Assert.assertFalse(result6);
Assert.assertTrue(result7);
Assert.assertFalse(result8);
Assert.assertTrue(result9);
Assert.assertTrue(result10);
Assert.assertFalse(result11);
Assert.assertFalse(result12);
}
}
Loading…
Cancel
Save