8000 Änderungen an der Einbindung externer Ressourcen für Javascript Edito… · Silent-Fred/iTrySQL@e730cfa · GitHub
[go: up one dir, main page]

Skip to content

Commit e730cfa

Browse files
committed
Änderungen an der Einbindung externer Ressourcen für Javascript Editor (Windows-Pfade)
1 parent 17778a9 commit e730cfa

File tree

5 files changed

+17
-34
lines changed

5 files changed

+17
-34
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
</classpath>
9090
</javac>
9191

92-
<!-- Copy over none Java-Files -->
92+
<!-- Copy over non Java-Files -->
9393
<copy todir="${BuildPath}/build/classes">
9494
<fileset dir="${BuildPath}/project/src">
9595
<exclude name="**/*.java" />

src/de/kuehweg/sqltool/dialog/component/editor/StatementEditorComponent.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import de.kuehweg.sqltool.common.DialogDictionary;
3232
import de.kuehweg.sqltool.common.UserPreferencesManager;
3333
import de.kuehweg.sqltool.dialog.action.StatementEditorFindAction;
34-
import de.kuehweg.sqltool.dialog.util.WebViewBundledResourceErrorDetection;
3534
import de.kuehweg.sqltool.dialog.util.WebViewWithHSQLDBBugfix;
3635
import de.kuehweg.sqltool.itrysql.ResourceLocator;
3736
import javafx.beans.value.ChangeListener;
@@ -152,12 +151,12 @@ public void changed(final ObservableValue<? extends State> observable, final Sta
152151
}
153152
});
154153

155-
if (new WebViewBundledResourceErrorDetection().runningOnJavaVersionWithBundledJavascriptDeficiencies()
156-
&& new ResourceLocator().looksLikeBundledApplication()) {
154+
final ResourceLocator locator = new ResourceLocator();
155+
try {
157156
javascriptEditor.getEngine()
158-
.load(new ResourceLocator().getExternalFormForExplodedResourceInBundle(resource));
159-
} else {
160-
javascriptEditor.getEngine().load(getClass().getResource(resource).toExternalForm());
157+
.load(locator.getExternalFormForExplodedResourceInBundle(resource).toExternalForm());
158+
} catch (final Exception e) {
159+
installEditorTextArea();
161160
}
162161
}
163162

src/de/kuehweg/sqltool/dialog/component/editor/StatementEditorCycle.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,8 @@ public Class<? extends StatementEditor> next() {
5252
return statementEditorClasses.get(cycle);
5353
}
5454

55-
public void oopsNotSupportedInThisVersion(final Class<? extends StatementEditor> defectiveStatementEditorClass) {
56-
statementEditorClasses.remove(defectiveStatementEditorClass);
57-
if (statementEditorClasses.isEmpty()) {
58-
statementEditorClasses.add(TextAreaBasedEditor.class);
59-
}
60-
}
61-
6255
public int numberOfOptions() {
6356
return statementEditorClasses.size();
6457
}
58+
6559
}

src/de/kuehweg/sqltool/dialog/util/WebViewBundledResourceErrorDetection.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,4 @@ private int readUpdateVersion() {
7777
public boolean runningOnJavaVersionWithRenderingDeficiencies() {
7878
return majorVersion == JAVA_8 && updateVersion > 40 && updateVersion < 72;
7979
}
80-
81-
public boolean runningOnJavaVersionWithBundledJavascriptDeficiencies() {
82-
// FIXME Wird laut Bugtracking erst in Java 9 behoben sein - da bislang
83-
// aber ungetestet, wird hier davon ausgegangen, dass es halt überhaupt
84-
// nicht funktioniert.
85-
return true;
86-
}
87-
8880
}

src/de/kuehweg/sqltool/itrysql/ResourceLocator.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,23 @@
2626

2727
package de.kuehweg.sqltool.itrysql;
2828

29-
import java.nio.file.Paths;
29+
import java.io.File;
30+
import java.net.MalformedURLException;
31+
import java.net.URL;
3032

3133
/**
3234
* @author Michael Kühweg
3335
*/
3436
public class ResourceLocator {
3537

36-
public String getExternalFormForExplodedResourceInBundle(final String name) {
37-
if (looksLikeBundledApplication()) {
38-
return Paths.get(whoAmI()).getParent() + "/libs" + name;
39-
}
40-
return name;
38+
public URL getExternalFormForExplodedResourceInBundle(final String name) throws MalformedURLException {
39+
final URL me = whoAmI();
40+
final File file = new File(me.getPath());
41+
final String parentPath = file.getParent();
42+
return new URL(me.getProtocol(), me.getHost(), me.getPort(), parentPath + "/libs" + name);
4143
}
4244

43-
public boolean looksLikeBundledApplication() {
44-
return whoAmI().toLowerCase().endsWith(".jar");
45-
}
46-
47-
private String whoAmI() {
48-
return getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm();
45+
public URL whoAmI() {
46+
return getClass().getProtectionDomain().getCodeSource().getLocation();
4947
}
5048
}

0 commit comments

Comments
 (0)
0