yhq
1 year ago
commit
ee0652e4ea
22 changed files with 3221 additions and 0 deletions
@ -0,0 +1,126 @@
|
||||
|
||||
apply plugin: 'java' |
||||
|
||||
|
||||
ext { |
||||
/** |
||||
* 项目中依赖的jar的路径 |
||||
* 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 |
||||
* 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 |
||||
*/ |
||||
libPath = "$projectDir/../webroot/WEB-INF/lib" |
||||
|
||||
/** |
||||
* 是否对插件的class进行加密保护,防止反编译 |
||||
*/ |
||||
guard = false |
||||
|
||||
def pluginInfo = getPluginInfo() |
||||
pluginPre = "fine-plugin" |
||||
pluginName = pluginInfo.id |
||||
pluginVersion = pluginInfo.version |
||||
|
||||
outputPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-"+pluginVersion+"/classes" |
||||
} |
||||
|
||||
group = 'com.fr.plugin' |
||||
version = '10.0' |
||||
sourceCompatibility = '8' |
||||
|
||||
sourceSets { |
||||
main { |
||||
java.outputDir = file(outputPath) |
||||
output.resourcesDir = file(outputPath) |
||||
} |
||||
} |
||||
|
||||
ant.importBuild("encrypt.xml") |
||||
//定义ant变量 |
||||
ant.projectDir = projectDir |
||||
ant.references["compile.classpath"] = ant.path { |
||||
fileset(dir: libPath, includes: '**/*.jar') |
||||
fileset(dir: ".",includes:"**/*.jar" ) |
||||
} |
||||
|
||||
classes.dependsOn('clean') |
||||
|
||||
task copyFiles(type: Copy,dependsOn: 'classes'){ |
||||
from outputPath |
||||
into "$projectDir/classes" |
||||
} |
||||
|
||||
task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){ |
||||
from "$projectDir/classes" |
||||
into "$projectDir/transform-classes" |
||||
include "**/*.*" |
||||
} |
||||
jar.dependsOn("preJar") |
||||
|
||||
task makeJar(type: Jar,dependsOn: preJar){ |
||||
from fileTree(dir: "$projectDir/transform-classes") |
||||
baseName pluginPre |
||||
appendix pluginName |
||||
version pluginVersion |
||||
destinationDir = file("$buildDir/libs") |
||||
|
||||
doLast(){ |
||||
delete file("$projectDir/classes") |
||||
delete file("$projectDir/transform-classes") |
||||
} |
||||
} |
||||
|
||||
task copyFile(type: Copy,dependsOn: ["makeJar"]){ |
||||
from "$buildDir/libs" |
||||
from("$projectDir/lib") { |
||||
include "*.jar" |
||||
} |
||||
from "$projectDir/plugin.xml" |
||||
into file("$buildDir/temp/plugin") |
||||
} |
||||
|
||||
task zip(type:Zip,dependsOn:["copyFile"]){ |
||||
from "$buildDir/temp/plugin" |
||||
destinationDir file("$buildDir/install") |
||||
baseName pluginPre |
||||
appendix pluginName |
||||
version pluginVersion |
||||
} |
||||
|
||||
//控制build时包含哪些文件,排除哪些文件 |
||||
processResources { |
||||
// exclude everything |
||||
// 用*.css没效果 |
||||
// exclude '**/*.css' |
||||
// except this file |
||||
// include 'xx.xml' |
||||
} |
||||
|
||||
/*读取plugin.xml中的version*/ |
||||
def getPluginInfo(){ |
||||
def xmlFile = file("plugin.xml") |
||||
if (!xmlFile.exists()) { |
||||
return ["id":"none", "version":"1.0.0"] |
||||
} |
||||
def plugin = new XmlParser().parse(xmlFile) |
||||
def version = plugin.version[0].text() |
||||
def id = plugin.id[0].text() |
||||
return ["id":id,"version":version] |
||||
} |
||||
|
||||
repositories { |
||||
mavenLocal() |
||||
maven { |
||||
url = uri('http://mvn.finedevelop.com/repository/maven-public/') |
||||
} |
||||
} |
||||
|
||||
dependencies { |
||||
//使用本地jar |
||||
implementation fileTree(dir: 'lib', include: ['**/*.jar']) |
||||
implementation fileTree(dir: libPath, include: ['**/*.jar']) |
||||
} |
||||
|
||||
tasks.withType(JavaCompile) { |
||||
options.encoding = "UTF-8" |
||||
} |
||||
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<project> |
||||
<target name="compile_encrypt_javas" depends="copyFiles"> |
||||
<echo message="加密文件"/> |
||||
<echo message="${projectDir}"/> |
||||
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask"> |
||||
<classpath refid="compile.classpath"/> |
||||
</taskdef> |
||||
<pretreatment baseDir="${projectDir}"/> |
||||
</target> |
||||
<target name="compile_plain_javas" depends="copyFiles"> |
||||
</target> |
||||
</project> |
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugins.dsgroupForV10.v11</id> |
||||
<name><![CDATA[数据集分组]]></name> |
||||
<active>yes</active> |
||||
<version>1.0.0</version> |
||||
<env-version>11.0</env-version> |
||||
<jartime>2022-9-8</jartime> |
||||
<vendor>phetran_ye</vendor> |
||||
<description><![CDATA[为数据集添加分组功能,方便管理数据集]]></description> |
||||
<change-notes> |
||||
<![CDATA[ |
||||
<p>[2018-08-07]开始开发</p> |
||||
<p>[2019-07-23]修复拖动字段bug</p> |
||||
<p>[2020-06-14]服务器数据集适应新版本设计器</p> |
||||
<p>[2020-09-03]根据设计器更新</p> |
||||
<p>[2020-10-16]解决分组下的数据集编辑界面是分组编辑界面bug</p> |
||||
<p>[2020-11-12]解决服务器数据集分组无效bug</p> |
||||
<p>[2021-09-14]适配11.0</p> |
||||
<p>[2022-04-14]10.0服务器数据集保存逻辑修改</p> |
||||
<p>[2022-05-14]修改适配11.0的几个问题</p> |
||||
<p>[2022-09-15]修改适配11.0新版本</p> |
||||
<p>[2023-01-16]修改bug</p> |
||||
<p>[2023-03-14]修复bug</p> |
||||
<p>[2023-04-02]拆分11设计器版本</p> |
||||
]]> |
||||
</change-notes> |
||||
<main-package>com.fr.plugins.dsgroup</main-package> |
||||
<function-recorder class="com.fr.plugins.dsgroup.DSGroupDefine"/> |
||||
<extra-report/> |
||||
<extra-designer> |
||||
<TableDataPaneProcessor class="com.fr.plugins.dsgroup.TableDataPaneProcessorImpl"/> |
||||
<TableDataDefineProvider class="com.fr.plugins.dsgroup.DSGroupDefine"/> |
||||
<ServerTableDataDefineProvider class="com.fr.plugins.dsgroup.DSGroupDefine"/> |
||||
|
||||
</extra-designer> |
||||
<extra-platform/> |
||||
<extra-core> |
||||
<LocaleFinder class="com.fr.plugins.dsgroup.LocaleFinder"/> |
||||
<StableKeyArgsProvider class="com.fr.plugins.dsgroup.rpc.GroupStableKeyArgsProvider"/> |
||||
</extra-core> |
||||
</plugin> |
@ -0,0 +1,55 @@
|
||||
package com.fr.plugins.dsgroup; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||
import com.fr.design.fun.ServerTableDataDefineProvider; |
||||
import com.fr.design.fun.impl.AbstractTableDataDefineProvider; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.plugins.dsgroup.fun.DSGroupTableData; |
||||
import com.fr.plugins.dsgroup.ui.DSGroupPane; |
||||
|
||||
/** |
||||
* Created by phetran_ye on 2018/9/25. |
||||
*/ |
||||
@FunctionRecorder |
||||
public class DSGroupDefine extends AbstractTableDataDefineProvider implements ServerTableDataDefineProvider { |
||||
|
||||
@Override |
||||
@ExecuteFunctionRecord |
||||
public Class<? extends TableData> classForTableData() { |
||||
//return null;
|
||||
return DSGroupTableData.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends TableData> classForInitTableData() { |
||||
//return null;
|
||||
return DSGroupTableData.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends AbstractTableDataPane> appearanceForTableData() { |
||||
return DSGroupPane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForTableData() { |
||||
return Toolkit.i18nText("Data_Set_Group"); |
||||
} |
||||
|
||||
@Override |
||||
public String prefixForTableData() { |
||||
return "group"; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public String iconPathForTableData() { |
||||
return "/com/fr/plugins/dsgroup/ui/images/query.png"; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,237 @@
|
||||
package com.fr.plugins.dsgroup; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.base.TableDataBean; |
||||
import com.fr.config.RemoteConfigEvent; |
||||
import com.fr.design.data.datapane.TableDataPaneListPane; |
||||
import com.fr.esd.event.DSMapping; |
||||
import com.fr.esd.event.DsNameTarget; |
||||
import com.fr.esd.event.StrategyEventsNotifier; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.file.*; |
||||
import com.fr.general.NameObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugins.dsgroup.fun.DSGroupTableData; |
||||
import com.fr.plugins.dsgroup.rpc.GroupTableDataOperator; |
||||
import com.fr.stable.Nameable; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.org.apache.commons.collections4.MapUtils; |
||||
import com.fr.workspace.WorkContext; |
||||
|
||||
|
||||
import javax.swing.*; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* Created by phetran_ye on 2019-03-12. |
||||
* 服务器数据集修改弹窗 |
||||
*/ |
||||
public class GroupTableDataPaneListPane extends TableDataPaneListPane { |
||||
|
||||
/** |
||||
* TableDataManagerPane下面有这个pane, |
||||
* 这个managerPane初始化的时候会将pane的rename方法覆盖 |
||||
* 下面新增的部分就是覆盖逻辑 |
||||
* 参考 TableDataManagerPane的initTableDataManagerPane方法 |
||||
* @param oldName |
||||
* @param newName |
||||
*/ |
||||
@Override |
||||
public void rename(String oldName, String newName) { |
||||
super.rename(oldName, newName); |
||||
(new SwingWorker<Void, Void>() { |
||||
@Override |
||||
protected Void doInBackground() { |
||||
StrategyEventsNotifier.modifyDataSet(new DSMapping[]{DSMapping.ofServerDS(new DsNameTarget(oldName))}); |
||||
return null; |
||||
} |
||||
}).execute(); |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void update(TableDataConfig dataConfig){ |
||||
Nameable[] tableDataArray = this.update(); |
||||
|
||||
//增加逻辑
|
||||
this.handleUpdateRelatedWithGroup(tableDataArray); |
||||
|
||||
final List<TableDataBean> tableDatas = new ArrayList(); |
||||
Map<String,String> nameChangedMap = MapUtils.invertMap(this.getDsNameChangedMap()); |
||||
for(int i=0;i<tableDataArray.length;i++){ |
||||
NameObject nameObject = (NameObject)tableDataArray[i]; |
||||
String oldName=nameChangedMap.get(nameObject.getName()); |
||||
if(oldName==null){ |
||||
oldName= StringUtils.EMPTY; |
||||
} |
||||
tableDatas.add(new TableDataBean(nameObject.getName(), oldName, (TableData)nameObject.getObject())); |
||||
} |
||||
try { |
||||
WorkContext.getCurrent().get(GroupTableDataOperator.class).saveTableData(new ArrayList(dataConfig.getTableDatas().keySet()),tableDatas); |
||||
if (!WorkContext.getCurrent().isLocal()) { |
||||
EventDispatcher.fire(RemoteConfigEvent.EDIT, TableDataConfig.getInstance().getNameSpace()); |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 处理涉及分组的服务器数据集的删改 |
||||
*/ |
||||
private void handleUpdateRelatedWithGroup(Nameable[] nameables) { |
||||
if(nameables==null||nameables.length==0){ |
||||
return; |
||||
} |
||||
TableDataConfig config=TableDataConfig.getInstance(); |
||||
Map<String,TableData> oldTableDataMap=config.getTableDatas(); |
||||
Map<String,TableData> newTableDataMap=new HashMap<>(GroupTableDataTree.TABLE_DATA_SET_INITIAL_SIZE); |
||||
for(Nameable nameable:nameables){ |
||||
NameObject no=(NameObject) nameable; |
||||
newTableDataMap.put(no.getName(),(TableData)no.getObject()); |
||||
} |
||||
Map<String,TableData> removedNormalTableDataMap=new HashMap<>(GroupTableDataTree.TABLE_DATA_SET_INITIAL_SIZE); |
||||
Map<String,DSGroupTableData> removedGroupTableDataMap=new HashMap<>(GroupTableDataTree.TABLE_DATA_SET_INITIAL_SIZE); |
||||
for(Map.Entry<String,TableData> entry:oldTableDataMap.entrySet()){ |
||||
String name=entry.getKey(); |
||||
if(!super.getDsNameChangedMap().containsKey(name)&&!newTableDataMap.containsKey(name)){ |
||||
TableData tableData=entry.getValue(); |
||||
if(tableData instanceof DSGroupTableData){ |
||||
removedGroupTableDataMap.put(name,(DSGroupTableData)tableData); |
||||
}else{ |
||||
removedNormalTableDataMap.put(name,tableData); |
||||
} |
||||
} |
||||
} |
||||
//deal with changing names
|
||||
for(Map.Entry<String,String> entry:super.getDsNameChangedMap().entrySet()){ |
||||
String newName=entry.getValue(); |
||||
String oldName=entry.getKey(); |
||||
for(Nameable nameable:nameables){ |
||||
NameObject no=(NameObject) nameable; |
||||
TableData tableData=(TableData)no.getObject(); |
||||
if(tableData instanceof DSGroupTableData){ |
||||
DSGroupTableData groupData=(DSGroupTableData) tableData; |
||||
if(groupData.hasChild(oldName)){ |
||||
groupData.changeChildName(oldName,newName); |
||||
} |
||||
if(groupData.isChildOf(oldName)){ |
||||
groupData.setParentDSName(newName); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
//deal with removing normal tabledata
|
||||
for(Map.Entry<String,TableData> entry:removedNormalTableDataMap.entrySet()){ |
||||
String removedName=entry.getKey(); |
||||
for(Nameable nameable:nameables){ |
||||
NameObject no=(NameObject) nameable; |
||||
TableData tableData=(TableData)no.getObject(); |
||||
if(tableData instanceof DSGroupTableData){ |
||||
DSGroupTableData groupData=(DSGroupTableData) tableData; |
||||
if(groupData.hasChild(removedName)){ |
||||
groupData.removeChild(removedName); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
//deal with removing group tabledata
|
||||
this.moveChildrenOfRemovedGroupToHigherGroup(removedGroupTableDataMap,newTableDataMap); |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*for(Map.Entry<String,String> entry:super.getDsNameChangedMap().entrySet()){ |
||||
String newName=entry.getValue(); |
||||
String oldName=entry.getKey(); |
||||
String separator= DSGroupTableData.getSeparator(); |
||||
String newNameToReplaceWith=separator+newName+separator; |
||||
String oldNameToMatchWith=separator+oldName+separator; |
||||
for(Nameable nameable:nameables){ |
||||
TableData tableData=(TableData) ((NameObject)nameable).getObject(); |
||||
if(tableData instanceof DSGroupTableData){ |
||||
DSGroupTableData dsGroupTableData=(DSGroupTableData) tableData; |
||||
String childNodes=dsGroupTableData.getChildrenDSNames(); |
||||
if(childNodes!=null){ |
||||
childNodes=separator+childNodes+separator; |
||||
if(childNodes.indexOf(oldNameToMatchWith)>-1){ |
||||
childNodes=childNodes.replace(oldNameToMatchWith,newNameToReplaceWith).replaceAll("^"+separator+"{1}","").replaceAll(separator+"${1}",""); |
||||
dsGroupTableData.setChildrenDSNames(childNodes); |
||||
} |
||||
} |
||||
|
||||
String parentNode=dsGroupTableData.getParentDSName(); |
||||
if(oldName.equals(parentNode)){ |
||||
parentNode=newName; |
||||
dsGroupTableData.setParentDSName(parentNode); |
||||
} |
||||
} |
||||
} |
||||
}*/ |
||||
|
||||
} |
||||
|
||||
private void moveChildrenOfRemovedGroupToHigherGroup(Map<String,DSGroupTableData> removedGroupDataMap,Map<String,TableData> finalTableDatas){ |
||||
while(removedGroupDataMap.size()>0){ |
||||
Set<String> removedNames=new HashSet<>(); |
||||
for(Map.Entry<String,DSGroupTableData> group:removedGroupDataMap.entrySet()){ |
||||
boolean hasAnyChildGroupOfThisNotBeenHandled=false; |
||||
DSGroupTableData groupData=group.getValue(); |
||||
String removedName=group.getKey(); |
||||
if(groupData.hasChildren()){ |
||||
String children=groupData.getChildrenDSNames(); |
||||
String[] childNames=children.split(DSGroupTableData.getSeparator()); |
||||
for(String childName:childNames){ |
||||
if(removedGroupDataMap.containsKey(childName)){ |
||||
hasAnyChildGroupOfThisNotBeenHandled=true; |
||||
} |
||||
} |
||||
if(hasAnyChildGroupOfThisNotBeenHandled){ |
||||
continue; |
||||
} |
||||
|
||||
if(groupData.hasParent()){ |
||||
String parentName=groupData.getParentDSName(); |
||||
if(!removedGroupDataMap.containsKey(parentName)){ |
||||
//父类没被删除
|
||||
((DSGroupTableData)finalTableDatas.get(parentName)).changeChildName(removedName,children); |
||||
}else{ |
||||
removedGroupDataMap.get(parentName).changeChildName(removedName,children); |
||||
} |
||||
} |
||||
|
||||
} |
||||
removedNames.add(removedName); |
||||
} |
||||
for(String name:removedNames){ |
||||
removedGroupDataMap.remove(name); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
/*@Override |
||||
public void update(TableDataConfig dataConfig){ |
||||
LinkedHashMap<String,TableData> tableDatas = new LinkedHashMap(); |
||||
Nameable[] tableDataArray = this.update(); |
||||
for (int i = 0; i < tableDataArray.length; i++) { |
||||
NameObject nameObject = (NameObject) tableDataArray[i]; |
||||
if(changedDatas.containsKey(nameObject.getName())){ |
||||
tableDatas.put(nameObject.getName(),changedDatas.get(nameObject.getName())); |
||||
}else{ |
||||
tableDatas.put(nameObject.getName(), (TableData) nameObject.getObject()); |
||||
} |
||||
|
||||
} |
||||
dataConfig.setTableDatas(tableDatas); |
||||
changedDatas.clear(); |
||||
}*/ |
||||
|
||||
|
||||
} |
@ -0,0 +1,774 @@
|
||||
package com.fr.plugins.dsgroup; |
||||
|
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.base.TableDataBean; |
||||
import com.fr.config.RemoteConfigEvent; |
||||
import com.fr.config.utils.UniqueKey; |
||||
import com.fr.design.DesignModelAdapter; |
||||
|
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.data.datapane.TableDataSourceOP; |
||||
import com.fr.design.data.datapane.TableDataTree; |
||||
import com.fr.design.editlock.EditLockUtils; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.file.*; |
||||
import com.fr.general.NameObject; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugins.dsgroup.fun.DSGroupTableData; |
||||
import com.fr.plugins.dsgroup.rpc.GroupTableDataOperator; |
||||
import com.fr.report.LockItem; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.workspace.WorkContext; |
||||
import javax.swing.tree.*; |
||||
import java.util.*; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by phetran_ye on 2018/8/12. |
||||
* 都是继承TableDataTree,没有多态 |
||||
*/ |
||||
public class GroupTableDataTree extends TableDataTree { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public static final int TABLE_DATA_SET_INITIAL_SIZE=4; |
||||
|
||||
private final int TEMPLATE_TABLE_DATA=0; |
||||
private final int SERVER_TABLE_DATA=1; |
||||
|
||||
private TableDataAware pane; |
||||
public void setPane(TableDataAware p){ |
||||
this.pane=p; |
||||
} |
||||
/** |
||||
* Constructor. |
||||
*/ |
||||
|
||||
// CellRenderer
|
||||
/* |
||||
该属性会在父类构造方法里完成实例化 |
||||
private DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@Override |
||||
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { |
||||
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); |
||||
ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) value; |
||||
Object userObj = treeNode.getUserObject(); |
||||
if (userObj instanceof String) { |
||||
// p:这个是column field.
|
||||
this.setIcon(BaseUtils.readIcon("com/fr/design/images/data/field.png")); |
||||
this.setText((String) userObj); |
||||
} else if (userObj instanceof NameObject) { |
||||
NameObject nameObject = (NameObject) userObj; |
||||
this.setText(nameObject.getName()); |
||||
if (nameObject.getObject() instanceof TableDataWrapper) { |
||||
TableDataWrapper tableDataWrappe = (TableDataWrapper) nameObject.getObject(); |
||||
this.setIcon(tableDataWrappe.getIcon()); |
||||
} else if (nameObject.getObject() instanceof Integer) { |
||||
int num = (Integer) nameObject.getObject(); |
||||
if (num == TableDataSourceOP.SERVER_TABLE_DATA) { |
||||
this.setIcon(BaseUtils.readIcon(IconPathConstants.STD_SHOW_ICON_PATH)); |
||||
} else if (num == TableDataSourceOP.STORE_PRECEDURE_DATA) { |
||||
this.setIcon(BaseUtils.readIcon(IconPathConstants.SP_SHOW_ICON_PATH)); |
||||
} else { |
||||
this.setIcon(BaseUtils.readIcon(IconPathConstants.DS_QUERY_ICON_PATH)); |
||||
} |
||||
} else { |
||||
this.setIcon(BaseUtils.readIcon("/com/fr/design/images/data/store_procedure.png")); |
||||
} |
||||
} else if (userObj == PENDING) { |
||||
this.setIcon(null); |
||||
this.setText(PENDING.toString()); |
||||
} |
||||
*//*
|
||||
11版本设计器更新220325 |
||||
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..."
|
||||
UILabel label = new UILabel(); |
||||
label.setText(getText()); |
||||
label.setIcon(getIcon()); |
||||
Dimension dim = label.getPreferredSize(); |
||||
dim.height += 2; |
||||
this.setSize(dim); |
||||
this.setPreferredSize(dim);*//*
|
||||
this.setB |
||||
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND); |
||||
this.setTextSelectionColor(Color.WHITE); |
||||
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); |
||||
return this; |
||||
} |
||||
}; |
||||
|
||||
public DefaultTreeCellRenderer getTableDataTreeCellRenderer() { |
||||
return tableDataTreeCellRenderer; |
||||
} |
||||
|
||||
public void setTableDataTreeCellRenderer(DefaultTreeCellRenderer tableDataTreeCellRenderer) { |
||||
this.tableDataTreeCellRenderer = tableDataTreeCellRenderer; |
||||
}*/ |
||||
|
||||
/* |
||||
删除220325 |
||||
@Override |
||||
protected void refreshTreeNode(ExpandMutableTreeNode eTreeNode, String childName) { |
||||
if (interceptRefresh(eTreeNode)) { |
||||
return; |
||||
} |
||||
boolean refreshall = childName.isEmpty(); |
||||
ExpandMutableTreeNode[] new_nodes = loadChildTreeNodes(eTreeNode); |
||||
|
||||
List<DefaultMutableTreeNode> childTreeNodeList = new ArrayList<>(); |
||||
for (int i = 0, len = eTreeNode.getChildCount(); i < len; i++) { |
||||
if (eTreeNode.getChildAt(i) instanceof ExpandMutableTreeNode) { |
||||
childTreeNodeList.add((ExpandMutableTreeNode) eTreeNode.getChildAt(i)); |
||||
} else { |
||||
childTreeNodeList.add((DefaultMutableTreeNode) eTreeNode.getChildAt(i)); |
||||
} |
||||
} |
||||
|
||||
eTreeNode.removeAllChildren(); |
||||
|
||||
for (int ci = 0; ci < new_nodes.length; ci++) { |
||||
Object cUserObject = new_nodes[ci].getUserObject(); |
||||
ExpandMutableTreeNode cTreeNode = null; |
||||
for (int ni = 0, nlen = childTreeNodeList.size(); ni < nlen; ni++) { |
||||
cTreeNode = (ExpandMutableTreeNode) childTreeNodeList.get(ni); |
||||
if (ComparatorUtils.equals(cTreeNode.getUserObject(), cUserObject)) { |
||||
if (!refreshall && !ComparatorUtils.equals(childName, ((NameObject) cUserObject).getName())) { |
||||
new_nodes[ci] = cTreeNode; |
||||
break; |
||||
} |
||||
new_nodes[ci].setExpanded(cTreeNode.isExpanded()); |
||||
if (cTreeNode.getChildCount()>0 && cTreeNode.getFirstChild() instanceof ExpandMutableTreeNode && cTreeNode.isExpanded()) { |
||||
checkChildNodes(cTreeNode, new_nodes[ci]); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
//eTreeNode.add(new_nodes[ci]);
|
||||
} |
||||
loadTreeNode(eTreeNode); |
||||
}*/ |
||||
|
||||
|
||||
/* |
||||
* p:获得选中的NameObject = name + tabledata. |
||||
*/ |
||||
@Override |
||||
public NameObject getSelectedNameObject() { |
||||
TreePath selectedTreePath = this.getSelectionPath(); |
||||
if (selectedTreePath == null) { |
||||
return null; |
||||
} |
||||
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent(); |
||||
Object selectedUserObject = selectedTreeNode.getUserObject(); |
||||
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent(); |
||||
if(isGroupData(parentTreeNode)){ |
||||
return (NameObject) selectedUserObject; |
||||
} |
||||
Object parentUserObject = parentTreeNode.getUserObject(); |
||||
if (parentUserObject instanceof NameObject && ((NameObject) parentUserObject).getObject() instanceof Integer) { |
||||
if (selectedUserObject instanceof NameObject) { |
||||
return (NameObject) selectedUserObject; |
||||
} |
||||
} else { |
||||
parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent(); |
||||
parentUserObject = parentTreeNode.getUserObject(); |
||||
|
||||
if (parentUserObject != null) { |
||||
if (!(parentUserObject instanceof NameObject)) { |
||||
return (NameObject) selectedUserObject; |
||||
} |
||||
/*//分组数据集下的子节点返回自身
|
||||
else if(isGroupData(selectedTreeNode)){ |
||||
return (NameObject) selectedUserObject; |
||||
}*/ |
||||
else { |
||||
return (NameObject) parentUserObject; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
|
||||
} |
||||
|
||||
/* |
||||
待验证能否删除 |
||||
public TableDataWrapper[] getSelectedDatas() { |
||||
TreePath[] selectedTreePaths = this.getSelectionPaths(); |
||||
if (selectedTreePaths == null || selectedTreePaths.length == 0) { |
||||
return null; |
||||
} |
||||
TableDataWrapper[] nameobjs = new TableDataWrapper[selectedTreePaths.length]; |
||||
for (int i = 0; i < selectedTreePaths.length; i++) { |
||||
TreePath selectedTreePath = selectedTreePaths[i]; |
||||
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent(); |
||||
Object selectedUserObject = selectedTreeNode.getUserObject(); |
||||
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent(); |
||||
Object parentUserObject = parentTreeNode.getUserObject(); |
||||
if (parentUserObject instanceof NameObject && ((NameObject) parentUserObject).getObject() instanceof Integer) { |
||||
if (selectedUserObject instanceof NameObject) { |
||||
Object obj = ((NameObject) selectedUserObject).getObject(); |
||||
if (obj instanceof TableDataWrapper) { |
||||
nameobjs[i] = (TableDataWrapper) obj; |
||||
} |
||||
} |
||||
} else { |
||||
return new TableDataWrapper[0]; |
||||
} |
||||
} |
||||
|
||||
return nameobjs; |
||||
}*/ |
||||
|
||||
//删除待验证
|
||||
/*public NameObject getRealSelectedNameObject() { |
||||
TreePath selectedTreePath = this.getSelectionPath(); |
||||
if (selectedTreePath == null) { |
||||
return null; |
||||
} |
||||
|
||||
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent(); |
||||
Object selectedUserObject = selectedTreeNode.getUserObject(); |
||||
if (selectedUserObject instanceof NameObject) { |
||||
return (NameObject) selectedUserObject; |
||||
} |
||||
|
||||
selectedTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent(); |
||||
selectedUserObject = selectedTreeNode.getUserObject(); |
||||
if (selectedUserObject instanceof NameObject) { |
||||
return (NameObject) selectedUserObject; |
||||
} |
||||
return null; |
||||
}*/ |
||||
|
||||
/** |
||||
* p:添加一个NameObject节点. |
||||
*/ |
||||
//删除待验证
|
||||
/*public void addNameObject(NameObject no) { |
||||
if (no == null) { |
||||
return; |
||||
} |
||||
DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel(); |
||||
|
||||
// 新建一个放着NameObject的newChildTreeNode,加到Root下面
|
||||
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); |
||||
|
||||
ExpandMutableTreeNode newChildTreeNode = new ExpandMutableTreeNode(no); |
||||
root.add(newChildTreeNode); |
||||
newChildTreeNode.add(new ExpandMutableTreeNode()); |
||||
|
||||
treeModel.reload(root); |
||||
}*/ |
||||
|
||||
/** |
||||
* 覆盖方法,如果是根节点,返回根节点直接下级节点而不是父类的所有节点 |
||||
* @param node |
||||
* @return |
||||
*/ |
||||
@Override |
||||
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode node) { |
||||
DefaultTreeModel treeModel = (DefaultTreeModel) this.getModel(); |
||||
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); |
||||
if(root.equals(node)){ |
||||
return this.loadChildNodesOfRoot(node); |
||||
}else{ |
||||
if(isGroupData(node)){ |
||||
DSGroupTableData ds=this.getGroupData(node); |
||||
if(!ds.hasChildren()){ |
||||
return new ExpandMutableTreeNode[0]; |
||||
} |
||||
ExpandMutableTreeNode[] allNodes=super.loadChildTreeNodes(root); |
||||
Map<String,ExpandMutableTreeNode> allNodesMap=new HashMap<>(TABLE_DATA_SET_INITIAL_SIZE); |
||||
for(ExpandMutableTreeNode nd:allNodes){ |
||||
allNodesMap.put(this.getDSName(nd),nd); |
||||
} |
||||
this.loadDSGroupTreeNode(node,allNodesMap,allNodesMap); |
||||
ExpandMutableTreeNode[] childNodes=new ExpandMutableTreeNode[node.getChildCount()]; |
||||
for(int i=0;i<node.getChildCount();i++){ |
||||
childNodes[i]=(ExpandMutableTreeNode) node.getChildAt(i); |
||||
} |
||||
return childNodes; |
||||
}else{ |
||||
return super.loadChildTreeNodes(node); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 加载根节点直接下级节点 |
||||
* @param root |
||||
* @return |
||||
*/ |
||||
private ExpandMutableTreeNode[] loadChildNodesOfRoot(ExpandMutableTreeNode root){ |
||||
Map<String,ExpandMutableTreeNode> allNodesMap=new HashMap<>(TABLE_DATA_SET_INITIAL_SIZE); |
||||
Map<String,ExpandMutableTreeNode> rootChildrenMap=new HashMap<>(TABLE_DATA_SET_INITIAL_SIZE); |
||||
ExpandMutableTreeNode[] children = super.loadChildTreeNodes(root); |
||||
for(ExpandMutableTreeNode etn:children){ |
||||
allNodesMap.put(this.getDSName(etn),etn); |
||||
rootChildrenMap.put(getDSName(etn),etn); |
||||
} |
||||
for(ExpandMutableTreeNode etn:children){ |
||||
if(!rootChildrenMap.containsKey(this.getDSName(etn))){ |
||||
continue; |
||||
} |
||||
if(isGroupData(etn)){ |
||||
//去掉"正在加载"
|
||||
if(((ExpandMutableTreeNode)etn.getFirstChild()).getUserObject() == PENDING){ |
||||
etn.remove(0); |
||||
} |
||||
if(getGroupData(etn).hasChildren()){ |
||||
loadDSGroupTreeNode(etn, allNodesMap,rootChildrenMap); |
||||
} |
||||
|
||||
} |
||||
} |
||||
if(rootChildrenMap.isEmpty()){ |
||||
return new ExpandMutableTreeNode[0]; |
||||
}else{ |
||||
ExpandMutableTreeNode[] result=new ExpandMutableTreeNode[rootChildrenMap.size()]; |
||||
return rootChildrenMap.values().toArray(result); |
||||
} |
||||
} |
||||
|
||||
public String getDSName(ExpandMutableTreeNode tn){ |
||||
return ((NameObject)tn.getUserObject()).getName(); |
||||
} |
||||
|
||||
public TableData getTableData(ExpandMutableTreeNode tn){ |
||||
return ((TableDataWrapper) ((NameObject)tn.getUserObject()).getObject()).getTableData(); |
||||
} |
||||
|
||||
public DSGroupTableData getGroupData(ExpandMutableTreeNode tn){ |
||||
return (DSGroupTableData)((TableDataWrapper) ((NameObject)tn.getUserObject()).getObject()).getTableData(); |
||||
} |
||||
|
||||
public static boolean isGroupData(ExpandMutableTreeNode tn){ |
||||
if(null==tn) { |
||||
return false; |
||||
} |
||||
if(!(tn.getUserObject() instanceof NameObject)){ |
||||
return false; |
||||
} |
||||
return ((TableDataWrapper) ((NameObject)tn.getUserObject()).getObject()).getTableData() instanceof DSGroupTableData; |
||||
} |
||||
|
||||
public static boolean nodeIsTableData(ExpandMutableTreeNode node){ |
||||
return (node.getUserObject() instanceof NameObject) && ( |
||||
((NameObject)node.getUserObject()).getObject() instanceof TableDataWrapper |
||||
); |
||||
} |
||||
|
||||
private void loadDSGroupTreeNode(ExpandMutableTreeNode groupNode,Map<String,ExpandMutableTreeNode> nodes,Map<String,ExpandMutableTreeNode> leftNodes){ |
||||
DSGroupTableData ds=this.getGroupData(groupNode); |
||||
if(!ds.hasChildren()){ |
||||
return; |
||||
} |
||||
if(groupNode.getChildCount()>0){ |
||||
groupNode.removeAllChildren(); |
||||
} |
||||
String[] nodeNames=ds.getChildrenDSNames().split(DSGroupTableData.getSeparator()); |
||||
//groupNode.removeAllChildren();
|
||||
//有父类的且有效的进行移除,最后不显示
|
||||
if(ds.hasParent()){ |
||||
//检查parent数据是否有效
|
||||
boolean validParent=true; |
||||
String parentDSName=ds.getParentDSName(); |
||||
if(!nodes.containsKey(parentDSName)){ |
||||
validParent=false; |
||||
}else{ |
||||
ExpandMutableTreeNode parentNode=nodes.get(parentDSName); |
||||
if(!isGroupData(parentNode)){ |
||||
validParent=false; |
||||
}else{ |
||||
validParent=getGroupData(parentNode).hasChild(ds.getName()); |
||||
} |
||||
} |
||||
|
||||
//有效的parent数据才会移除
|
||||
if(validParent){ |
||||
leftNodes.remove(ds.getName()); |
||||
} |
||||
} |
||||
|
||||
for(int i=0;i<nodeNames.length;i++){ |
||||
ExpandMutableTreeNode node=nodes.get(nodeNames[i]); |
||||
if(node==null){ |
||||
continue; |
||||
} |
||||
if(isGroupData(node)){ |
||||
//去掉"正在加载"
|
||||
/*if(((ExpandMutableTreeNode)node.getFirstChild()).getUserObject() == PENDING){ |
||||
node.remove(0); |
||||
}*/ |
||||
loadDSGroupTreeNode(node, nodes, leftNodes); |
||||
} |
||||
groupNode.add(node); |
||||
leftNodes.remove(nodeNames[i]); |
||||
} |
||||
} |
||||
|
||||
public void moveToGroup(ExpandMutableTreeNode groupToMoveTo){ |
||||
TableDataSourceOP op=pane.getOp(); |
||||
if (op==null) { |
||||
return; |
||||
} |
||||
boolean global=false; |
||||
if(op.getDataMode()==SERVER_TABLE_DATA){ |
||||
global=true; |
||||
} |
||||
TreePath[] paths=getSelectionPaths(); |
||||
//待分组的节点的父节点,用于展开
|
||||
Set<ExpandMutableTreeNode> parentNodes=new HashSet<>(); |
||||
List<ExpandMutableTreeNode> nodesToMove=new ArrayList<>(); |
||||
ExpandMutableTreeNode root=(ExpandMutableTreeNode)(this.getModel()).getRoot(); |
||||
Map<String,TableData> changedGroupTableDataMap=null; |
||||
if(global){ |
||||
changedGroupTableDataMap=new HashMap<>(TABLE_DATA_SET_INITIAL_SIZE); |
||||
} |
||||
//将选择的节点拼成子节点数据,以防止选择了分组又选择了其下的数据集
|
||||
for(int i=0;i<paths.length;i++){ |
||||
if(!(paths[i].getLastPathComponent() instanceof ExpandMutableTreeNode)){ |
||||
continue; |
||||
} |
||||
ExpandMutableTreeNode tn=(ExpandMutableTreeNode) paths[i].getLastPathComponent(); |
||||
if(!nodeIsTableData(tn)){ |
||||
continue; |
||||
} |
||||
//分组本身
|
||||
if(tn.equals(groupToMoveTo)){ |
||||
continue; |
||||
} |
||||
nodesToMove.add(tn); |
||||
ExpandMutableTreeNode parent=getDsGroupParentNodeIfExists(tn); |
||||
if(parent!=null){ |
||||
//clear
|
||||
this.clearNodeTableDataNameSpace(parent); |
||||
this.moveNodeOutOfParent(parent,tn); |
||||
if(global){ |
||||
changedGroupTableDataMap.put(this.getDSName(parent),this.getGroupData(parent)); |
||||
} |
||||
parentNodes.add(parent); |
||||
} |
||||
groupToMoveTo.add(tn); |
||||
|
||||
} |
||||
if(nodesToMove.size()==0){ |
||||
return; |
||||
} |
||||
//clear
|
||||
this.clearNodeTableDataNameSpace(groupToMoveTo); |
||||
DSGroupTableData groupData=this.getGroupData(groupToMoveTo); |
||||
for(ExpandMutableTreeNode nodeToMove:nodesToMove){ |
||||
//待分组的节点是分组
|
||||
if(isGroupData(nodeToMove)){ |
||||
//clear
|
||||
this.clearNodeTableDataNameSpace(nodeToMove); |
||||
getGroupData(nodeToMove).setParentDSName(getDSName(groupToMoveTo)); |
||||
if(global){ |
||||
changedGroupTableDataMap.put(this.getDSName(nodeToMove),this.getGroupData(nodeToMove)); |
||||
} |
||||
} |
||||
//选中的节点是该分组下的节点
|
||||
if(groupData.hasChild(getDSName(nodeToMove))) { |
||||
continue; |
||||
} |
||||
groupData.addChildren(getDSName(nodeToMove)); |
||||
} |
||||
if(global){ |
||||
changedGroupTableDataMap.put(this.getDSName(groupToMoveTo),this.getGroupData(groupToMoveTo)); |
||||
} |
||||
if(global){ |
||||
onGlobalDsGroupChanged(changedGroupTableDataMap); |
||||
}else{ |
||||
onTemplateDsGroupChanged(); |
||||
} |
||||
parentNodes.add(groupToMoveTo); |
||||
((DefaultTreeModel)this.getModel()).reload(root); |
||||
for(ExpandMutableTreeNode node:parentNodes){ |
||||
this.expandNodesUpwardRecursively(node,root); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void expandNodesUpwardRecursively(ExpandMutableTreeNode node,ExpandMutableTreeNode root){ |
||||
node.setExpanded(true); |
||||
node.expandCurrentTreeNode(this); |
||||
TreeNode parent=node.getParent(); |
||||
if(parent!=null&&!parent.equals(root)&&(parent instanceof ExpandMutableTreeNode)){ |
||||
expandNodesUpwardRecursively((ExpandMutableTreeNode) parent,root); |
||||
} |
||||
} |
||||
|
||||
public void moveToRoot(){ |
||||
TableDataSourceOP op=pane.getOp(); |
||||
if (op==null) { |
||||
return; |
||||
} |
||||
boolean global=false; |
||||
if(op.getDataMode()==SERVER_TABLE_DATA){ |
||||
global=true; |
||||
} |
||||
TreePath[] paths=getSelectionPaths(); |
||||
Map<String,TableData> changedDsGroupTableDatas=null; |
||||
if(global){ |
||||
changedDsGroupTableDatas=new HashMap<>(TABLE_DATA_SET_INITIAL_SIZE); |
||||
} |
||||
//待分组的节点的父节点,用于展开
|
||||
Set<ExpandMutableTreeNode> parentNodes=new HashSet<>(); |
||||
ExpandMutableTreeNode root=(ExpandMutableTreeNode)(this.getModel()).getRoot(); |
||||
int nodeToMoveCnt=0; |
||||
for(int i=0;i<paths.length;i++){ |
||||
if(!(paths[i].getLastPathComponent() instanceof ExpandMutableTreeNode)){ |
||||
continue; |
||||
} |
||||
ExpandMutableTreeNode tn=(ExpandMutableTreeNode) paths[i].getLastPathComponent(); |
||||
if(!nodeIsTableData(tn)){ |
||||
continue; |
||||
} |
||||
nodeToMoveCnt++; |
||||
ExpandMutableTreeNode parent=getDsGroupParentNodeIfExists(tn); |
||||
if(parent!=null){ |
||||
//clear
|
||||
this.clearNodeTableDataNameSpace(parent); |
||||
this.moveNodeOutOfParent(parent,tn); |
||||
if(global){ |
||||
changedDsGroupTableDatas.put(this.getDSName(parent),this.getGroupData(parent)); |
||||
} |
||||
parentNodes.add(parent); |
||||
} |
||||
root.add(tn); |
||||
if(isGroupData(tn)){ |
||||
//clear
|
||||
this.clearNodeTableDataNameSpace(tn); |
||||
getGroupData(tn).setParentDSName(null); |
||||
if(global){ |
||||
changedDsGroupTableDatas.put(getDSName(tn),getTableData(tn)); |
||||
} |
||||
} |
||||
} |
||||
if(nodeToMoveCnt==0){ |
||||
return; |
||||
} |
||||
if(global){ |
||||
onGlobalDsGroupChanged(changedDsGroupTableDatas); |
||||
}else{ |
||||
onTemplateDsGroupChanged(); |
||||
} |
||||
((DefaultTreeModel)this.getModel()).reload(root); |
||||
for(ExpandMutableTreeNode node:parentNodes){ |
||||
this.expandNodesUpwardRecursively(node,root); |
||||
} |
||||
} |
||||
|
||||
private void clearNodeTableDataNameSpace(ExpandMutableTreeNode tn){ |
||||
((UniqueKey)((TableDataWrapper) ((NameObject)tn.getUserObject()).getObject()).getTableData()).setNameSpace(null); |
||||
} |
||||
|
||||
/** |
||||
* 模板数据集分组修改事件响应 |
||||
*/ |
||||
private void onTemplateDsGroupChanged(){ |
||||
pane.getTC().fireTargetModified(); |
||||
} |
||||
|
||||
/** |
||||
* 服务器数据集分组修改事件响应 |
||||
*/ |
||||
private void onGlobalDsGroupChanged(Map<String,TableData> changedGroupTableDataMap){ |
||||
//参照GlobalTableDataAction actionPerform (弹出服务器数据集编辑面板,点确认后保存)
|
||||
boolean lock = EditLockUtils.lock(LockItem.SERVER_TABLE_DATA); |
||||
//!LOCK
|
||||
if (!lock) { |
||||
EditLockUtils.showLockMessage(); |
||||
}else{ |
||||
Map<String,TableData> tableDatas=TableDataConfig.getInstance().getTableDatas(); |
||||
|
||||
//Nameable[] originalDS =new Nameable[tableDataMap.size()];
|
||||
List<TableDataBean> newTDBeans = new ArrayList<>(); |
||||
//貌似没用
|
||||
//List<String> tdNames=new ArrayList<>();
|
||||
/*for(Map.Entry<String,TableData> entry:tableDatas.entrySet()){ |
||||
String name=((NameObject)node.getUserObject()).getName(); |
||||
tdNames.add(name); |
||||
TableData tableData=((TableDataWrapper) ((NameObject)node.getUserObject()).getObject()).getTableData(); |
||||
((UniqueKey)tableData).setNameSpace(null); |
||||
newTDBeans.add(new TableDataBean(name,StringUtils.EMPTY,tableData)); |
||||
}*/ |
||||
for(Map.Entry<String,TableData> entry:tableDatas.entrySet()){ |
||||
String name=entry.getKey(); |
||||
newTDBeans.add(new TableDataBean(name,StringUtils.EMPTY, |
||||
changedGroupTableDataMap.containsKey(name)? changedGroupTableDataMap.get(name) :entry.getValue() |
||||
)); |
||||
} |
||||
//changedDsGroupTableDatas.clear();
|
||||
try { |
||||
WorkContext.getCurrent().get(GroupTableDataOperator.class).saveTableData(Collections.emptyList(),newTDBeans);//new ArrayList<>(tableDataMap.keySet())
|
||||
if (!WorkContext.getCurrent().isLocal()) { |
||||
EventDispatcher.fire(RemoteConfigEvent.EDIT, TableDataConfig.getInstance().getNameSpace()); |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
DesignTableDataManager.clearGlobalDs(); |
||||
//貌似沒用待验证
|
||||
/*Iterator tdIterator = tdNames.iterator(); |
||||
|
||||
while(tdIterator.hasNext()) { |
||||
String var2 = (String)tdIterator.next(); |
||||
DesignTableDataManager.removeSelectedColumnNames(var2); |
||||
}*/ |
||||
GroupTableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); |
||||
DesignTableDataManager.fireDSChanged(new HashMap<>()); |
||||
EditLockUtils.unlock(LockItem.SERVER_TABLE_DATA); |
||||
} |
||||
} |
||||
|
||||
|
||||
//从节点的父节点移除节点,如果父节点是分组还要修改分组数据集数据
|
||||
public void moveNodeOutOfParent(ExpandMutableTreeNode parent, ExpandMutableTreeNode nodeToMove){ |
||||
parent.remove(nodeToMove); |
||||
if(isGroupData(parent)){ |
||||
this.getGroupData(parent).removeChild(this.getDSName(nodeToMove)); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 删除一个数据集节点 |
||||
* @param nodeToRemove |
||||
*/ |
||||
public void removeNode(ExpandMutableTreeNode nodeToRemove){ |
||||
ExpandMutableTreeNode parent=this.getDsGroupParentNodeIfExists(nodeToRemove); |
||||
if(parent==null){ |
||||
//无上级分组并且本身是分组
|
||||
if(isGroupData(nodeToRemove)){ |
||||
for(int i=0;i<nodeToRemove.getChildCount();i++){ |
||||
ExpandMutableTreeNode child=(ExpandMutableTreeNode) nodeToRemove.getChildAt(i); |
||||
if(isGroupData(child)){ |
||||
this.getGroupData(child).setParentDSName(null); |
||||
} |
||||
} |
||||
} |
||||
this.refresh(); |
||||
this.requestFocus(); |
||||
this.setSelectionRow(this.getRowCount() - 1); |
||||
}else{ |
||||
//有上级分组
|
||||
|
||||
if(isGroupData(nodeToRemove)){ |
||||
for(int i=0;i<nodeToRemove.getChildCount();i++){ |
||||
ExpandMutableTreeNode child=(ExpandMutableTreeNode) nodeToRemove.getChildAt(i); |
||||
if(isGroupData(child)){ |
||||
this.getGroupData(child).setParentDSName(this.getDSName(parent)); |
||||
} |
||||
} |
||||
getGroupData(parent).changeChildName(this.getDSName(nodeToRemove),getGroupData(nodeToRemove).getChildrenDSNames()); |
||||
}else{ |
||||
getGroupData(parent).removeChild(this.getDSName(nodeToRemove)); |
||||
} |
||||
this.refreshGroupNode(parent); |
||||
} |
||||
|
||||
} |
||||
|
||||
//更新了某个节点名称
|
||||
public void updateTableDataNodeName(String oldName,String newName){ |
||||
ExpandMutableTreeNode tableDataNode=this.getRealSelectedTableDataNode(); |
||||
ExpandMutableTreeNode parent=getDsGroupParentNodeIfExists(tableDataNode); |
||||
//如果有上级分组
|
||||
if(parent!=null){ |
||||
getGroupData(parent).changeChildName(oldName,newName); |
||||
} |
||||
|
||||
//如果有下级分组
|
||||
for(int i=0;i<tableDataNode.getChildCount();i++){ |
||||
TreeNode cn=tableDataNode.getChildAt(i); |
||||
if(cn instanceof ExpandMutableTreeNode){ |
||||
ExpandMutableTreeNode child=(ExpandMutableTreeNode) cn; |
||||
if(isGroupData(child)){ |
||||
this.getGroupData(child).setParentDSName(newName); |
||||
} |
||||
} |
||||
} |
||||
this.refreshParent(this.getSelectionPath()); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 将一个数据集添加到分组,待添加的包括分组数据集 |
||||
* @param group |
||||
* @param tdName |
||||
*/ |
||||
public void addTableDataToGroup(ExpandMutableTreeNode group,String tdName){ |
||||
DSGroupTableData groupData=getGroupData(group); |
||||
String children=groupData.getChildrenDSNames(); |
||||
children= children==null? tdName : (children+DSGroupTableData.getSeparator()+tdName) ; |
||||
groupData.setChildrenDSNames(children); |
||||
this.refreshGroupNode(group); |
||||
} |
||||
|
||||
/** |
||||
* 分组下的数据集修改后刷新分组节点 |
||||
* @param group |
||||
*/ |
||||
public void refreshGroupNode(ExpandMutableTreeNode group){ |
||||
this.refreshTreeNode(group,StringUtils.EMPTY); |
||||
((DefaultTreeModel)this.getModel()).reload(group); |
||||
if(!group.isExpanded()){ |
||||
group.setExpanded(true); |
||||
} |
||||
group.expandCurrentTreeNode(this); |
||||
} |
||||
|
||||
/** |
||||
* 防止分组下添加数据集的时候不刷新 |
||||
* @param node |
||||
* @return |
||||
*/ |
||||
@Override |
||||
protected boolean interceptRefresh(ExpandMutableTreeNode node) { |
||||
if(isGroupData(node)&&getGroupData(node).hasChildren()){ |
||||
return false; |
||||
}else{ |
||||
return super.interceptRefresh(node); |
||||
} |
||||
} |
||||
|
||||
public ExpandMutableTreeNode getDsGroupParentNodeIfExists(ExpandMutableTreeNode node){ |
||||
TreeNode pnode=node.getParent(); |
||||
if(pnode instanceof ExpandMutableTreeNode){ |
||||
ExpandMutableTreeNode parent=(ExpandMutableTreeNode) pnode; |
||||
if(isGroupData(parent)){ |
||||
return parent; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 获取实际选择的数据集节点 |
||||
* @return |
||||
*/ |
||||
public ExpandMutableTreeNode getRealSelectedTableDataNode() { |
||||
TreePath selectedPath = this.getSelectionPath(); |
||||
if (selectedPath == null) { |
||||
return null; |
||||
} else { |
||||
ExpandMutableTreeNode selectedNode = (ExpandMutableTreeNode)selectedPath.getLastPathComponent(); |
||||
Object object = selectedNode.getUserObject(); |
||||
if (object instanceof NameObject) { |
||||
return selectedNode; |
||||
} else { |
||||
selectedNode = (ExpandMutableTreeNode)selectedNode.getParent(); |
||||
object = selectedNode.getUserObject(); |
||||
return object instanceof NameObject ? selectedNode : null; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,260 @@
|
||||
package com.fr.plugins.dsgroup; |
||||
|
||||
import com.fr.design.data.datapane.TableDataTree; |
||||
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; |
||||
import com.fr.design.mainframe.dnd.ArrayTransferable; |
||||
import com.fr.general.NameObject; |
||||
import com.fr.plugins.dsgroup.GroupTableDataTree; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.tree.TreePath; |
||||
import java.awt.*; |
||||
import java.awt.dnd.*; |
||||
import java.util.*; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by phetran_ye on 2018/8/20. |
||||
*/ |
||||
public class GroupTableDataTreeDragSource extends DragSourceAdapter implements DragGestureListener { |
||||
/*private Point orginPoint; |
||||
private Point orginPointInScreen;*/ |
||||
private TreePath groupToMoveTo; |
||||
private DragSource source=new DragSource(); |
||||
protected String[][] doubleArray; |
||||
|
||||
public GroupTableDataTreeDragSource(JTree tree, int actions) { |
||||
this.source.createDefaultDragGestureRecognizer(tree,actions,this); |
||||
} |
||||
|
||||
/* |
||||
* Drag Gesture Handler |
||||
*/ |
||||
@Override |
||||
public void dragGestureRecognized(DragGestureEvent dge) { |
||||
groupToMoveTo =null; |
||||
Component comp = dge.getComponent(); |
||||
if (comp instanceof TableDataTree) { |
||||
List<String[]> names = new ArrayList(); |
||||
TableDataTree tree = (TableDataTree)comp; |
||||
TreePath[] paths = tree.getSelectionPaths(); |
||||
if (paths == null) { |
||||
return; |
||||
} |
||||
|
||||
this.doubleArray = null; |
||||
this.setnameArray(paths, names); |
||||
this.source.startDrag(dge, DragSource.DefaultLinkDrop, new ArrayTransferable(this.doubleArray), this); |
||||
} |
||||
} |
||||
|
||||
protected void setnameArray(TreePath[] paths, List<String[]> stringList) { |
||||
for (int i = 0; i < paths.length; i++) { |
||||
if ((paths[i] == null) || (paths[i].getPathCount() <= 1)) { |
||||
return;// We can't move the root node or an empty selection
|
||||
} |
||||
ExpandMutableTreeNode segmentMutableTreeNode = (ExpandMutableTreeNode) paths[i].getLastPathComponent(); |
||||
Object userObj = segmentMutableTreeNode.getUserObject(); |
||||
List<String> tableAddress = new ArrayList<String>(); |
||||
String displayName; |
||||
StringBuffer dsNameBuf = new StringBuffer(); |
||||
if (userObj instanceof NameObject) { |
||||
continue; |
||||
} else { |
||||
if (!(userObj instanceof String)) { |
||||
continue; |
||||
} |
||||
displayName = (String) userObj; |
||||
// james 读取表名
|
||||
//分组名不加
|
||||
while (!GroupTableDataTree.isGroupData((ExpandMutableTreeNode) segmentMutableTreeNode.getParent()) && segmentMutableTreeNode.getParent().getParent() != null) { |
||||
segmentMutableTreeNode = (ExpandMutableTreeNode) segmentMutableTreeNode.getParent(); |
||||
ExpandMutableTreeNode datasheetExpandMutableTreeNode = segmentMutableTreeNode; |
||||
Object parentUserObj = datasheetExpandMutableTreeNode.getUserObject(); |
||||
if (parentUserObj instanceof NameObject && !(((NameObject) parentUserObj).getObject() instanceof Integer)) { |
||||
NameObject nameObject = (NameObject) parentUserObj; |
||||
tableAddress.add(nameObject.getName()); |
||||
} |
||||
} |
||||
} |
||||
for (int j = tableAddress.size() - 1; j > -1; j--) { |
||||
dsNameBuf.append(tableAddress.get(j)); |
||||
if (j != 0) { |
||||
dsNameBuf.append('_'); |
||||
} |
||||
} |
||||
String dsName; |
||||
if (dsNameBuf.toString() != null) { |
||||
dsName = dsNameBuf.toString(); |
||||
} else { |
||||
return; |
||||
} |
||||
String[] attributes = {dsName, displayName}; |
||||
stringList.add(attributes); |
||||
Object[] bo = stringList.toArray(); |
||||
doubleArray = new String[bo.length][]; |
||||
for (int io = 0; io < bo.length; io++) { |
||||
if (bo[io] instanceof String[]) { |
||||
doubleArray[io] = (String[]) bo[io]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/*@Override |
||||
public void dragOver(DragSourceDragEvent dsde) { |
||||
DragSourceContext dsc = dsde.getDragSourceContext(); |
||||
Component comp=dsc.getComponent(); |
||||
TableDataTree tree = (TableDataTree) comp; |
||||
Point p=dsde.getLocation(); |
||||
if(null==orginPointInScreen){ |
||||
orginPointInScreen=p; |
||||
} |
||||
TreePath path = tree.getPathForLocation((int)(orginPoint.getX()+p.getX()-orginPointInScreen.getX()), |
||||
(int)(orginPoint.getY()+p.getY()-orginPointInScreen.getY())) ; |
||||
TreePath pt=tree.getPathForLocation((int)(p.getX()-tree.getBounds().getX()),(int)(p.getY()-tree.getBounds().getY())); |
||||
if(pt!=null){ |
||||
System.out.println("++++"+pt.getLastPathComponent().toString()); |
||||
} |
||||
|
||||
if(null==path){ |
||||
if(null!= groupToMoveTo){ |
||||
tree.removeSelectionPath(groupToMoveTo); |
||||
groupToMoveTo=null; |
||||
} |
||||
}else{ |
||||
//移入选择的分组是之前选中的节点之一不做任何处理
|
||||
TreePath[] paths=tree.getSelectionPaths(); |
||||
for(int i=0;i<paths.length;i++){ |
||||
if(paths[i].equals(path)){ |
||||
return; |
||||
} |
||||
} |
||||
if( |
||||
((GroupTableDataTree) tree).isGroupData((ExpandMutableTreeNode) path.getLastPathComponent()) |
||||
){ |
||||
|
||||
if(null==groupToMoveTo){ |
||||
tree.addSelectionPath(path); |
||||
groupToMoveTo =path; |
||||
}else if(!groupToMoveTo.equals(path)){ |
||||
tree.addSelectionPath(path); |
||||
tree.removeSelectionPath(groupToMoveTo); |
||||
groupToMoveTo =path; |
||||
} |
||||
|
||||
}else{ |
||||
if(null!= groupToMoveTo){ |
||||
tree.removeSelectionPath(groupToMoveTo); |
||||
groupToMoveTo=null; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
}*/ |
||||
|
||||
@Override |
||||
public void dragOver(DragSourceDragEvent dsde) { |
||||
DragSourceContext dsc = dsde.getDragSourceContext(); |
||||
Component comp=dsc.getComponent(); |
||||
TableDataTree tree = (TableDataTree) comp; |
||||
Point treePosition=comp.getLocationOnScreen(); |
||||
Point p=dsde.getLocation(); |
||||
TreePath path = tree.getPathForLocation((int)(p.getX()-treePosition.getX()), |
||||
(int)(p.getY()-treePosition.getY())) ; |
||||
if(null==path){ |
||||
if(null!= groupToMoveTo){ |
||||
tree.removeSelectionPath(groupToMoveTo); |
||||
groupToMoveTo=null; |
||||
} |
||||
}else{ |
||||
//移入选择的分组是之前选中的节点之一不做任何处理
|
||||
TreePath[] paths=tree.getSelectionPaths(); |
||||
for(int i=0;i<paths.length;i++){ |
||||
if(paths[i].equals(path)){ |
||||
return; |
||||
} |
||||
} |
||||
if( (path.getLastPathComponent() instanceof ExpandMutableTreeNode) && |
||||
GroupTableDataTree.isGroupData((ExpandMutableTreeNode) path.getLastPathComponent()) |
||||
){ |
||||
|
||||
if(null==groupToMoveTo){ |
||||
tree.addSelectionPath(path); |
||||
groupToMoveTo =path; |
||||
}else if(!groupToMoveTo.equals(path)){ |
||||
tree.addSelectionPath(path); |
||||
tree.removeSelectionPath(groupToMoveTo); |
||||
groupToMoveTo =path; |
||||
} |
||||
|
||||
}else{ |
||||
if(null!= groupToMoveTo){ |
||||
tree.removeSelectionPath(groupToMoveTo); |
||||
groupToMoveTo=null; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
/*@Override |
||||
public void dragDropEnd(DragSourceDropEvent dsde) { |
||||
DragSourceContext dsc = dsde.getDragSourceContext(); |
||||
Component comp=dsc.getComponent(); |
||||
GroupTableDataTree tree = (GroupTableDataTree) comp; |
||||
Point p=dsde.getLocation(); |
||||
if(null==orginPoint||null==orginPointInScreen){ |
||||
return; |
||||
} |
||||
TreePath path = tree.getPathForLocation((int)(orginPoint.getX()+p.getX()-orginPointInScreen.getX()), |
||||
(int)(orginPoint.getY()+p.getY()-orginPointInScreen.getY())) ; |
||||
System.out.println("++++end+"+p.toString()); |
||||
//没选中意味移到根路径下
|
||||
if(null==path) { |
||||
tree.moveToRoot(); |
||||
} |
||||
tree.getBounds() |
||||
//移入的分组如果是选中的节点之一,不做处理,移入后该分组自动选择这里不判断了
|
||||
*//*TreePath[] paths=tree.getSelectionPaths();
|
||||
for(int i=0;i<paths.length;i++){ |
||||
if(paths[i].equals(path)) return; |
||||
}*//*
|
||||
//将数据集或者分组移动到该分组下
|
||||
ExpandMutableTreeNode groupNode=(ExpandMutableTreeNode) groupToMoveTo.getLastPathComponent(); |
||||
if(null!= groupToMoveTo && groupToMoveTo.equals(path)&&tree.isGroupData(groupNode)){ |
||||
tree.moveToGroup(groupNode); |
||||
} |
||||
orginPoint=null; |
||||
orginPointInScreen=null; |
||||
groupToMoveTo =null; |
||||
}*/ |
||||
|
||||
@Override |
||||
public void dragDropEnd(DragSourceDropEvent dsde) { |
||||
DragSourceContext dsc = dsde.getDragSourceContext(); |
||||
Component comp=dsc.getComponent(); |
||||
GroupTableDataTree tree = (GroupTableDataTree) comp; |
||||
Point treePosition=comp.getLocationOnScreen(); |
||||
Point p=dsde.getLocation(); |
||||
TreePath path = tree.getPathForLocation((int)(p.getX()-treePosition.getX()), |
||||
(int)(p.getY()-treePosition.getY())) ; |
||||
//没选中意味移到根路径下
|
||||
if(null==path) { |
||||
tree.moveToRoot(); |
||||
}else{ |
||||
//将数据集或者分组移动到该分组下
|
||||
if(null!= groupToMoveTo && groupToMoveTo.equals(path)){ |
||||
ExpandMutableTreeNode groupNode=(ExpandMutableTreeNode) groupToMoveTo.getLastPathComponent(); |
||||
tree.moveToGroup(groupNode); |
||||
} |
||||
groupToMoveTo =null; |
||||
} |
||||
} |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
||||
package com.fr.plugins.dsgroup; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
/** |
||||
* Created by phetran_ye on 2018/8/7. |
||||
*/ |
||||
public class LocaleFinder extends AbstractLocaleFinder { |
||||
@Override |
||||
|
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
|
||||
public String find() { |
||||
return "com/fr/plugins/dsgroup/locale/locale"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,9 @@
|
||||
package com.fr.plugins.dsgroup; |
||||
|
||||
/** |
||||
* @author phetran_ye |
||||
* 2023-03-18 |
||||
*/ |
||||
public enum PaneActionType { |
||||
ADD,EDIT; |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.fr.plugins.dsgroup; |
||||
|
||||
import com.fr.design.DesignModelAdapter; |
||||
import com.fr.design.data.datapane.TableDataSourceOP; |
||||
|
||||
/** |
||||
* @author phetran_ye |
||||
* 2022-09-12 |
||||
*/ |
||||
public interface TableDataAware { |
||||
DesignModelAdapter getTC(); |
||||
TableDataSourceOP getOp(); |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.plugins.dsgroup; |
||||
|
||||
import com.fr.design.DesignModelAdapter; |
||||
import com.fr.design.actions.server.GlobalTableDataAction; |
||||
import com.fr.design.data.BasicTableDataTreePane; |
||||
import com.fr.design.data.datapane.TableDataPaneController; |
||||
import com.fr.design.fun.impl.AbstractTDPaneProcessor; |
||||
import com.fr.design.menu.ShortCut; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.stable.ProductConstants; |
||||
|
||||
|
||||
/** |
||||
* Created by phetran_ye on 2018/8/8. |
||||
*/ |
||||
public class TableDataPaneProcessorImpl extends AbstractTDPaneProcessor { |
||||
@Override |
||||
public BasicTableDataTreePane createTableDataTreePane(DesignModelAdapter<?, ?> tc) { |
||||
return GroupTableDataTreePane.getInstance(tc); |
||||
} |
||||
|
||||
@Override |
||||
public TableDataPaneController createServerTableDataPane(DesignModelAdapter<?, ?> tc) { |
||||
return new GroupTableDataPaneListPane(); |
||||
} |
||||
|
||||
@Override |
||||
public ShortCut createServerTDAction() { |
||||
return new GlobalTableDataAction(); |
||||
} |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,172 @@
|
||||
package com.fr.plugins.dsgroup.fun; |
||||
|
||||
|
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.impl.SimConf; |
||||
import com.fr.data.AbstractParameterTableData; |
||||
import com.fr.design.mainframe.WestRegionContainerPane; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* Created by richie on 2016/10/8. |
||||
*/ |
||||
public class DSGroupTableData extends AbstractParameterTableData { |
||||
|
||||
private static final String XML_ATTR_TAG = "QueryTableDataAttr"; |
||||
|
||||
private static final String separator="&;"; |
||||
private static final String childrenAttrName="children_DS_names"; |
||||
private static final String parentAttrName="parent_DS_name"; |
||||
private Conf<String> attrParentDSName=new SimConf<>(null); |
||||
private Conf<String> attrChildrenDSNames=new SimConf<>(null); |
||||
|
||||
public Conf<String> getAttrParentDSName() { |
||||
return attrParentDSName; |
||||
} |
||||
|
||||
public void setAttrParentDSName(Conf<String> attrParentDSName) { |
||||
this.attrParentDSName = attrParentDSName; |
||||
} |
||||
|
||||
public Conf<String> getAttrChildrenDSNames() { |
||||
return attrChildrenDSNames; |
||||
} |
||||
|
||||
public void setAttrChildrenDSNames(Conf<String> attrChildrenDSNames) { |
||||
this.attrChildrenDSNames = attrChildrenDSNames; |
||||
} |
||||
|
||||
public static String getSeparator() { |
||||
return separator; |
||||
} |
||||
|
||||
public String getChildrenDSNames() { |
||||
return attrChildrenDSNames.get(); |
||||
} |
||||
|
||||
public boolean hasChildren(){ |
||||
return attrChildrenDSNames.get()!=null; |
||||
} |
||||
|
||||
public boolean hasParent(){ |
||||
return attrParentDSName.get()!=null; |
||||
} |
||||
|
||||
public void setChildrenDSNames(String childrenDSNames) { |
||||
this.attrChildrenDSNames.set(childrenDSNames); |
||||
} |
||||
|
||||
public String getParentDSName() { |
||||
return attrParentDSName.get(); |
||||
} |
||||
|
||||
public void setParentDSName(String parentDSName) { |
||||
this.attrParentDSName.set(parentDSName); |
||||
} |
||||
|
||||
public void addChildren(String children){ |
||||
if(StringUtils.isEmpty(children)){ |
||||
return; |
||||
} |
||||
if(this.hasChildren()){ |
||||
this.setChildrenDSNames(this.getChildrenDSNames()+separator+children); |
||||
}else{ |
||||
this.setChildrenDSNames(children); |
||||
} |
||||
} |
||||
|
||||
public void removeParent(){ |
||||
this.setParentDSName(null); |
||||
} |
||||
|
||||
public void removeChild(String childName){ |
||||
if(!hasChildren()){ |
||||
return; |
||||
} |
||||
String children=this.getChildrenDSNames(); |
||||
children=wrapDsName(children); |
||||
childName=wrapDsName(childName); |
||||
children=children.replace(childName,separator).replaceAll("^"+separator+"{1}","").replaceAll(separator+"${1}",""); |
||||
if(children.length()==0){ |
||||
children=null; |
||||
} |
||||
this.setChildrenDSNames(children); |
||||
} |
||||
|
||||
public boolean hasChild(String childName){ |
||||
if(!hasChildren()){ |
||||
return false; |
||||
}else{ |
||||
childName=wrapDsName(childName); |
||||
String myChildren=wrapDsName(this.getChildrenDSNames()); |
||||
return myChildren.indexOf(childName)>-1; |
||||
} |
||||
} |
||||
|
||||
public boolean isChildOf(String parentName){ |
||||
return parentName.equals(this.getParentDSName()); |
||||
} |
||||
|
||||
public void changeChildName(String oldChildName,String newChildName){ |
||||
if(!hasChildren()||StringUtils.isEmpty(newChildName)){ |
||||
return; |
||||
} |
||||
String children=this.getChildrenDSNames(); |
||||
children=wrapDsName(children); |
||||
oldChildName=wrapDsName(oldChildName); |
||||
newChildName=wrapDsName(newChildName); |
||||
children=children.replace(oldChildName,newChildName).replaceAll("^"+separator+"{1}","").replaceAll(separator+"${1}",""); |
||||
this.setChildrenDSNames(children); |
||||
} |
||||
|
||||
private String wrapDsName(String name){ |
||||
return separator+name+separator; |
||||
} |
||||
|
||||
@Override |
||||
public DataModel createDataModel(Calculator calculator) { |
||||
//return new QueryDataModel(processParameters(calculator));
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
super.readXML(reader); |
||||
if (reader.isChildNode()) { |
||||
String tagName = reader.getTagName(); |
||||
if (tagName.equals(XML_ATTR_TAG)) { |
||||
attrParentDSName = new SimConf<>(reader.getAttrAsString(parentAttrName, null)); |
||||
attrChildrenDSNames = new SimConf<>(reader.getAttrAsString(childrenAttrName, null)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
super.writeXML(writer); |
||||
writer.startTAG(XML_ATTR_TAG); |
||||
writer.attr(parentAttrName, attrParentDSName.get()); |
||||
writer.attr(childrenAttrName, attrChildrenDSNames.get()); |
||||
writer.end(); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
DSGroupTableData cloned = (DSGroupTableData)super.clone(); |
||||
cloned.attrParentDSName=(SimConf<String>)this.attrParentDSName.clone(); |
||||
cloned.attrChildrenDSNames=(SimConf<String>)this.attrChildrenDSNames.clone(); |
||||
return cloned; |
||||
} |
||||
|
||||
public DSGroupTableData newData(){ |
||||
try{ |
||||
return (DSGroupTableData)this.clone(); |
||||
}catch (CloneNotSupportedException e){ |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.plugins.dsgroup.rpc; |
||||
|
||||
import com.fr.module.StableKey; |
||||
import com.fr.stable.fun.impl.AbstractStableKeyArgsProvider; |
||||
import com.fr.workspace.base.WorkspaceKey; |
||||
import com.fr.workspace.pool.WorkRPCRegister; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author phetran_ye |
||||
* 2022-04-20 |
||||
*/ |
||||
public class GroupStableKeyArgsProvider extends AbstractStableKeyArgsProvider<WorkRPCRegister<?>>{ |
||||
@Override |
||||
protected List<WorkRPCRegister<?>> createArgs() { |
||||
return Arrays.asList( WorkRPCRegister.wrap(GroupTableDataOperator.class, GroupTableDataOperatorImpl.getInstance()) ); |
||||
} |
||||
|
||||
@Override |
||||
public StableKey<WorkRPCRegister<?>> getKey() { |
||||
return WorkspaceKey.RPC; |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.fr.plugins.dsgroup.rpc; |
||||
|
||||
import com.fr.base.TableDataBean; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author phetran_ye |
||||
* 2022-04-20 |
||||
*/ |
||||
public interface GroupTableDataOperator { |
||||
boolean saveTableData(List<String> toDeleted, List<TableDataBean> tableDataBeanList) throws Exception; |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.plugins.dsgroup.rpc; |
||||
|
||||
import com.fr.base.TableDataBean; |
||||
import com.fr.file.ConfigChangeProcessor; |
||||
import com.fr.file.TableDataConfig; |
||||
import com.fr.transaction.Configurations; |
||||
import com.fr.transaction.WorkerFacade; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author phetran_ye |
||||
* 2022-04-20 |
||||
*/ |
||||
public class GroupTableDataOperatorImpl implements GroupTableDataOperator{ |
||||
private static final GroupTableDataOperator INSTANCE = new GroupTableDataOperatorImpl(); |
||||
|
||||
public static GroupTableDataOperator getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
@Override |
||||
public boolean saveTableData(List<String> toDeleted, List<TableDataBean> tableDataBeanList) throws Exception { |
||||
return save(tableDataBeanList, new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
removeDeleted(toDeleted); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private boolean save(List<TableDataBean> tableDataBeanList, Runnable deleteAction) { |
||||
ConfigChangeProcessor.getInstance().applyForTableData(tableDataBeanList); |
||||
return Configurations.modify(new WorkerFacade(TableDataConfig.class) { |
||||
@Override |
||||
public void run() { |
||||
deleteAction.run(); |
||||
for (TableDataBean tableDataBean : tableDataBeanList) { |
||||
TableDataConfig.getInstance().addTableData(tableDataBean.getName(), tableDataBean.getTableData()); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void removeDeleted(List<String> toDeleted) { |
||||
for (String name : toDeleted) { |
||||
TableDataConfig.getInstance().removeTableData(name); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,91 @@
|
||||
package com.fr.plugins.dsgroup.ui; |
||||
|
||||
/** |
||||
* Created by phetran_ye on 2018/8/7. |
||||
*/ |
||||
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.WestRegionContainerPane; |
||||
import com.fr.plugins.dsgroup.fun.DSGroupTableData; |
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
public class DSGroupPane extends AbstractTableDataPane<DSGroupTableData> { |
||||
|
||||
//private static final String PREVIEW_BUTTON = Inter.getLocText("Preview");
|
||||
|
||||
|
||||
private UITextField contentTextField; |
||||
private DSGroupTableData tableData; |
||||
|
||||
|
||||
public DSGroupPane() { |
||||
WestRegionContainerPane wp=WestRegionContainerPane.getInstance(); |
||||
setLayout(new BorderLayout()); |
||||
//add(createToolBar(), BorderLayout.NORTH);
|
||||
JPanel contentPane = new JPanel(); |
||||
JLabel infoLbl=new JLabel(); |
||||
String info="<html><body>提示:<br>"; |
||||
info+="1.选中分组,然后添加数据集即可在该分组下添加数据集。<br>"; |
||||
info+="2.拖动数据集到某分组上即可将数据集添加到该分组下。<br>"; |
||||
info+="3.拖动数据集到数据集面板空白处即可将该数据集移到最外部。<br> </body></html>"; |
||||
infoLbl.setText(info); |
||||
contentPane.setLayout(new BorderLayout()); |
||||
contentPane.add(infoLbl, BorderLayout.NORTH); |
||||
add(contentPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
/*private JToolBar createToolBar() { |
||||
ToolBarDef toolBarDef = new ToolBarDef(); |
||||
//toolBarDef.addShortCut(new PreviewQueryTableDataAction());
|
||||
UIToolbar editToolBar = ToolBarDef.createJToolBar(); |
||||
toolBarDef.updateToolBar(editToolBar); |
||||
return editToolBar; |
||||
}*/ |
||||
|
||||
/* private void addChildrenToParent(JPanel contentPane) { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {p, f}; |
||||
|
||||
JPanel panel = TableLayoutHelper.createTableLayoutPane(new Component[][]{ |
||||
{new UILabel("名字"), contentTextField = new UITextField()} |
||||
}, rowSize, columnSize); |
||||
contentPane.add(panel, BorderLayout.CENTER); |
||||
}*/ |
||||
|
||||
@Override |
||||
public void populateBean(DSGroupTableData ob) { |
||||
/*if (ob != null) { |
||||
contentTextField.setText(ob.getText()); |
||||
}*/ |
||||
tableData=ob; |
||||
} |
||||
|
||||
@Override |
||||
public DSGroupTableData updateBean() { |
||||
//DSGroupTableData tableData = new DSGroupTableData();
|
||||
//tableData.setText(contentTextField.getText());
|
||||
return tableData; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Data_Set_Group"); |
||||
} |
||||
|
||||
/*private class PreviewQueryTableDataAction extends UpdateAction { |
||||
public PreviewQueryTableDataAction() { |
||||
this.setName(PREVIEW_BUTTON); |
||||
this.setMnemonic('P'); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent evt) { |
||||
PreviewTablePane.previewTableData(DSGroupPane.this.updateBean()); |
||||
} |
||||
}*/ |
||||
} |
||||
|
@ -0,0 +1,9 @@
|
||||
Plugin-Data_Set_Group=Data Set Group |
||||
Data_Set_Group=Data Set Group |
||||
Default_Group_Name=unnamed group |
||||
Template=Template |
||||
DS-TableData=DS-TableData |
||||
DS-Server_TableData=DS-Server_TableData |
||||
FR-Designer_Edit=FR-Designer_Edit |
||||
FR-Designer_Remove=FR-Designer_Remove |
||||
Utils-Are_you_sure_to_remove_the_selected_item=Are you sure to remove the selected item |
@ -0,0 +1,9 @@
|
||||
Plugin-Data_Set_Group=Data Set Group |
||||
Data_Set_Group=Data Set Group |
||||
Default_Group_Name=unnamed group |
||||
Template=Template |
||||
DS-TableData=DS-TableData |
||||
DS-Server_TableData=DS-Server_TableData |
||||
FR-Designer_Edit=FR-Designer_Edit |
||||
FR-Designer_Remove=FR-Designer_Remove |
||||
Utils-Are_you_sure_to_remove_the_selected_item=Are you sure to remove the selected item |
@ -0,0 +1,9 @@
|
||||
Plugin-Data_Set_Group=\u6570\u636e\u96c6\u5206\u7ec4 |
||||
Data_Set_Group=\u6570\u636e\u96c6\u5206\u7ec4 |
||||
Default_Group_Name=\u672a\u547d\u540d\u5206\u7ec4 |
||||
Template=\u6a21\u677f |
||||
DS-TableData=\u6570\u636e\u96c6 |
||||
DS-Server_TableData=\u670d\u52a1\u5668\u6570\u636e\u96c6 |
||||
FR-Designer_Edit=\u7f16\u8f91 |
||||
FR-Designer_Remove=\u5220\u9664 |
||||
Utils-Are_you_sure_to_remove_the_selected_item=\u4f60\u786e\u5b9e\u51b3\u5b9a\u5220\u9664\u9009\u4e2d\u7684\u9879 |
After Width: | Height: | Size: 215 B |
Loading…
Reference in new issue