提交 04ac5407 编写于 作者: J jurgen

Data transfer wizard fix - use lazy target node resolution

上级 14c740ad
......@@ -64,6 +64,8 @@ public class DatabaseConsumerPageMapping extends ActiveWizardPage<DataTransferWi
public static final String TARGET_NAME_BROWSE = "[browse]";
private TreeViewer mappingViewer;
private Label containerIcon;
private Text containerName;
private static abstract class MappingLabelProvider extends CellLabelProvider {
@Override
......@@ -99,14 +101,12 @@ public class DatabaseConsumerPageMapping extends ActiveWizardPage<DataTransferWi
containerPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createControlLabel(containerPanel, "Target container");
DBNDatabaseNode containerNode = settings.getContainerNode();
final Label containerIcon = new Label(containerPanel, SWT.NONE);
containerIcon = new Label(containerPanel, SWT.NONE);
containerIcon.setImage(DBeaverIcons.getImage(DBIcon.TYPE_UNKNOWN));
if (containerNode != null) containerIcon.setImage(DBeaverIcons.getImage(containerNode.getNodeIconDefault()));
final Text containerName = new Text(containerPanel, SWT.BORDER | SWT.READ_ONLY);
containerName = new Text(containerPanel, SWT.BORDER | SWT.READ_ONLY);
containerName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (containerNode != null) containerName.setText(settings.getContainerFullName());
containerName.setText("");
Button browseButton = new Button(containerPanel, SWT.PUSH);
browseButton.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
......@@ -595,9 +595,15 @@ public class DatabaseConsumerPageMapping extends ActiveWizardPage<DataTransferWi
@Override
public void activatePage()
{
if (mappingViewer.getInput() == null) {
final DatabaseConsumerSettings settings = getWizard().getPageSettings(this, DatabaseConsumerSettings.class);
final DatabaseConsumerSettings settings = getWizard().getPageSettings(this, DatabaseConsumerSettings.class);
settings.loadNode();
DBNDatabaseNode containerNode = settings.getContainerNode();
if (containerNode != null) {
containerIcon.setImage(DBeaverIcons.getImage(containerNode.getNodeIconDefault()));
containerName.setText(containerNode.getNodeFullName());
}
if (mappingViewer.getInput() == null) {
Map<DBSDataContainer,DatabaseMappingContainer> dataMappings = settings.getDataMappings();
for (DataTransferPipe pipe : getWizard().getSettings().getDataPipes()) {
if (pipe.getProducer() == null) {
......
......@@ -18,6 +18,7 @@
package org.jkiss.dbeaver.tools.transfer.database;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.core.Log;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.operation.IRunnableContext;
......@@ -49,6 +50,7 @@ public class DatabaseConsumerSettings implements IDataTransferSettings {
static final Log log = Log.getLog(DatabaseConsumerSettings.class);
private String containerNodePath;
private DBNDatabaseNode containerNode;
private Map<DBSDataContainer, DatabaseMappingContainer> dataMappings = new LinkedHashMap<DBSDataContainer, DatabaseMappingContainer>();
private boolean openNewConnections = true;
......@@ -162,31 +164,7 @@ public class DatabaseConsumerSettings implements IDataTransferSettings {
@Override
public void loadSettings(IRunnableContext runnableContext, IDialogSettings dialogSettings)
{
final String containerPath = dialogSettings.get("container");
if (!CommonUtils.isEmpty(containerPath)) {
try {
RuntimeUtils.run(runnableContext, true, true, new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
try {
DBNNode node = DBeaverCore.getInstance().getNavigatorModel().getNodeByPath(
monitor,
containerPath);
if (node instanceof DBNDatabaseNode) {
containerNode = (DBNDatabaseNode) node;
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
log.error("Error getting container node", e.getTargetException());
} catch (InterruptedException e) {
// skip
}
}
containerNodePath = dialogSettings.get("container");
if (dialogSettings.get("openNewConnections") != null) {
openNewConnections = dialogSettings.getBoolean("openNewConnections");
}
......@@ -223,4 +201,30 @@ public class DatabaseConsumerSettings implements IDataTransferSettings {
DBUtils.getObjectFullName(container) + " [" + container.getDataSource().getContainer().getName() + "]";
}
public void loadNode() {
if (containerNode == null && !CommonUtils.isEmpty(containerNodePath)) {
if (!CommonUtils.isEmpty(containerNodePath)) {
try {
DBeaverUI.runInProgressDialog(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
try {
DBNNode node = DBeaverCore.getInstance().getNavigatorModel().getNodeByPath(
monitor,
containerNodePath);
if (node instanceof DBNDatabaseNode) {
containerNode = (DBNDatabaseNode) node;
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
log.error("Error getting container node", e.getTargetException());
}
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册