|
|
|
@ -1,14 +1,19 @@
|
|
|
|
|
package com.fr.design.data.datapane; |
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
import com.fr.data.TableDataSource; |
|
|
|
|
import com.fr.data.impl.DBTableData; |
|
|
|
|
import com.fr.design.actions.tabledata.TableDataAction; |
|
|
|
|
import com.fr.design.beans.BasicBeanPane; |
|
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
|
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; |
|
|
|
@ -32,6 +37,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
|
|
|
|
|
private boolean isNeedInsertSeparator = false; |
|
|
|
|
private String prefix = ""; |
|
|
|
|
private java.util.List<String> names = new ArrayList<String>(); |
|
|
|
|
private String[] allDSNames; |
|
|
|
|
|
|
|
|
|
public TableDataNameObjectCreator(TableDataAction action) { |
|
|
|
|
super(action.getDisplayName(), action.getIconPath(), action.getTableDataClass(), action.getUpdateTableDataPaneClass()); |
|
|
|
@ -90,11 +96,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 取得菜单的图片 |
|
|
|
|
* |
|
|
|
|
* @return 图片 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Icon menuIcon() { |
|
|
|
|
return createMenuIcon(); |
|
|
|
|
} |
|
|
|
@ -107,11 +109,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
|
|
|
|
|
return b ? new WarningIcon(this.menuImage) : this.menuIcon; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建提示 |
|
|
|
|
* |
|
|
|
|
* @return 提示 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public String createTooltip() { |
|
|
|
|
return b ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") : null; |
|
|
|
|
} |
|
|
|
@ -166,11 +164,43 @@ 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(this.createUnrepeatedName(this.getPrefix()), clazzOfInitCase.newInstance()); |
|
|
|
|
} catch (InstantiationException | IllegalAccessException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String createUnrepeatedName(String prefix) { |
|
|
|
|
int count = 1; |
|
|
|
|
|
|
|
|
|
while (isDsNameRepeated(prefix + count)) { |
|
|
|
|
count++; |
|
|
|
|
} |
|
|
|
|
return prefix + count; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isDsNameRepeated(String name) { |
|
|
|
|
if (allDSNames == null) { |
|
|
|
|
TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); |
|
|
|
|
allDSNames = DesignTableDataManager.getAllDSNames(source); |
|
|
|
|
} |
|
|
|
|
for (String allDSName : allDSNames) { |
|
|
|
|
if (ComparatorUtils.equals(name, allDSName)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int hashCode() { |
|
|
|
|
return menuName == null ? 0 : menuName.hashCode(); |
|
|
|
|