使用产品 ideskopx10i 版本:10.2.0
Application.getActiveApplication().initialize()后使用ThreadUtilties.executeAfterDesktopVisible加载默认工作空间
工作空间加载了,但是数据源和地图不显示,实际上数据源和地图是可以获取到的,只是目录没显示出来,有时候工作空间面板还会自动释放,导致工作空间无法加载,面板一片空白
调试过了,代码层可以 获取到数据源和地图,只是资源目录不显示,感觉是个bug
//加载默认工作空间 ThreadUtilties.executeAfterDesktopVisible(() -> { try { File rfile = Paths.get(user_dir, "", "workspace.ini").toFile(); BufferedReader br = new BufferedReader(new FileReader(rfile)); String file_workspace = br.readLine(); Workspace workspace = Application.getActiveApplication().getWorkspace(); File file = new File(file_workspace); if (file.exists()) { workspace.open(new WorkspaceConnectionInfo(file.getPath())); String parentpath=file.getParent()+File.separator+"图形"; //个别打开失败的时候重新打开 if(!workspace.getDatasources().contains("自定义图层")){ System.out.println("重新自定义图层"); DatasourceConnectionInfo datasourceConnectionInfo=new DatasourceConnectionInfo(); datasourceConnectionInfo.setServer(parentpath+File.separator+"自定义图层.udb"); datasourceConnectionInfo.setEngineType(EngineType.UDB); datasourceConnectionInfo.setAlias("自定义图层"); workspace.getDatasources().open(datasourceConnectionInfo); workspace.save(); } if(!workspace.getDatasources().contains("基础数据")){ System.out.println("基础数据"); DatasourceConnectionInfo datasourceConnectionInfo=new DatasourceConnectionInfo(); datasourceConnectionInfo.setServer(parentpath+File.separator+"基础数据.udb"); datasourceConnectionInfo.setEngineType(EngineType.UDB); datasourceConnectionInfo.setAlias("基础数据"); workspace.getDatasources().open(datasourceConnectionInfo); workspace.save(); } if(!workspace.getDatasources().contains("斜坡调查数据")){ System.out.println("斜坡调查数据"); DatasourceConnectionInfo datasourceConnectionInfo=new DatasourceConnectionInfo(); datasourceConnectionInfo.setServer(parentpath+File.separator+"斜坡调查数据.udb"); datasourceConnectionInfo.setEngineType(EngineType.UDB); datasourceConnectionInfo.setAlias("斜坡调查数据"); workspace.getDatasources().open(datasourceConnectionInfo); workspace.save(); } } }catch (IOException ex){ Application.getActiveApplication().getOutput().output(ex); } //清除插件加载提示 Application.getActiveApplication().getOutput().clearOutput(); },1);
图中不显示数据源和地图,实际上模块里可以获取到数据源和地图,打开地图