Changeset 898 for trunk/src/org/expeditee/items/widgets/JfxBrowser.java
- Timestamp:
- 02/16/14 14:28:45 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/widgets/JfxBrowser.java
r894 r898 10 10 */ 11 11 import java.awt.Point; 12 import java.awt.event.KeyListener; 12 13 import java.io.BufferedReader; 13 14 import java.io.IOException; … … 105 106 private StackPane _overlay; 106 107 108 private boolean _parserRunning; 109 107 110 private MouseButton _buttonDownId = MouseButton.NONE; 108 111 private MouseEvent _backupEvent = null; … … 129 132 130 133 _panel = (JFXPanel) _swingComponent; 134 135 // Quick & easy way of having a cancel function for the web parser. 136 // Can't just have a JFX button, as the JFX thread is occupied with running JavaScript so it wouldn't receive the click event straight away 137 _swingComponent.addKeyListener(new KeyListener() { 138 139 @Override 140 public void keyReleased(java.awt.event.KeyEvent e) { 141 if(e.getKeyCode() == java.awt.event.KeyEvent.VK_ESCAPE) { 142 JfxBrowser.this.cancel(); 143 } 144 } 145 146 @Override 147 public void keyPressed(java.awt.event.KeyEvent e) { 148 } 149 150 @Override 151 public void keyTyped(java.awt.event.KeyEvent e) { 152 } 153 }); 131 154 132 155 Platform.runLater(new Runnable() { … … 838 861 839 862 public void getFrameNew() { 840 // this.setSize(1000, 1000); 841 // this._browser.setBounds(getX(), getY(), getWidth(), getHeight()); 842 // this.layout(this._browser); 843 863 864 this._parserRunning = true; 865 844 866 try { 845 867 // hack to make sure we don't try parsing the page from within the JavaFX thread, … … 852 874 } catch (Exception e) { 853 875 e.printStackTrace(); 876 this._parserRunning = false; 854 877 } 855 878 } … … 1106 1129 return (urlLower.startsWith("http://") || url.startsWith("https://") || urlLower.startsWith("ftp://") || urlLower.startsWith("file://")); 1107 1130 } 1131 1132 /** 1133 * @return Whether the parser is running. If this is true then the parser is running, 1134 * however even if it is false, the parser may still be running (but it has been requested to stop) 1135 */ 1136 public boolean isParserRunning() { 1137 return this._parserRunning; 1138 } 1139 1140 /** 1141 * Should be called when the web parser has finished converting a page 1142 */ 1143 public void parserFinished() { 1144 this._parserRunning = false; 1145 } 1146 1147 /** 1148 * Cancels the current action being performed by the browser, such as loading a page or converting a page 1149 */ 1150 public void cancel() { 1151 if(isParserRunning()) { 1152 this._parserRunning = false; 1153 } else { 1154 Platform.runLater(new Runnable() { 1155 1156 @Override 1157 public void run() { 1158 JfxBrowser.this._webEngine.getLoadWorker().cancel(); 1159 } 1160 }); 1161 } 1162 } 1108 1163 }
Note:
See TracChangeset
for help on using the changeset viewer.