提交 e83e17be 编写于 作者: S serge-rider

#7863 SubTask proxy monitor (avoid tasks spam)


Former-commit-id: d7961f78
上级 18d315c0
......@@ -29,6 +29,7 @@ import org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode;
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.runtime.DBRProgressListener;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.SubTaskProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.DBSObjectContainer;
import org.jkiss.dbeaver.runtime.properties.*;
......@@ -281,14 +282,16 @@ public class CompareObjectsExecutor {
// Compare children
int nodeCount = nodes.size();
List<DBNDatabaseNode[]> allChildren = new ArrayList<>(nodeCount);
// Use submonitor to avoid huge number of tasks
DBRProgressMonitor subMonitor = new SubTaskProgressMonitor(monitor);
for (int i = 0; i < nodeCount; i++) {
DBNDatabaseNode node = nodes.get(i);
// Cache structure if possible
if (node.getObject() instanceof DBSObjectContainer) {
((DBSObjectContainer) node.getObject()).cacheStructure(monitor, DBSObjectContainer.STRUCT_ALL);
((DBSObjectContainer) node.getObject()).cacheStructure(subMonitor, DBSObjectContainer.STRUCT_ALL);
}
try {
DBNDatabaseNode[] children = node.getChildren(monitor);
DBNDatabaseNode[] children = node.getChildren(subMonitor);
allChildren.add(children);
} catch (Exception e) {
log.warn("Error reading child nodes for compare", e);
......
......@@ -25,7 +25,7 @@ import java.util.List;
*/
public class ProxyProgressMonitor implements DBRProgressMonitor, IProgressMonitor {
private DBRProgressMonitor original;
protected DBRProgressMonitor original;
public ProxyProgressMonitor(DBRProgressMonitor original)
{
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2020 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.model.runtime;
/**
* Progress monitor default implementation
*/
public class SubTaskProgressMonitor extends ProxyProgressMonitor {
public SubTaskProgressMonitor(DBRProgressMonitor original) {
super(original);
}
@Override
public void beginTask(String name, int totalWork) {
// show as syb task
original.subTask(name);
}
@Override
public void done() {
// ignore
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册