|
32 | 32 | import com.headwire.aem.tooling.intellij.util.ExecutionUtil; |
33 | 33 | import com.intellij.openapi.actionSystem.CommonDataKeys; |
34 | 34 | import com.intellij.openapi.actionSystem.DataContext; |
| 35 | +import com.intellij.openapi.application.Application; |
35 | 36 | import com.intellij.openapi.application.ApplicationManager; |
36 | 37 | import com.intellij.openapi.application.ModalityState; |
37 | 38 | import com.intellij.openapi.project.Project; |
@@ -117,36 +118,40 @@ private void doImport(final Project project, final VirtualFile file) { |
117 | 118 | final ServerConfiguration.Module currentModule = currentModuleLookup; |
118 | 119 | InvokableRunner runnable = new InvokableRunner(ModalityState.NON_MODAL) { |
119 | 120 | public void run() { |
120 | | - IServer server = new IServer(currentModule.getParent()); |
121 | | - String path = file.getPath(); |
122 | | - String modulePath = currentModule.getUnifiedModule().getModuleDirectory(); |
123 | | - String relativePath = path.substring(modulePath.length()); |
124 | | - if(relativePath.startsWith("/")) { |
125 | | - relativePath = relativePath.substring(1); |
126 | | - } |
127 | | - IPath projectRelativePath = new IPath(relativePath); |
128 | | - IProject iProject = new IProject(currentModule); |
129 | | - SerializationManager serializationManager = ComponentProvider.getComponent(project, SerializationManager.class); |
| 121 | + ApplicationManager.getApplication().runWriteAction( |
| 122 | + () -> { |
| 123 | + IServer server = new IServer(currentModule.getParent()); |
| 124 | + String path = file.getPath(); |
| 125 | + String modulePath = currentModule.getUnifiedModule().getModuleDirectory(); |
| 126 | + String relativePath = path.substring(modulePath.length()); |
| 127 | + if(relativePath.startsWith("/")) { |
| 128 | + relativePath = relativePath.substring(1); |
| 129 | + } |
| 130 | + IPath projectRelativePath = new IPath(relativePath); |
| 131 | + IProject iProject = new IProject(currentModule); |
| 132 | + SerializationManager serializationManager = ComponentProvider.getComponent(project, SerializationManager.class); |
130 | 133 |
|
131 | | - try { |
132 | | - ImportRepositoryContentManager importManager = new ImportRepositoryContentManager(server, projectRelativePath, iProject, serializationManager); |
133 | | - importManager.doImport(new NullProgressMonitor()); |
134 | | - } catch(CoreException e) { |
135 | | - boolean done = false; |
136 | | - if(e.getCause() instanceof org.apache.sling.ide.transport.RepositoryException) { |
137 | | - if(e.getCause().getCause() instanceof PathNotFoundException) { |
138 | | - if(messageManager != null) { |
139 | | - messageManager.sendDebugNotification("import.from.remote.resource.not.found", relativePath); |
140 | | - done = true; |
| 134 | + try { |
| 135 | + ImportRepositoryContentManager importManager = new ImportRepositoryContentManager(server, projectRelativePath, iProject, serializationManager); |
| 136 | + importManager.doImport(new NullProgressMonitor()); |
| 137 | + } catch(CoreException e) { |
| 138 | + boolean done = false; |
| 139 | + if(e.getCause() instanceof org.apache.sling.ide.transport.RepositoryException) { |
| 140 | + if(e.getCause().getCause() instanceof PathNotFoundException) { |
| 141 | + if(messageManager != null) { |
| 142 | + messageManager.sendDebugNotification("import.from.remote.resource.not.found", relativePath); |
| 143 | + done = true; |
| 144 | + } |
| 145 | + } |
141 | 146 | } |
| 147 | + if(!done && messageManager != null) { messageManager.sendDebugNotification("import.from.failed", e); } |
| 148 | + } catch(InterruptedException e) { |
| 149 | + if(messageManager != null) { messageManager.sendDebugNotification("import.from.failed", e); } |
| 150 | + } catch(SerializationException e) { |
| 151 | + if(messageManager != null) { messageManager.sendDebugNotification("import.from.failed", e); } |
142 | 152 | } |
143 | 153 | } |
144 | | - if(!done && messageManager != null) { messageManager.sendDebugNotification("import.from.failed", e); } |
145 | | - } catch(InterruptedException e) { |
146 | | - if(messageManager != null) { messageManager.sendDebugNotification("import.from.failed", e); } |
147 | | - } catch(SerializationException e) { |
148 | | - if(messageManager != null) { messageManager.sendDebugNotification("import.from.failed", e); } |
149 | | - } |
| 154 | + ); |
150 | 155 | } |
151 | 156 | }; |
152 | 157 | invokeAndWait(runnable); |
|
0 commit comments