|
50 | 50 | import java.util.Locale; |
51 | 51 | import java.util.Map; |
52 | 52 | import java.util.Map.Entry; |
53 | | -import java.util.Objects; |
54 | 53 | import java.util.Optional; |
55 | 54 | import java.util.Set; |
56 | 55 | import java.util.concurrent.CompletableFuture; |
|
71 | 70 | import org.eclipse.lsp4j.CompletionItem; |
72 | 71 | import org.eclipse.lsp4j.DidChangeConfigurationParams; |
73 | 72 | import org.eclipse.lsp4j.DidChangeWatchedFilesParams; |
| 73 | +import org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams; |
74 | 74 | import org.eclipse.lsp4j.ExecuteCommandParams; |
75 | 75 | import org.eclipse.lsp4j.Location; |
76 | 76 | import org.eclipse.lsp4j.Position; |
77 | 77 | import org.eclipse.lsp4j.Range; |
78 | 78 | import org.eclipse.lsp4j.ShowDocumentParams; |
79 | 79 | import org.eclipse.lsp4j.SymbolInformation; |
| 80 | +import org.eclipse.lsp4j.WorkspaceFolder; |
80 | 81 | import org.eclipse.lsp4j.WorkspaceSymbol; |
81 | 82 | import org.eclipse.lsp4j.WorkspaceSymbolLocation; |
82 | 83 | import org.eclipse.lsp4j.WorkspaceSymbolParams; |
|
129 | 130 | import org.netbeans.spi.project.ui.ProjectProblemsProvider; |
130 | 131 | import org.openide.DialogDisplayer; |
131 | 132 | import org.openide.NotifyDescriptor; |
| 133 | +import org.openide.awt.StatusDisplayer; |
132 | 134 | import org.openide.filesystems.FileObject; |
133 | 135 | import org.openide.filesystems.URLMapper; |
134 | 136 | import org.openide.util.Exceptions; |
135 | 137 | import org.openide.util.Lookup; |
| 138 | +import org.openide.util.NbBundle; |
136 | 139 | import org.openide.util.NbPreferences; |
137 | 140 | import org.openide.util.Pair; |
138 | 141 | import org.openide.util.RequestProcessor; |
@@ -1170,6 +1173,54 @@ void updateJavaImportPreferences(FileObject fo, JsonObject configuration) { |
1170 | 1173 | } |
1171 | 1174 | } |
1172 | 1175 |
|
| 1176 | + @NbBundle.Messages({ |
| 1177 | + "# {0} - project name", |
| 1178 | + "MSG_ProjectFolderInitializationComplete=Completed initialization of project {0}", |
| 1179 | + "# {0} - some project name", |
| 1180 | + "# {1} - number of other projects loaded", |
| 1181 | + "MSG_ProjectFolderInitializationComplete2=Completed initialization of {0} and {1} other projectss" |
| 1182 | + }) |
| 1183 | + @Override |
| 1184 | + public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) { |
| 1185 | + List<FileObject> refreshProjectFolders = new ArrayList<>(); |
| 1186 | + for (WorkspaceFolder wkspFolder : params.getEvent().getAdded()) { |
| 1187 | + String uri = wkspFolder.getUri(); |
| 1188 | + try { |
| 1189 | + FileObject f = Utils.fromUri(uri); |
| 1190 | + if (f != null) { |
| 1191 | + refreshProjectFolders.add(f); |
| 1192 | + } |
| 1193 | + } catch (MalformedURLException ex) { |
| 1194 | + // expected, perhaps some client-specific URL scheme ? |
| 1195 | + LOG.fine("Workspace folder URI could not be converted into fileobject: {0}"); |
| 1196 | + } |
| 1197 | + } |
| 1198 | + if (!refreshProjectFolders.isEmpty()) { |
| 1199 | + server.asyncOpenSelectedProjects(refreshProjectFolders, true).thenAccept((projects) -> { |
| 1200 | + // report initialization of a project / projects |
| 1201 | + String msg; |
| 1202 | + if (projects.length == 0) { |
| 1203 | + // this should happen immediately |
| 1204 | + return; |
| 1205 | + } |
| 1206 | + ProjectInformation pi = ProjectUtils.getInformation(projects[0]); |
| 1207 | + String n = pi.getDisplayName(); |
| 1208 | + if (n == null) { |
| 1209 | + n = pi.getName(); |
| 1210 | + } |
| 1211 | + if (n == null) { |
| 1212 | + n = projects[0].getProjectDirectory().getName(); |
| 1213 | + } |
| 1214 | + if (projects.length == 1) { |
| 1215 | + msg = Bundle.MSG_ProjectFolderInitializationComplete(n); |
| 1216 | + } else { |
| 1217 | + msg = Bundle.MSG_ProjectFolderInitializationComplete2(n, projects.length); |
| 1218 | + } |
| 1219 | + StatusDisplayer.getDefault().setStatusText(msg, StatusDisplayer.IMPORTANCE_ANNOTATION); |
| 1220 | + }); |
| 1221 | + } |
| 1222 | + } |
| 1223 | + |
1173 | 1224 | @Override |
1174 | 1225 | public void didChangeWatchedFiles(DidChangeWatchedFilesParams arg0) { |
1175 | 1226 | //TODO: not watching files for now |
|
0 commit comments