Browse Source

REPORT-133133 & REPORT-134138 fix:数据连接异常报错场景弹窗处理

fbp/release
Levy.Xie-解安森 2 months ago
parent
commit
8d4fb7256f
  1. 76
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

76
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -13,6 +13,8 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.data.MapCompareUtils; import com.fr.design.data.MapCompareUtils;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.editlock.EditLockUtils;
import com.fr.design.fun.ConnectionProvider; import com.fr.design.fun.ConnectionProvider;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;
@ -25,18 +27,21 @@ import com.fr.general.NameObject;
import com.fr.license.database.DBTypes; import com.fr.license.database.DBTypes;
import com.fr.license.database.DataBaseTypePointManager; import com.fr.license.database.DataBaseTypePointManager;
import com.fr.license.exception.DataBaseNotSupportedException; import com.fr.license.exception.DataBaseNotSupportedException;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.LockItem;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.engine.exception.DriverUnExistException;
import com.fr.workspace.server.database.DataBaseTypeOperator; import com.fr.workspace.server.database.DataBaseTypeOperator;
import com.fr.workspace.server.entity.connection.ConnectionBean; import com.fr.workspace.server.entity.connection.ConnectionBean;
import com.fr.workspace.server.repository.connection.ConnectionRepository; import com.fr.workspace.server.repository.connection.ConnectionRepository;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.swing.SwingWorker; import javax.swing.*;
import java.awt.Window; import java.awt.Window;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -345,18 +350,23 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
private void alterConnections(List<ConnectionInfoBean> addConnections, List<String> removedConnNames, List<ConnectionInfoBean> updateConnection) throws Exception { private void alterConnections(List<ConnectionInfoBean> addConnections, List<String> removedConnNames, List<ConnectionInfoBean> updateConnection) throws Exception {
try { try {
for (ConnectionInfoBean bean : addConnections) { // 处理新增 connections
processConnections(addConnections, bean -> {
ConnectionRepository.getInstance().add(bean); ConnectionRepository.getInstance().add(bean);
} }, "add");
for (ConnectionInfoBean bean : updateConnection) {
// 处理更新 connections
processConnections(updateConnection, bean -> {
ConnectionRepository.getInstance().update(bean); ConnectionRepository.getInstance().update(bean);
} }, "update");
for (String name : removedConnNames) {
// 处理移除 connections
processConnections(removedConnNames, name -> {
ConnectionRepository.getInstance().delete(new ConnectionInfoBean(name)); ConnectionRepository.getInstance().delete(new ConnectionInfoBean(name));
} }, "delete");
// hades:远程环境时,由于时直接RPC调用远程修改,因此设计器本地配置需要失效
// 远程环境处理逻辑
if (!WorkContext.getCurrent().isLocal()) { if (!WorkContext.getCurrent().isLocal()) {
EventDispatcher.fire(RemoteConfigEvent.EDIT, "ConnectionConfig"); EventDispatcher.fire(RemoteConfigEvent.EDIT, "ConnectionConfig");
} }
@ -366,18 +376,46 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
} }
} }
private <T> void processConnections(List<T> connections, ThrowingConsumer<T> action, String actionType) throws Exception {
for (T item : connections) {
try {
action.accept(item);
} catch (Exception e) {
String errorConnectionName = (item instanceof ConnectionInfoBean)
? ((ConnectionInfoBean) item).getConnectionName()
: item.toString();
if (e instanceof DriverUnExistException) {
throw new DriverUnExistException(InterProviderFactory.getProvider().getLocText("Fine-Core_Data_Connection") + errorConnectionName
+ InterProviderFactory.getProvider().getLocText("Fine-Core_Driver_Not_Found"));
}
throw e;
}
}
}
@FunctionalInterface
interface ThrowingConsumer<T> {
void accept(T t) throws Exception;
}
public static void showDialog(Window parent) { public static void showDialog(Window parent) {
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); try {
final ConnectionManagerPane connectionManagerPane = new ConnectionManagerPane() { final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
@Override final ConnectionManagerPane connectionManagerPane = new ConnectionManagerPane() {
public void complete() { @Override
populate(connectionMap); public void complete() {
} populate(connectionMap);
}; }
final BasicDialog connectionListDialog = connectionManagerPane.showLargeWindow(parent, null); };
connectionListDialog.addDialogActionListener(new ConnectionListDialogActionAdapter(connectionManagerPane, connectionListDialog, connectionMap)); final BasicDialog connectionListDialog = connectionManagerPane.showLargeWindow(parent, null);
connectionListDialog.setVisible(true); connectionListDialog.addDialogActionListener(new ConnectionListDialogActionAdapter(connectionManagerPane, connectionListDialog, connectionMap));
connectionListDialog.setVisible(true);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Remote_Data_Error"),
Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE);
EditLockUtils.unlock(LockItem.CONNECTION);
}
} }
@Override @Override

Loading…
Cancel
Save