Browse Source

Merge pull request #829 in BA/design from ~YAOH.WU/design_0407:release to release

* commit '049e74143bdceb0424daacca62891c528922d085':
  组件复用边界复制
  REPORT-2273 远程设计数据库连接成功,预览报错,datasourcexml保存失败问题修复
master
superman 8 years ago
parent
commit
2babd72f99
  1. 27
      designer_base/src/com/fr/design/actions/server/ConnectionListAction.java
  2. 40
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  3. 2
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java
  4. 3
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java
  5. 15
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionShowPane.java
  6. 27
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

27
designer_base/src/com/fr/design/actions/server/ConnectionListAction.java

@ -8,6 +8,7 @@ import com.fr.data.impl.Connection;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.connect.ConnectionManagerPane; import com.fr.design.data.datapane.connect.ConnectionManagerPane;
import com.fr.design.data.datapane.connect.ConnectionShowPane;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -25,7 +26,6 @@ import java.util.HashMap;
* DatasourceList Action * DatasourceList Action
*/ */
public class ConnectionListAction extends UpdateAction { public class ConnectionListAction extends UpdateAction {
private static final int BYTENUM = 1444;
public ConnectionListAction() { public ConnectionListAction() {
this.setMenuKeySet(DEFINE_DATA_CONNECTION); this.setMenuKeySet(DEFINE_DATA_CONNECTION);
@ -92,7 +92,10 @@ public class ConnectionListAction extends UpdateAction {
} }
private void writeFile(DatasourceManagerProvider datasourceManager) { /**
* @param datasourceManager
*/
public static void writeFile(DatasourceManagerProvider datasourceManager) {
Env currentEnv = FRContext.getCurrentEnv(); Env currentEnv = FRContext.getCurrentEnv();
try { try {
boolean isSuccess = currentEnv.writeResource(datasourceManager); boolean isSuccess = currentEnv.writeResource(datasourceManager);
@ -106,15 +109,17 @@ public class ConnectionListAction extends UpdateAction {
} }
/** /**
* 是否正常更新datasourceManager * 更新datasourceManager
* *
* @param datasourceManager * @param datasourceManager datasource管理对象
* @param databaseManagerPane * @param backupManager datasource管理对象备份
* @return * @param connectionShowPane datasource面板
* @param databaseListDialog datasource管理对话框
* @return boolean 是否更新成功
*/ */
private boolean doWithDatasourceManager(DatasourceManagerProvider datasourceManager, DatasourceManager backupManager, public static boolean doWithDatasourceManager(DatasourceManagerProvider datasourceManager, DatasourceManager
ConnectionManagerPane databaseManagerPane, BasicDialog databaseListDialog) { backupManager, ConnectionShowPane connectionShowPane, BasicDialog databaseListDialog) {
databaseManagerPane.update(datasourceManager); connectionShowPane.update(datasourceManager);
HashMap<String, Connection> modifyDetails = datasourceManager.getConnectionModifyDetails(); HashMap<String, Connection> modifyDetails = datasourceManager.getConnectionModifyDetails();
modifyDetails.clear(); modifyDetails.clear();
Env currentEnv = FRContext.getCurrentEnv(); Env currentEnv = FRContext.getCurrentEnv();
@ -139,7 +144,7 @@ public class ConnectionListAction extends UpdateAction {
localModifiedTable.removeConfilct(); localModifiedTable.removeConfilct();
modifyDetails.clear(); modifyDetails.clear();
//更新面板 //更新面板
databaseManagerPane.populate(datasourceManager); connectionShowPane.populate(datasourceManager);
} else { } else {
//更新失败,继续停留页面 //更新失败,继续停留页面
isFailed = true; isFailed = true;
@ -152,7 +157,7 @@ public class ConnectionListAction extends UpdateAction {
int index = datasourceManager.isConnectionMapContainsRename(); int index = datasourceManager.isConnectionMapContainsRename();
if (index != -1) { if (index != -1) {
isFailed = true; isFailed = true;
databaseManagerPane.setSelectedIndex(index); connectionShowPane.setSelectedIndex(index);
} }
databaseListDialog.setDoOKSucceed(!isFailed); databaseListDialog.setDoOKSucceed(!isFailed);
//如果修改成功,则去远程端增量修改修改表 //如果修改成功,则去远程端增量修改修改表

40
designer_base/src/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java

@ -1,11 +1,11 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.data.impl.AbstractDatabaseConnection; import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection; import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.server.ConnectionListAction;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.file.DatasourceManager; import com.fr.file.DatasourceManager;
@ -17,6 +17,7 @@ import javax.swing.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
@ -31,7 +32,7 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Class<? extends Connection> cls; // 所取的Connection都是cls及其子类 private Class<? extends Connection> cls; // 所取的Connection都是cls及其子类
private java.util.List<String> nameList = new ArrayList<String>(); private List<String> nameList = new ArrayList<String>();
public ConnectionComboBoxPanel(Class<? extends Connection> cls) { public ConnectionComboBoxPanel(Class<? extends Connection> cls) {
super(); super();
@ -53,11 +54,11 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
/* /*
* 刷新ComboBox.items * 刷新ComboBox.items
*/ */
protected java.util.Iterator<String> items() { protected Iterator<String> items() {
nameList = new ArrayList<String>(); nameList = new ArrayList<String>();
DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance(); DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
java.util.Iterator<String> nameIt = mgr.getConnectionNameIterator(); Iterator<String> nameIt = mgr.getConnectionNameIterator();
while (nameIt.hasNext()) { while (nameIt.hasNext()) {
String conName = nameIt.next(); String conName = nameIt.next();
Connection connection = mgr.getConnection(conName); Connection connection = mgr.getConnection(conName);
@ -71,7 +72,6 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class}); connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class});
} }
public int getConnectionSize() { public int getConnectionSize() {
return nameList.size(); return nameList.size();
} }
@ -86,25 +86,37 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
protected void editItems() { protected void editItems() {
final ConnectionListPane connectionListPane = new ConnectionListPane(); final ConnectionListPane connectionListPane = new ConnectionListPane();
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance(); final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance();
final DatasourceManager backupManager = datasourceManager.getBackUpManager();
connectionListPane.populate(datasourceManager); connectionListPane.populate(datasourceManager);
BasicDialog connectionListDialog = connectionListPane.showLargeWindow( final BasicDialog connectionListDialog = connectionListPane.showLargeWindow(
SwingUtilities.getWindowAncestor(ConnectionComboBoxPanel.this), new DialogActionAdapter() { SwingUtilities.getWindowAncestor(ConnectionComboBoxPanel.this), null);
connectionListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() { public void doOk() {
connectionListPane.update(datasourceManager); if (!connectionListPane.isNamePermitted()) {
connectionListDialog.setDoOKSucceed(false);
return;
}
if (!ConnectionListAction.doWithDatasourceManager(datasourceManager, backupManager, connectionListPane,
connectionListDialog)) {
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
return;
}
// marks:保存数据 // marks:保存数据
Env currentEnv = FRContext.getCurrentEnv(); ConnectionListAction.writeFile(datasourceManager);
try {
currentEnv.writeResource(datasourceManager);
} catch (Exception ex) {
FRContext.getLogger().error(ex.getMessage(), ex);
} }
public void doCancel() {
datasourceManager.synchronizedWithServer();
} }
}); });
connectionListDialog.setVisible(true); connectionListDialog.setVisible(true);
refreshItems(); refreshItems();
} }
public void populate(com.fr.data.impl.Connection connection) { /**
* @param connection 数据库链接
*/
public void populate(Connection connection) {
editButton.setEnabled(FRContext.getCurrentEnv().isRoot()); editButton.setEnabled(FRContext.getCurrentEnv().isRoot());
if (connection instanceof NameDatabaseConnection) { if (connection instanceof NameDatabaseConnection) {
this.setSelectedItem(((NameDatabaseConnection) connection).getName()); this.setSelectedItem(((NameDatabaseConnection) connection).getName());

2
designer_base/src/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -23,7 +23,7 @@ import java.util.*;
/** /**
* Connection List Pane. * Connection List Pane.
*/ */
public class ConnectionListPane extends JListControlPane { public class ConnectionListPane extends JListControlPane implements ConnectionShowPane {
public static final String TITLE_NAME = Inter.getLocText("Server-Define_Data_Connection"); public static final String TITLE_NAME = Inter.getLocText("Server-Define_Data_Connection");
private boolean isNamePermitted = true; private boolean isNamePermitted = true;
private HashMap<String, String> renameMap = new HashMap<String, String>(); private HashMap<String, String> renameMap = new HashMap<String, String>();

3
designer_base/src/com/fr/design/data/datapane/connect/ConnectionManagerPane.java

@ -14,7 +14,7 @@ import java.awt.*;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
public class ConnectionManagerPane extends LoadingBasicPane { public class ConnectionManagerPane extends LoadingBasicPane implements ConnectionShowPane {
private UITextField connectionTextField; private UITextField connectionTextField;
private ConnectionListPane connectionListPane; private ConnectionListPane connectionListPane;
@ -69,6 +69,7 @@ public class ConnectionManagerPane extends LoadingBasicPane {
/** /**
* 名字是否允许 * 名字是否允许
*
* @return 允许返回true * @return 允许返回true
*/ */
public boolean isNamePermitted() { public boolean isNamePermitted() {

15
designer_base/src/com/fr/design/data/datapane/connect/ConnectionShowPane.java

@ -0,0 +1,15 @@
package com.fr.design.data.datapane.connect;
import com.fr.file.DatasourceManagerProvider;
/**
* Created by yaoh.wu on 2017/4/22.
* 数据链接显示面板
*/
public interface ConnectionShowPane {
void update(DatasourceManagerProvider datasourceManager);
void populate(DatasourceManagerProvider datasourceManager);
void setSelectedIndex(int index);
}

27
designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

@ -132,29 +132,18 @@ public class FormSelectionUtils {
XLayoutContainer container = layoutAdapter.getContainer(); XLayoutContainer container = layoutAdapter.getContainer();
boolean xOut = x < 0 || x + copiedCreator.getWidth() / 2 + xoffset > container.getWidth(); boolean xOut = x < 0 || x + copiedCreator.getWidth() / 2 + xoffset > container.getWidth();
boolean yOut = y < 0 || y + copiedCreator.getHeight() / 2 + yoffset > container.getHeight(); boolean yOut = y < 0 || y + copiedCreator.getHeight() / 2 + yoffset > container.getHeight();
/*
* 组件原始位置位于布局的右下角 y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y;
* 和布局右下边界线紧挨 boolean isEdge = (x - DELAY_X_Y == container.getWidth() - copiedCreator.getWidth() / 2 - xoffset);
* 粘贴时组件在原始位置向左错开20像素 if (xOut) {
* x,y同时越界 if (isEdge) {
*/
if (xOut && yOut) {
//向左偏移 //向左偏移
x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset; x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset;
}
//紧贴下边界 //紧贴下边界
y = container.getHeight() - copiedCreator.getHeight() / 2 - yoffset; else {
return new Point(x, y); x = container.getWidth() - copiedCreator.getWidth() / 2 - xoffset;
} }
/*
* 组件原始位置与布局边界距离小于20像素下边界&右边界同时小于或者任意一个边界小于
* 则粘贴时距离小于20像素一侧直接贴近布局边界
* 距离大于20像素的一侧正常错开
* x,y中只有一个越界
*/
if ((xOut || yOut)) {
x = xOut ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset : x;
y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y;
return new Point(x, y);
} }
} }
return new Point(x, y); return new Point(x, y);

Loading…
Cancel
Save