Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into release/10.0

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
94c2ab2420
  1. 6
      designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java
  2. 10
      designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java
  3. 2
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  4. 36
      designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java
  5. 4
      designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java
  6. 2
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java
  7. 15
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java
  8. 44
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  9. 4
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java
  10. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java
  11. 5
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  12. 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());

10
designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java

@ -77,18 +77,8 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS
}
protected void renameConnection(final String oldName, final String newName) {
Configurations.update(new Worker() {
@Override
public void run() {
tableDataConfig.renameTableData(oldName, newName);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{TableDataConfig.class, ProcedureConfig.class};
}
});
}
};
final BasicDialog globalTableDataDialog = globalTableDataPane.showLargeWindow(designerFrame, null);

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();
}
}

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

@ -60,6 +60,7 @@ public class TableDataCreatorProducer {
"Proc",
"/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) {
@Override
public boolean shouldInsertSeparator() {
return true;
}
@ -92,6 +93,7 @@ public class TableDataCreatorProducer {
};
TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), "/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) {
@Override
public boolean shouldInsertSeparator() {
return true;
}

15
designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java

@ -5,10 +5,13 @@ import com.fr.data.impl.DBTableData;
import com.fr.design.actions.tabledata.TableDataAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.icon.WarningIcon;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
@ -95,6 +98,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
*
* @return 图片
*/
@Override
public Icon menuIcon() {
return createMenuIcon();
}
@ -112,6 +116,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
*
* @return 提示
*/
@Override
public String createTooltip() {
return b ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") : null;
}
@ -166,11 +171,21 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
return false;
}
@Override
public boolean equals(Object obj) {
return obj instanceof TableDataNameObjectCreator
&& ComparatorUtils.equals(menuName, ((TableDataNameObjectCreator) obj).menuName);
}
@Override
public Nameable createNameable(UnrepeatedNameHelper helper) {
try {
return new NameObject(helper.createUnrepeatedName(this.getPrefix()), clazzOfInitCase.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
@Override
public int hashCode() {
return menuName == null ? 0 : menuName.hashCode();

44
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;
@ -14,6 +15,7 @@ import com.fr.file.ProcedureConfig;
import com.fr.file.TableDataConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
@ -47,6 +49,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();
@ -133,36 +143,28 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
return super.createUnrepeatedName(prefix);
}
String[] allDsNames = DesignTableDataManager.getAllDSNames(source);
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = 1;
while (isDsNameRepeated(prefix + count, allDsNames)) {
count++;
}
return prefix + count;
}
private boolean isDsNameRepeated(String name, String[] allDsNames) {
DefaultListModel model = this.getModel();
Nameable[] all = new Nameable[model.getSize()];
for (int i = 0; i < model.size(); i++) {
all[i] = ((ListModelElement) model.get(i)).wrapper;
}
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = all.length + 1;
while (true) {
String name_test = prefix + count;
boolean repeated = false;
for (int i = 0, len = model.size(); i < len; i++) {
Nameable nameable = all[i];
if (ComparatorUtils.equals(nameable.getName(), name_test)) {
repeated = true;
break;
}
}
for (String dsname : allDsNames) {
if (ComparatorUtils.equals(dsname, name_test)) {
repeated = true;
break;
if (ComparatorUtils.equals(nameable.getName(), name)) {
return true;
}
}
if (!repeated) {
return name_test;
}
count++;
}
return ArrayUtils.contains(allDsNames, name);
}
@Override

4
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java

@ -25,7 +25,7 @@ import java.util.Date;
public class EmbeddedTableDataDefinedPane extends BasicPane{
private static final int MIN_CELL_WIDTH = 30;
private EmbeddedTableData tableData;
private JTable dataJTable;
private UIButton add;
@ -64,7 +64,7 @@ public class EmbeddedTableDataDefinedPane extends BasicPane{
// 行号显示
TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0);
tableColumn.setCellRenderer(new CellRenderer());
tableColumn.setMaxWidth(dataJTable.getColumnCount());
tableColumn.setMaxWidth(Math.max(dataJTable.getColumnCount(), MIN_CELL_WIDTH));
// 控制按钮
add = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add"));

3
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java

@ -34,6 +34,7 @@ import java.util.Date;
public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableData> {
private static final int MIN_CELL_WIDTH = 30;
private JTable dataJTable ;
private JScrollPane scrollPane;
private UILabel coordinatelabel;
@ -220,7 +221,7 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa
// 行号显示,每次dateJTable的表结构发生变化时都要调用
TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0);
tableColumn.setCellRenderer(new CellRenderer());
tableColumn.setMaxWidth(dataJTable.getColumnCount());
tableColumn.setMaxWidth(Math.max(dataJTable.getColumnCount(), MIN_CELL_WIDTH));
}
private class DoubleRenderer extends DefaultTableCellRenderer {

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