Skip to content

Commit

Permalink
smoother browsing by not having the UI freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jan 4, 2016
1 parent 76c8746 commit 1133aec
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,25 @@ public void loadCodeFromGist(String addr, WebEngine engine)
this.addr = addr;
this.engine = engine;
loadGist = true;
fileListBox.valueProperty().removeListener(this);
Platform.runLater(()->runfx.setDisable(true));
Platform.runLater(()->edit.setDisable(true));
Platform.runLater(()->fileListBox.getItems().clear());
currentGist = ScriptingEngine.getCurrentGist(addr, engine).get(0);

ArrayList<String> fileList = ScriptingEngine.filesInGist(currentGist);

if(fileList.size()==1)
loadGistLocal(currentGist, fileList.get(0));
Platform.runLater(()->{
fileListBox.getItems().clear();

for(String s:fileList){
fileListBox.getItems().add(s);
}
fileListBox.setValue(fileList.get(0));
fileListBox.valueProperty().addListener(this);
Platform.runLater(()->runfx.setDisable(false));
Platform.runLater(()->edit.setDisable(false));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,14 @@ public void run(){
finishLoadingComponents();
}

if(scripting==null)
finishLoadingComponents();
System.out.println("Loading code from "+Current_URL);
try {
scripting.loadCodeFromGist(Current_URL, webEngine);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


//System.err.println("Done Loading to: "+webEngine.getLocation());
else{
try {
scripting.loadCodeFromGist(Current_URL, webEngine);
} catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
}
}
}.start();

Expand Down Expand Up @@ -289,53 +282,66 @@ private void finishLoadingComponents(){
}catch(Exception E){
E.printStackTrace();
}
finishedLoadingScriptingWidget=false;
try{
scripting = new ScriptingWebWidget( null ,Current_URL, webEngine);
Platform.runLater(() -> {
vBox.getChildren().add(scripting);
if(!isTutorialTab){
Platform.runLater(()->{
try{

myTab.setText(scripting.getFileName());
}catch(java.lang.NullPointerException ex){
// web page contains no gist
ex.printStackTrace();
myTab.setText("Web");
new Thread() {
public void run() {
finishedLoadingScriptingWidget=false;
try{
scripting = new ScriptingWebWidget( null ,Current_URL, webEngine);
Platform.runLater(() -> {
vBox.getChildren().add(scripting);
if(!isTutorialTab){
Platform.runLater(()->{
try{

myTab.setText(scripting.getFileName());
}catch(java.lang.NullPointerException ex){
// web page contains no gist
ex.printStackTrace();
myTab.setText("Web");
}
finishedLoadingScriptingWidget=true;
});
}
finishedLoadingScriptingWidget=true;
else
finishedLoadingScriptingWidget=true;
});
}
else

}catch(Exception ex){
ex.printStackTrace();
finishedLoadingScriptingWidget=true;
});

}catch(Exception ex){
ex.printStackTrace();
finishedLoadingScriptingWidget=true;
}
}

while(!finishedLoadingScriptingWidget){
ThreadUtil.wait(10);
}
System.out.println("Loading code from "+Current_URL);
try {
scripting.loadCodeFromGist(Current_URL, webEngine);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(firstBoot){
firstBoot=false;
//now that the application is totally loaded check for connections to add

while(!finishedLoadingScriptingWidget){
ThreadUtil.wait(10);
}

if(firstBoot){
firstBoot=false;
//now that the application is totally loaded check for connections to add

new Thread() {
public void run() {
setName("Get First Connection");
List<String> devs = SerialConnection.getAvailableSerialPorts();
if (devs.size() == 0) {
return;
} else {
DeviceManager.addConnection();
}
new Thread() {
public void run() {
setName("Get First Connection");
List<String> devs = SerialConnection.getAvailableSerialPorts();
if (devs.size() == 0) {
return;
} else {
DeviceManager.addConnection();
}
}
}.start();
}
}.start();
}
}
}.start();
}

public String goBack()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app.name=BowlerStudio
app.version=0.6.8
app.version=0.6.9


0 comments on commit 1133aec

Please sign in to comment.