Browse Source

Merge pull request #534 in BA/design from ~ZACK/design:dev to dev

* commit 'a848d5736eacea80e47636efb4d173f90254fe33':
  无JIRA任务 PMD
  无JIRA任务 组件复用的远程安装,现在是把reu文件拆分成两个xml分别传给服务端,直接给正文塞reu文件的二进制会因为tostring方法造成数据丢失
  REPORT-841 代码质量
  d
  d
  REPORT-841 表单数据集重命名报表块内容联动
master
superman 8 years ago
parent
commit
a4e24e7887
  1. 6
      designer_base/src/com/fr/design/data/BasicTableDataTreePane.java
  2. 9
      designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java
  3. 60
      designer_base/src/com/fr/env/RemoteEnv.java
  4. 94
      designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

6
designer_base/src/com/fr/design/data/BasicTableDataTreePane.java

@ -428,11 +428,11 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
}
/**
* 合并数据集
* 合并数据集并返回自动更改数据集名字的新老名字键值对
* @param srcName 数据集来源(比如报表块就是报表块的名称)
* @param tableDataSource 数据集
*/
public void addTableData(String srcName, TableDataSource tableDataSource) {
public Map<String, String> addTableData(String srcName, TableDataSource tableDataSource) {
return new HashMap<>(0);
}
}

9
designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java

