提交 4051370f 编写于 作者: J jurgen

Version change

Former-commit-id: bbf82209
上级 b316e260
......@@ -30,12 +30,12 @@ import java.util.*;
*/
public class DriverDependencies implements DBPDriverDependencies
{
final List<? extends DBPDriverLibrary> rootLibraries;
final List<DBPDriverLibrary> rootLibraries;
final List<DependencyNode> rootNodes = new ArrayList<>();
final List<DependencyNode> libraryList = new ArrayList<>();
public DriverDependencies(List<? extends DBPDriverLibrary> rootLibraries) {
this.rootLibraries = rootLibraries;
this.rootLibraries = new ArrayList<>(rootLibraries);
}
@Override
......@@ -69,11 +69,12 @@ public class DriverDependencies implements DBPDriverDependencies
sb.append(lib).append("\n");
}
System.out.println(sb.toString());
*/
System.out.println("---------------------------");
for (DependencyNode node : rootNodes) {
dumpNode(node, 0);
}
*/
}
} catch (IOException e) {
throw new DBException("IO error while resolving dependencies", e);
......@@ -126,4 +127,13 @@ public class DriverDependencies implements DBPDriverDependencies
return rootNodes;
}
public void changeLibrary(DBPDriverLibrary oldLibrary, DBPDriverLibrary newLibrary) {
int index = rootLibraries.indexOf(oldLibrary);
if (index == -1) {
rootLibraries.add(newLibrary);
} else {
rootLibraries.add(index, newLibrary);
rootLibraries.remove(oldLibrary);
}
}
}
......@@ -44,7 +44,7 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
protected final DriverDescriptor driver;
protected final FileType type;
protected final OSDescriptor system;
protected String path;
protected final String path;
protected boolean custom;
protected boolean disabled;
......@@ -111,9 +111,10 @@ public abstract class DriverLibraryAbstract implements DBPDriverLibrary
return Collections.emptyList();
}
@NotNull
@Override
public void setVersion(DBRProgressMonitor monitor, @NotNull String version) throws IOException {
throw new IOException("Vaersions are not supported");
public DBPDriverLibrary createVersion(DBRProgressMonitor monitor, @NotNull String version) throws IOException {
throw new IOException("Versions are not supported");
}
@NotNull
......
......@@ -44,7 +44,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
public static final String PATH_PREFIX = "maven:/";
private MavenArtifactReference reference;
private final MavenArtifactReference reference;
protected MavenArtifactVersion localVersion;
public DriverLibraryMavenArtifact(DriverDescriptor driver, FileType type, String path) {
......@@ -85,8 +85,9 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
return Collections.emptyList();
}
@NotNull
@Override
public void setVersion(DBRProgressMonitor monitor, @NotNull String version) throws IOException {
public DBPDriverLibrary createVersion(DBRProgressMonitor monitor, @NotNull String version) throws IOException {
MavenArtifactReference newReference = new MavenArtifactReference(
this.reference.getGroupId(),
this.reference.getArtifactId(),
......@@ -96,9 +97,7 @@ public class DriverLibraryMavenArtifact extends DriverLibraryAbstract
if (newVersion == null) {
throw new IOException("Can't resolve artifact version " + newReference);
}
this.reference = newReference;
this.localVersion = newVersion;
this.path = PATH_PREFIX + this.localVersion.toString();
return new DriverLibraryMavenArtifact(getDriver(), getType(), PATH_PREFIX + newVersion.toString());
}
@Override
......
......@@ -203,7 +203,11 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
library.setVersion(new DefaultProgressMonitor(monitor), version);
DBPDriverLibrary newVersion = library.createVersion(new DefaultProgressMonitor(monitor), version);
DriverDescriptor driver = getWizard().getDriver();
driver.removeDriverLibrary(library);
driver.addDriverLibrary(newVersion);
getWizard().getDependencies().changeLibrary(library, newVersion);
} catch (IOException e) {
throw new InvocationTargetException(e);
}
......
......@@ -23,6 +23,7 @@ import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.connection.DBPDriverLibrary;
import org.jkiss.dbeaver.registry.driver.DriverDependencies;
import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.ui.UIUtils;
......
......@@ -100,7 +100,8 @@ public interface DBPDriverLibrary
@NotNull
Collection<String> getAvailableVersions(DBRProgressMonitor monitor) throws IOException;
void setVersion(DBRProgressMonitor monitor, @NotNull String version)
@NotNull
DBPDriverLibrary createVersion(DBRProgressMonitor monitor, @NotNull String version)
throws IOException;
void resetVersion();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册