Changeset 824
- Timestamp:
- 02/04/14 16:20:02 (10 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/io/WebParser.java
r816 r824 48 48 import org.expeditee.items.Picture; 49 49 import org.expeditee.items.Text; 50 import org.expeditee.items.widgets.JfxBrowser; 50 51 import org.w3c.dom.Node; 51 52 import org.w3c.dom.html.HTMLBodyElement; … … 281 282 * The Expeditee frame to output the converted page to 282 283 */ 283 public static void parsePageSimple( final WebEngine webEngine, final WebView webView, final Frame frame) {284 public static void parsePageSimple(JfxBrowser browserWidget, final WebEngine webEngine, final WebView webView, final Frame frame) { 284 285 try { 286 browserWidget.setOverlayVisible(true); 287 285 288 final Object notifier = new Object(); 286 289 … … 633 636 } 634 637 635 638 browserWidget.setOverlayVisible(false); 636 639 637 640 } … … 1179 1182 bounds = (JSObject) ((JSObject) currentNode.getParentNode()).call("getBoundingClientRect", new Object[] {}); 1180 1183 1181 // TODO: This doesn't check if an element or any of its parent elements have position:fixed set - the only way to check seems to be to walking through the element's parents until the document root is reached (or a recursive function) 1184 // TODO: This doesn't check if an element or any of its parent elements have position:fixed set - the only way to check seems to 1185 // be to walking through the element's parents until the document root is reached (or a recursive function) 1182 1186 float x = Float.valueOf(bounds.getMember("left").toString()); 1183 1187 float y = Float.valueOf(bounds.getMember("top").toString()); -
trunk/src/org/expeditee/items/widgets/JfxBrowser.java
r815 r824 22 22 import javafx.event.EventDispatcher; 23 23 import javafx.event.EventHandler; 24 import javafx.geometry.Insets; 24 25 import javafx.geometry.Point2D; 26 import javafx.geometry.Pos; 25 27 import javafx.geometry.Rectangle2D; 26 28 import javafx.scene.Node; 27 29 import javafx.scene.Scene; 28 30 import javafx.scene.control.Button; 31 import javafx.scene.control.Label; 32 import javafx.scene.control.ProgressIndicator; 29 33 import javafx.scene.control.TextField; 30 34 import javafx.scene.input.KeyEvent; … … 33 37 import javafx.scene.layout.HBox; 34 38 import javafx.scene.layout.Priority; 39 import javafx.scene.layout.StackPane; 35 40 import javafx.scene.layout.VBox; 36 41 import javafx.scene.web.WebEngine; … … 68 73 private WebEngine _webEngine; 69 74 private TextField _urlField; 75 private StackPane _overlay; 70 76 71 77 private MouseButton _buttonDownId = MouseButton.NONE; … … 145 151 private void initFx(String url) { 146 152 try { 153 StackPane mainLayout = new StackPane(); 147 154 VBox vertical = new VBox(); 148 155 HBox horizontal = new HBox(); 156 horizontal.getStyleClass().add("custom-toolbar"); 149 157 150 158 Button backButton = new Button("Back"); 151 159 backButton.setMinWidth(Button.USE_PREF_SIZE); 152 160 backButton.setFocusTraversable(false); 161 backButton.getStyleClass().add("first"); 162 153 163 Button forwardButton = new Button("Forward"); 154 164 forwardButton.setMinWidth(Button.USE_PREF_SIZE); 155 165 forwardButton.setFocusTraversable(false); 166 forwardButton.getStyleClass().add("last"); 167 156 168 this._urlField = new TextField(url); 169 this._urlField.getStyleClass().add("first"); 157 170 this._urlField.setMinWidth(0); 158 171 this._urlField.setMaxWidth(Double.MAX_VALUE); 159 172 this._urlField.setFocusTraversable(false); 173 174 Button goButton = new Button("Go"); 175 goButton.getStyleClass().add("last"); 176 goButton.setMinWidth(Button.USE_PREF_SIZE); 177 goButton.setFocusTraversable(false); 178 160 179 Button convertButton = new Button("Convert"); 161 180 convertButton.setMinWidth(Button.USE_PREF_SIZE); 162 181 convertButton.setFocusTraversable(false); 163 Button convertButtonNew = new Button("Convert (New Method)"); 164 convertButtonNew.setMinWidth(Button.USE_PREF_SIZE); 165 convertButtonNew.setFocusTraversable(false); 166 167 horizontal.getChildren().addAll(backButton, forwardButton, this._urlField, convertButton, convertButtonNew); 168 182 183 horizontal.getChildren().addAll(backButton, forwardButton, this._urlField, goButton, convertButton); 184 169 185 HBox.setHgrow(backButton, Priority.NEVER); 170 186 HBox.setHgrow(forwardButton, Priority.NEVER); 171 187 HBox.setHgrow(convertButton, Priority.NEVER); 172 HBox.setHgrow( convertButtonNew, Priority.NEVER);188 HBox.setHgrow(goButton, Priority.NEVER); 173 189 HBox.setHgrow(this._urlField, Priority.ALWAYS); 174 190 191 HBox.setMargin(goButton, new Insets(0, 5, 0, 0)); 192 HBox.setMargin(forwardButton, new Insets(0, 5, 0, 0)); 193 175 194 this._webView = new WebView(); 176 195 this._webView.setMaxWidth(Double.MAX_VALUE); … … 179 198 VBox.setVgrow(this._webView, Priority.ALWAYS); 180 199 this._webEngine = this._webView.getEngine(); 181 200 182 201 vertical.getChildren().addAll(horizontal, this._webView); 183 184 Scene scene = new Scene(vertical); 202 203 this._overlay = new StackPane(); 204 this._overlay.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); 205 206 // Class for CSS styling 207 this._overlay.getStyleClass().add("browser-overlay"); 208 209 // Don't show the overlay until processing the page 210 this._overlay.setVisible(false); 211 212 Label overlayLabel = new Label("Importing page to Expeditee..."); 213 214 ProgressIndicator prog = new ProgressIndicator(); 215 prog.setMaxSize(25, 25); 216 217 this._overlay.getChildren().addAll(overlayLabel, prog); 218 219 this._overlay.setAlignment(Pos.CENTER); 220 StackPane.setMargin(overlayLabel, new Insets(-50, 0, 0, 0)); 221 StackPane.setMargin(prog, new Insets(50, 0, 0, 0)); 222 223 mainLayout.getChildren().addAll(vertical, this._overlay); 224 225 Scene scene = new Scene(mainLayout); 226 227 scene.getStylesheets().add(ClassLoader.getSystemResource("org/expeditee/assets/style/jfx.css").toString()); 185 228 186 229 this._panel.setScene(scene); … … 217 260 }); 218 261 219 220 262 convertButton.setOnAction(new EventHandler<ActionEvent>() { 221 @Override222 public void handle(ActionEvent e) {223 getFrame();224 }225 });226 227 convertButtonNew.setOnAction(new EventHandler<ActionEvent>() {228 263 @Override 229 264 public void handle(ActionEvent e) { … … 591 626 new Thread(new Runnable() { 592 627 public void run() { 593 WebParser.parsePageSimple(JfxBrowser.this ._webEngine, JfxBrowser.this._webView, DisplayIO.getCurrentFrame());628 WebParser.parsePageSimple(JfxBrowser.this, JfxBrowser.this._webEngine, JfxBrowser.this._webView, DisplayIO.getCurrentFrame()); 594 629 } 595 630 }).start(); … … 613 648 public boolean ItemsLeftClickDropped() { 614 649 Text carried = null; 615 if ((carried = FreeItems.getTextAttachedToCursor()) == null) { 650 if ((carried = FreeItems.getTextAttachedToCursor()) == null) { // fails if no text is attached to cursor. 616 651 return false; 617 652 } 618 653 619 if (carried.getText().toLowerCase().equals(BACK)) {654 if (carried.getText().toLowerCase().equals(BACK)) { 620 655 navigateBack(); 621 } else if (carried.getText().toLowerCase().equals(FORWARD)) {656 } else if (carried.getText().toLowerCase().equals(FORWARD)) { 622 657 navigateForward(); 623 } else if (carried.getText().toLowerCase().equals(REFRESH)) {658 } else if (carried.getText().toLowerCase().equals(REFRESH)) { 624 659 refresh(); 625 } else if (carried.getText().toLowerCase().equals(CONVERT)) {660 } else if (carried.getText().toLowerCase().equals(CONVERT)) { 626 661 getFrame(); 627 662 } else { … … 630 665 FreeItems.getInstance().clear(); 631 666 } 632 667 633 668 return true; 634 669 } … … 683 718 } 684 719 720 public void setOverlayVisible(final boolean visible) { 721 Platform.runLater(new Runnable() { 722 723 @Override 724 public void run() { 725 JfxBrowser.this._overlay.setVisible(visible); 726 } 727 }); 728 729 } 730 685 731 @Override 686 732 protected String[] getArgs() {
Note:
See TracChangeset
for help on using the changeset viewer.