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

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

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

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

@ -14,7 +14,7 @@ import java.awt.*;
import java.io.File;
import java.util.HashMap;
public class ConnectionManagerPane extends LoadingBasicPane {
public class ConnectionManagerPane extends LoadingBasicPane implements ConnectionShowPane {
private UITextField connectionTextField;
private ConnectionListPane connectionListPane;
@ -30,10 +30,10 @@ public class ConnectionManagerPane extends LoadingBasicPane {
this.connectionTextField = new UITextField();
connectionPathPane.add(connectionTextField, BorderLayout.CENTER);
this.connectionTextField.setEditable(false);
connectionListPane = new ConnectionListPane(){
protected void rename(String oldName,String newName) {
super.rename(oldName,newName);
renameConnection(oldName,newName);
connectionListPane = new ConnectionListPane() {
protected void rename(String oldName, String newName) {
super.rename(oldName, newName);
renameConnection(oldName, newName);
}
};
container.add(connectionListPane, BorderLayout.CENTER);
@ -69,6 +69,7 @@ public class ConnectionManagerPane extends LoadingBasicPane {
/**
* 名字是否允许
*
* @return 允许返回true
*/
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);
}

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

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

Loading…
Cancel
Save