public void goBack(){ final WebHistory history = webEngine.getHistory(); ObservableList<WebHistory.Entry> entryList = history.getEntries(); int currentIndex = history.getCurrentIndex(); Platform.runLater(new Runnable() { @Override public void run() { try { history.go(-1); }catch(Exception e){ webEngine.loadContent(body); } } }); }
public HTMLView() { viewport = ToolBarContainer.createDefaultContainer(Orientation.RIGHT); webView = new WebView(); viewport.setContent(webView); VLToolBar bar = new VLToolBar(); Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true); Button prevPage = FXUIUtils.createButton("prev", "Previous Page", false); WebHistory history = webView.getEngine().getHistory(); prevPage.setOnAction((event) -> { history.go(-1); }); bar.add(prevPage); Button nextPage = FXUIUtils.createButton("next", "Next Page", false); nextPage.setOnAction((event) -> { history.go(1); }); bar.add(nextPage); openInBrowser.setOnAction((event) -> { try { URI uri = ProjectHTTPDServer.getURI(fileHandler.getCurrentFile().toPath()); if (uri != null) Desktop.getDesktop().browse(uri); else Desktop.getDesktop().open(fileHandler.getCurrentFile()); } catch (IOException e) { e.printStackTrace(); } }); bar.add(openInBrowser); history.currentIndexProperty().addListener((ob, o, n) -> { nextPage.setDisable(n.intValue() == history.getEntries().size() - 1); prevPage.setDisable(n.intValue() == 0); }); viewport.getToolBarPanel().add(bar); }
private void addButtonsAvailabilityListeners(JButton backButton, JButton forwardButton) { Platform.runLater(() -> myEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> { if (newState == Worker.State.SUCCEEDED) { final WebHistory history = myEngine.getHistory(); boolean isGoBackAvailable = history.getCurrentIndex() > 0; boolean isGoForwardAvailable = history.getCurrentIndex() < history.getEntries().size() - 1; ApplicationManager.getApplication().invokeLater(() -> { backButton.setEnabled(isGoBackAvailable); forwardButton.setEnabled(isGoForwardAvailable); }); } })); }
public String goBack() { final WebHistory history = webEngine.getHistory(); ObservableList<WebHistory.Entry> entryList = history.getEntries(); int currentIndex = history.getCurrentIndex(); // Out("currentIndex = "+currentIndex); // Out(entryList.toString().replace("],","]\n")); if (currentIndex > 0) { Platform.runLater(() -> { history.go(-1); }); } return entryList.get(currentIndex > 0 ? currentIndex - 1 : currentIndex).getUrl(); }
public String goForward() { final WebHistory history = webEngine.getHistory(); ObservableList<WebHistory.Entry> entryList = history.getEntries(); int currentIndex = history.getCurrentIndex(); // Out("currentIndex = "+currentIndex); // Out(entryList.toString().replace("],","]\n")); if (currentIndex < entryList.size() - 1) { Platform.runLater(() -> { history.go(1); }); } return entryList .get(currentIndex < entryList.size() - 1 ? currentIndex + 1 : currentIndex) .getUrl(); }
public String goBack() { final WebHistory history = webEngine.getHistory(); ObservableList<WebHistory.Entry> entryList = history.getEntries(); int currentIndex = history.getCurrentIndex(); // Out("currentIndex = "+currentIndex); // Out(entryList.toString().replace("],","]\n")); Platform.runLater(() -> { history.go(-1); }); return entryList.get(currentIndex > 0 ? currentIndex - 1 : currentIndex).getUrl(); }
public String goForward() { final WebHistory history = webEngine.getHistory(); ObservableList<WebHistory.Entry> entryList = history.getEntries(); int currentIndex = history.getCurrentIndex(); // Out("currentIndex = "+currentIndex); // Out(entryList.toString().replace("],","]\n")); Platform.runLater(() -> { history.go(1); }); return entryList .get(currentIndex < entryList.size() - 1 ? currentIndex + 1 : currentIndex) .getUrl(); }
@SuppressWarnings("restriction") public String getCurrentURL() { //history = engine.getHistory(); ObservableList<WebHistory.Entry> entryList = history.getEntries(); int currentIndex = history.getCurrentIndex(); String txt = null; if (currentIndex >=0 ) { txt = entryList.get(currentIndex).getUrl(); //System.out.println("currentIndex is " + currentIndex + " url is " + txt); //Platform.runLater(() -> { history.go(0);} ); } return txt; }
public String goBack() { final WebHistory history = engine.getHistory(); ObservableList<WebHistory.Entry> entryList=history.getEntries(); int currentIndex=history.getCurrentIndex(); // Out("currentIndex = "+currentIndex); // Out(entryList.toString().replace("],","]\n")); Platform.runLater(new Runnable() { public void run() { history.go(-1); } }); return entryList.get(currentIndex>0?currentIndex-1:currentIndex).getUrl(); }
public String goForward() { final WebHistory history=engine.getHistory(); ObservableList<WebHistory.Entry> entryList=history.getEntries(); int currentIndex=history.getCurrentIndex(); // Out("currentIndex = "+currentIndex); // Out(entryList.toString().replace("],","]\n")); Platform.runLater(new Runnable() { public void run() { history.go(1); } }); return entryList.get(currentIndex<entryList.size()-1?currentIndex+1:currentIndex).getUrl(); }
/** * @return the history */ public WebHistory getHistory() { return history; }
/** * @param history * the history to set */ public void setHistory(WebHistory history) { this.history = history; }