Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
DARIAH-DE
TextGridLab
RDF Object Plugin
Commits
3ea62655
Commit
3ea62655
authored
Apr 17, 2014
by
Ubbo Veentjer
Browse files
execute js only after browser ready
parent
13062b95
Changes
2
Hide whitespace changes
Inline
Side-by-side
de.blumenbach_online.tglab.sammlungsdb/src/de/blumenbach_online/tglab/sammlungsdb/views/SammlungsDbEditor.java
View file @
3ea62655
package
de.blumenbach_online.tglab.sammlungsdb.views
;
import
java.util.ArrayList
;
import
info.textgrid.lab.authn.RBACSession
;
import
info.textgrid.lab.core.model.TextGridObject
;
...
...
@@ -18,6 +20,7 @@ import org.eclipse.ui.IEditorInput;
import
org.eclipse.ui.IEditorSite
;
import
org.eclipse.ui.PartInitException
;
import
org.eclipse.ui.part.EditorPart
;
import
org.eclipse.ui.progress.UIJob
;
import
de.blumenbach_online.tglab.sammlungsdb.Activator
;
import
de.blumenbach_online.tglab.sammlungsdb.preferences.PluginPreferencePage
;
...
...
@@ -25,7 +28,8 @@ import de.blumenbach_online.tglab.sammlungsdb.preferences.PluginPreferencePage;
public
class
SammlungsDbEditor
extends
EditorPart
{
private
Browser
browser
;
private
boolean
browserReady
=
false
;
private
boolean
browserReady
=
false
;
private
ArrayList
<
UIJob
>
browserJobs
=
new
ArrayList
<
UIJob
>();
@Override
public
void
doSave
(
IProgressMonitor
arg0
)
{
...
...
@@ -60,11 +64,9 @@ public class SammlungsDbEditor extends EditorPart {
String
uri
=
tgo
.
getURI
().
toString
();
String
contentType
=
tgo
.
getMetadata
().
getGeneric
().
getProvided
().
getFormat
();
if
(
browserReady
)
{
System
.
out
.
println
(
"u: "
+
uri
+
" - t: "
+
title
+
" - ct: "
+
contentType
);
browser
.
execute
(
"addTGObject('"
+
uri
+
"', '"
+
title
+
"', '"
+
contentType
+
"')"
);
}
this
.
setPartName
(
title
);
scheduleJavascript
(
"addTGObject('"
+
uri
+
"', '"
+
title
+
"', '"
+
contentType
+
"')"
);
}
catch
(
CoreException
e
)
{
IStatus
status
=
new
Status
(
IStatus
.
ERROR
,
Activator
.
PLUGIN_ID
,
"Error !"
,
e
);
...
...
@@ -115,16 +117,44 @@ public class SammlungsDbEditor extends EditorPart {
//System.out.println("set sid to: " + sid);
browser
.
execute
(
"setSid('"
+
sid
+
"')"
);
String
user
=
Platform
.
getPreferencesService
().
getString
(
Activator
.
PLUGIN_ID
,
PluginPreferencePage
.
boldbUser_id
,
""
,
null
);
String
pw
=
Platform
.
getPreferencesService
().
getString
(
Activator
.
PLUGIN_ID
,
PluginPreferencePage
.
boldbPW_id
,
""
,
null
);
String
user
=
Platform
.
getPreferencesService
().
getString
(
Activator
.
PLUGIN_ID
,
PluginPreferencePage
.
boldbUser_id
,
""
,
null
);
String
pw
=
Platform
.
getPreferencesService
().
getString
(
Activator
.
PLUGIN_ID
,
PluginPreferencePage
.
boldbPW_id
,
""
,
null
);
browser
.
execute
(
"setAuth('"
+
user
+
"','"
+
pw
+
"')"
);
browserReady
=
true
;
for
(
UIJob
job
:
browserJobs
)
{
job
.
schedule
();
}
}
});
}
/**
* execute javascript only is browser is ready, otherwise put it to joblist
* @param js
*/
public
void
scheduleJavascript
(
final
String
js
)
{
UIJob
execjs
=
new
UIJob
(
"executing Javasscript"
){
@Override
public
IStatus
runInUIThread
(
IProgressMonitor
monitor
)
{
browser
.
execute
(
js
);
return
Status
.
OK_STATUS
;
}
};
registerBrowserJob
(
execjs
);
}
public
void
registerBrowserJob
(
UIJob
job
)
{
if
(
browserReady
)
job
.
schedule
();
else
browserJobs
.
add
(
job
);
}
@Override
public
void
setFocus
()
{
...
...
de.blumenbach_online.tglab.sammlungsdb/src/de/blumenbach_online/tglab/sammlungsdb/views/SammlungsDbView.java
View file @
3ea62655
...
...
@@ -68,8 +68,8 @@ public class SammlungsDbView extends ViewPart {
//System.out.println("set sid to: " + sid);
spBrowser
.
execute
(
"setSid('"
+
sid
+
"')"
);
String
user
=
Platform
.
getPreferencesService
().
getString
(
Activator
.
PLUGIN_ID
,
PluginPreferencePage
.
boldbUser_id
,
""
,
null
);
String
pw
=
Platform
.
getPreferencesService
().
getString
(
Activator
.
PLUGIN_ID
,
PluginPreferencePage
.
boldbPW_id
,
""
,
null
);
String
user
=
Platform
.
getPreferencesService
().
getString
(
Activator
.
PLUGIN_ID
,
PluginPreferencePage
.
boldbUser_id
,
""
,
null
);
String
pw
=
Platform
.
getPreferencesService
().
getString
(
Activator
.
PLUGIN_ID
,
PluginPreferencePage
.
boldbPW_id
,
""
,
null
);
spBrowser
.
execute
(
"setAuth('"
+
user
+
"','"
+
pw
+
"')"
);
browserReady
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment