Skip to content

Commit

Permalink
Providing custom environment entries for ASP, closes #369
Browse files Browse the repository at this point in the history
- introducing new preference page for environment entries
- ASP is restarted when environment entries have been changed by user
- installed asciidoctor version adapter does use this as well
- upgraded to 2.5.0 already because of changed libraries etc.
  • Loading branch information
de-jcup committed Sep 7, 2021
1 parent aa85eba commit 5dbf3ea
Show file tree
Hide file tree
Showing 11 changed files with 715 additions and 12 deletions.
2 changes: 1 addition & 1 deletion asciidoctor-editor-feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="de.jcup.asciidoctoreditor"
label="Asciidoctor Editor"
version="2.4.1"
version="2.5.0"
provider-name="Albert Tregnaghi">

<description url="https://marketplace.eclipse.org/content/asciidoctor-editor">
Expand Down
2 changes: 1 addition & 1 deletion asciidoctor-editor-plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Asciidoctor Editor
Bundle-SymbolicName: de.jcup.asciidoctoreditor;singleton:=true
Bundle-Version: 2.4.1
Bundle-Version: 2.5.0
Bundle-Activator: de.jcup.asciidoctoreditor.AsciiDoctorEditorActivator
Bundle-Vendor: Albert Tregnaghi
Require-Bundle: org.eclipse.ui,
Expand Down
9 changes: 9 additions & 0 deletions asciidoctor-editor-plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,15 @@
<keywordReference
id="asciidoctoreditor.preferences.keyword.tasks">
</keywordReference>
</page>
<page
id="asciidoctoreditor.eclipse.preferences.AsciiDoctorEditorEnvironmentPreferencePage"
class="de.jcup.asciidoctoreditor.preferences.AsciiDoctorEditorEnvironmentPreferencePage"
name="Environmemt"
category="asciidoctoreditor.eclipse.preferences.AsciiDoctorEditorEditorPreferencePage">
<keywordReference
id="asciidoctoreditor.preferences.keyword.asciidoctor">
</keywordReference>
</page>
<!-- plantuml -->
<page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
package de.jcup.asciidoctoreditor;

import java.io.File;
import java.util.Map;

import de.jcup.asciidoctoreditor.asciidoc.ASPServerAdapter;
import de.jcup.asciidoctoreditor.console.AsciiDoctorConsoleUtil;
import de.jcup.asciidoctoreditor.preferences.AsciiDoctorEditorPreferences;
import de.jcup.asciidoctoreditor.preferences.CustomEnvironmentEntrySupport;
import de.jcup.asp.client.AspClient;

public class ASPSupport {
Expand Down Expand Up @@ -147,6 +149,13 @@ private void internalUpdateASPServerStart() {
aspServerAdapter.setMaxPort(preferences.getAspServerMaxPort());
aspServerAdapter.setConsoleAdapter(AsciiDoctorEclipseConsoleAdapter.INSTANCE);
aspServerAdapter.setLogAdapter(AsciiDoctorEclipseLogAdapter.INSTANCE);

Map<String,String> customEnvEntries = null;
if (CustomEnvironmentEntrySupport.DEFAULT.areCustomEnvironmentEntriesEnabled()) {
customEnvEntries = CustomEnvironmentEntrySupport.DEFAULT.fetchConfiguredEnvironmentEntriesAsMap();
}
aspServerAdapter.setCustomEnvironmentEntries(customEnvEntries);

aspServerAdapter.startServer();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import de.jcup.asciidoctoreditor.OSUtil;
import de.jcup.asciidoctoreditor.console.AsciiDoctorConsoleUtil;
import de.jcup.asciidoctoreditor.preferences.AsciiDoctorEditorPreferences;
import de.jcup.asciidoctoreditor.preferences.CustomEnvironmentEntrySupport;
import de.jcup.asciidoctoreditor.util.AsciiDoctorEditorUtil;
import de.jcup.asp.client.AspClientProgressMonitor;

Expand All @@ -47,6 +48,10 @@ public void convertFile(File editorFileOrNull, File asciiDocFile, Map<String, Ob
}
ProcessBuilder pb = new ProcessBuilder(commands);
try {
CustomEnvironmentEntrySupport customEnvironmentEntrySupport = getCustomEnvEntrySupport();
if (customEnvironmentEntrySupport.areCustomEnvironmentEntriesEnabled()) {
pb.environment().putAll(customEnvironmentEntrySupport.fetchConfiguredEnvironmentEntriesAsMap());
}
StringBuffer lineStringBuffer = null;
Process process = pb.start();
try (InputStream is = process.getErrorStream();) {
Expand Down Expand Up @@ -91,6 +96,10 @@ public void convertFile(File editorFileOrNull, File asciiDocFile, Map<String, Ob

}

private CustomEnvironmentEntrySupport getCustomEnvEntrySupport() {
return CustomEnvironmentEntrySupport.DEFAULT;
}

protected String createCommandLineString(List<String> commands) {
StringBuilder commandLine = new StringBuilder();
for (String command : commands) {
Expand Down
Loading

0 comments on commit 5dbf3ea

Please sign in to comment.