Skip to content

Commit be75d63

Browse files
committed
Added a fix for 1.0.3.4-beta1 for the failing Import From action.
1 parent 847d026 commit be75d63

File tree

5 files changed

+47
-30
lines changed

5 files changed

+47
-30
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

META-INF/plugin.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin version="2">
22
<id>com.headwire.aem.tooling.intellij</id>
33
<name>AEM IDE Tooling 4 IntelliJ</name>
4-
<version>1.0.3.3</version>
4+
<version>1.0.3.4-beta1</version>
55
<vendor email="aemintellijplugin@headwire.com" url="https://www.headwire.com/aemintellijplugin">headwire.com Inc</vendor>
66

77
<description><![CDATA[
@@ -16,6 +16,14 @@
1616

1717
<change-notes><![CDATA[
1818
<ul>
19+
<li>1.0.3.4-beta1:
20+
<ol>
21+
<li>
22+
Added a fix of a threading issue inside the Import From action. IntelliJ does not permit (anymore)
23+
to write in an User Action.
24+
</li>
25+
</ol>
26+
</li>
1927
<li>1.0.3.3:
2028
<ol>
2129
<li>

Readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This plugin requires to run IntelliJ IDEA **2016.2** or higher.
66

77
#### Releases:
88

9+
Beta of 1.0.3.4 is out with a fix for the Import From action.
10+
911
Release of 1.0.3.3 is out. Check out in the release section.
1012

1113
**Attention**: due to changes inside IntelliJ APIs some stored data might be lost during
@@ -45,6 +47,10 @@ The **master** is the latest release code and it the same as the highest
4547

4648
#### Updates:
4749

50+
**1.0.3.4-beta1**:
51+
* A fix for the Import From User Action that fails because I cannot write from a
52+
User Action.
53+
4854
**1.0.3.3**:
4955
* Working on issues with latest IntelliJ Releases.
5056
* All threading is centralized in single class and with it fixed some issues with threading

src/main/java/com/headwire/aem/tooling/intellij/action/ImportFromServerAction.java

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.headwire.aem.tooling.intellij.util.ExecutionUtil;
3333
import com.intellij.openapi.actionSystem.CommonDataKeys;
3434
import com.intellij.openapi.actionSystem.DataContext;
35+
import com.intellij.openapi.application.Application;
3536
import com.intellij.openapi.application.ApplicationManager;
3637
import com.intellij.openapi.application.ModalityState;
3738
import com.intellij.openapi.project.Project;
@@ -117,36 +118,40 @@ private void doImport(final Project project, final VirtualFile file) {
117118
final ServerConfiguration.Module currentModule = currentModuleLookup;
118119
InvokableRunner runnable = new InvokableRunner(ModalityState.NON_MODAL) {
119120
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);
130133

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+
}
141146
}
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); }
142152
}
143153
}
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+
);
150155
}
151156
};
152157
invokeAndWait(runnable);

0 commit comments

Comments
 (0)