@ -38,6 +38,7 @@ import java.awt.dnd.DnDConstants;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@ -275,13 +276,15 @@ public class TableDataTreePane extends BasicTableDataTreePane {
* @param srcName 数据集来源(比如报表块就是报表块的名称)
* @param tableDataSource 数据集
*/
public void addTableData(String srcName, TableDataSource tableDataSource) {
public Map<String, String> addTableData(String srcName, TableDataSource tableDataSource) {
Map<String, String> tdNameMap = new HashMap<>();
allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook());
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
TableDataSource tds = tc.getBook();
Iterator tdIterator = tableDataSource.getTableDataNameIterator();
while (tdIterator.hasNext()) {
String tdName = (String) tdIterator.next();
String oldName = tdName;
TableData td = tableDataSource.getTableData(tdName);
if (tds.getTableData(tdName) != null || isDsNameRepeaded(tdName)) {//如果有同名的就拼上来源名称
tdName = srcName + tdName;
@ -292,8 +295,12 @@ public class TableDataTreePane extends BasicTableDataTreePane {
tdName += i;
}
tds.putTableData(tdName, td);
if (!ComparatorUtils.equals(oldName, tdName)) {
tdNameMap.put(oldName, tdName);
}
}
tc.parameterChanged();
dataTree.refresh();
return Collections.unmodifiableMap(tdNameMap);
}
}

60
designer_base/src/com/fr/env/RemoteEnv.java vendored

@ -2114,6 +2114,7 @@ public class RemoteEnv implements Env {
StableUtils.mkdirs(target);
File cacheDir = null;
File zip = null;
OutputStream out = null;
try {
HashMap<String, String> para = new HashMap<String, String>();
para.put("op", "fr_remote_design");
@ -2122,16 +2123,15 @@ public class RemoteEnv implements Env {
para.put("currentUsername", this.getUser());
HttpClient client = createHttpMethod(para);
InputStream input = client.getResponseStream();
InputStream input = client.getResponseStream();//拿到服务端传过来的整个共享文件夹的压缩文件的文件流
zip = new File(StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath()), "share.zip");
cacheDir = new File(StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath()), ShareConstants.DIR_SHARE_CACHE);
StableUtils.deleteFile(cacheDir);
StableUtils.mkdirs(cacheDir);
StableUtils.makesureFileExist(zip);
FileOutputStream out = new FileOutputStream(zip);
IOUtils.copyBinaryTo(input, out);
out.flush();
out.close();
out = new FileOutputStream(zip);
IOUtils.copyBinaryTo(input, out);//放到本地缓存目录下
IOUtils.unzip(zip, cacheDir.getAbsolutePath(), EncodeConstants.ENCODING_GBK);//先解压到临时目录
if (cacheDir.exists() && cacheDir.isDirectory()) {
return cacheDir.listFiles(new FilenameFilter() {
@ -2144,6 +2144,10 @@ public class RemoteEnv implements Env {
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
} finally {
if (out != null) {
out.flush();
out.close();
}
StableUtils.deleteFile(zip);
}
return new File[0];
@ -2151,25 +2155,33 @@ public class RemoteEnv implements Env {
@Override
public boolean installREUFile(File reuFile) {
// if (reuFile == null) {
// return false;
// }
// try {
// HashMap<String, String> para = new HashMap<String, String>();
// para.put("op", "fr_remote_design");
// para.put("cmd", "design_install_reufile");
// para.put("current_uid", this.createUserID());
// para.put("currentUsername", this.getUser());
// para.put("reuFileName", reuFile.getName());
//
// HttpClient client = createHttpMethod(para);
// client.setContent(IOUtils.inputStream2Bytes(new FileInputStream(reuFile)));
// InputStream input = execute4InputStream(client);
// return ComparatorUtils.equals(stream2String(input), "true");
// } catch (Exception e) {
// return false;
// }
return false;
if (reuFile == null) {
return false;
}
File tempFile = new File(CacheManager.getProviderInstance().getCacheDirectory(), "temp_remote");
IOUtils.unzip(reuFile, tempFile.getAbsolutePath());
String shareXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_MODULE);
String helpXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_HELP);
try {
HashMap<String, String> para = new HashMap<String, String>();
para.put("op", "fr_remote_design");
para.put("cmd", "design_install_reufile");
para.put("current_uid", this.createUserID());
para.put("currentUsername", this.getUser());
para.put("reuFileName", reuFile.getName());
HttpClient client = createHttpMethod(para);
client.setContent(IOUtils.inputStream2Bytes(new FileInputStream(new File(shareXMLName))));
InputStream input = execute4InputStream(client);
client.release();
para.put("isComplete", "true");
HttpClient client1 = createHttpMethod(para);
client1.setContent(IOUtils.inputStream2Bytes(new FileInputStream(new File(helpXMLName))));
InputStream input1 = execute4InputStream(client1);
return ComparatorUtils.equals(stream2String(input), "true") && ComparatorUtils.equals(stream2String(input1), "true");
} catch (Exception e) {
return false;
}
}
@Override

94
designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -26,6 +26,7 @@ import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.util.Map;
/**
* 添加模式下鼠标事件处理器
@ -55,15 +56,11 @@ public class FormCreatorDropTarget extends DropTarget {
private void adding(int x, int y) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(x, y);
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
//cardTagLayout里用到
container.stopAddingState(designer);
boolean success = false;
if (container != null) {
// 如果是容器,则调用其acceptComponent接受组件
AddingModel model = designer.getAddingModel();
@ -76,7 +73,6 @@ public class FormCreatorDropTarget extends DropTarget {
}
cancelPromptWidgetForbidEnter();
}
if (success) {
// 如果添加成功,则触发相应事件
XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent();
@ -88,7 +84,9 @@ public class FormCreatorDropTarget extends DropTarget {
SharableElementCaseEditor sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId);
ElCaseBindInfo bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId);
if (sharableEditor != null && bindInfo != null) {
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(),sharableEditor.getTableDataSource());
Map<String, String> tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource());
//合并数据集之后,可能会有数据集名称变化,做一下联动
sharableEditor.batchRenameTdName(tdNameMap);
}
}
Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();
@ -98,7 +96,6 @@ public class FormCreatorDropTarget extends DropTarget {
} else {
Toolkit.getDefaultToolkit().beep();
}
// 取消提示
designer.setPainter(null);
// 切换添加状态到普通状态
@ -129,47 +126,9 @@ public class FormCreatorDropTarget extends DropTarget {
//提示组件是否可以拖入
promptUser(x, y, container);
if (container != null) {
HoverPainter painter = null;
if (container != current || designer.getPainter() == null) {
// 如果焦点容器不是当前容器
if (current != null) {
// 取消前一个焦点容器的提示渲染器
designer.setPainter(null);
}
//获取painter的时候要考虑布局之间嵌套的问题
XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.getParent() != null
&& ((XLayoutContainer) xLayoutContainer.getParent()).acceptType(XWAbsoluteLayout.class)) {
if (!xLayoutContainer.isEditable()) {
xLayoutContainer = (XLayoutContainer) xLayoutContainer.getParent();
}
}
painter = AdapterBus.getContainerPainter(designer,
xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class) ? xLayoutContainer : container);
// 为界面设计器设置提示渲染提示器
designer.setPainter(painter);
// 将当前容器更新为新的容器
current = container;
} else {
// 获取当前设计界面的提示渲染器
Painter p = designer.getPainter();
if (p instanceof HoverPainter) {
painter = (HoverPainter) p;
}
}
dealWithContainer(x, y, container);
if (painter != null) {
// 为提示渲染器设置焦点位置、区域等渲染参数
Rectangle rect = ComponentUtils.getRelativeBounds(container);
rect.x -= designer.getArea().getHorizontalValue();
rect.y -= designer.getArea().getVerticalValue();
painter.setRenderingBounds(rect);
painter.setHotspot(new Point(x, y));
painter.setCreator(addingModel.getXCreator());
}
} else {
// 如果鼠标不在任何组件上,则取消提示器
designer.setPainter(null);
@ -178,6 +137,49 @@ public class FormCreatorDropTarget extends DropTarget {
designer.repaint();
}
private void dealWithContainer(int x, int y, XLayoutContainer container) {
HoverPainter painter = null;
if (container != current || designer.getPainter() == null) {
// 如果焦点容器不是当前容器
if (current != null) {
// 取消前一个焦点容器的提示渲染器
designer.setPainter(null);
}
//获取painter的时候要考虑布局之间嵌套的问题
XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.getParent() != null
&& ((XLayoutContainer) xLayoutContainer.getParent()).acceptType(XWAbsoluteLayout.class)) {
if (!xLayoutContainer.isEditable()) {
xLayoutContainer = (XLayoutContainer) xLayoutContainer.getParent();
}
}
painter = AdapterBus.getContainerPainter(designer,
xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class) ? xLayoutContainer : container);
// 为界面设计器设置提示渲染提示器
designer.setPainter(painter);
// 将当前容器更新为新的容器
current = container;
} else {
// 获取当前设计界面的提示渲染器
Painter p = designer.getPainter();
if (p instanceof HoverPainter) {
painter = (HoverPainter) p;
}
}
if (painter != null) {
// 为提示渲染器设置焦点位置、区域等渲染参数
Rectangle rect = ComponentUtils.getRelativeBounds(container);
rect.x -= designer.getArea().getHorizontalValue();
rect.y -= designer.getArea().getVerticalValue();
painter.setRenderingBounds(rect);
painter.setHotspot(new Point(x, y));
painter.setCreator(addingModel.getXCreator());
}
}
private void promptUser(int x, int y, XLayoutContainer container) {
if (!addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class)) {
promptButton.setText(Inter.getLocText("FR-Designer_Forbid_Drag_into_Para_Pane"));

Loading…
Cancel
Save