Changeset 877 for trunk/src/org/expeditee/actions
- Timestamp:
- 02/11/14 01:27:13 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/ExploratorySearchActions.java
r876 r877 7 7 import org.expeditee.gui.FrameMouseActions; 8 8 import org.expeditee.gui.FreeItems; 9 import org.expeditee.gui.MessageBay;10 9 import org.expeditee.items.Item; 11 10 import org.expeditee.items.Text; 12 import org.expeditee.items.widgets.InteractiveWidget;13 import org.expeditee.items.widgets.JfxBrowser;14 11 import org.expeditee.settings.exploratorysearch.ExploratorySearchSettings; 15 12 import org.expeditee.settings.network.NetworkSettings; … … 23 20 /** 24 21 * Adds a text item to the cursor which is linked to a new frame with the web browser active overlay and a JavaFX browser. 25 * @param text The text item attached to the cursor.22 * @param caller The item that the action is called from 26 23 */ 27 public static void startBrowserSession( Text text) {24 public static void startBrowserSession(Item caller) { 28 25 try { 29 if (!(text instanceof Text)) { 30 MessageBay.errorMessage("Must be a text item."); 31 return; 26 String url; 27 28 Text urlItem = FreeItems.getTextAttachedToCursor(); 29 30 // If there is a text item attached to the cursor, use it as the URL to load 31 if (urlItem != null) { 32 url = urlItem.getText(); 33 34 // Remove the item, since the link to the browser session will added to the cursor 35 urlItem.delete(); 36 } else { 37 // Otherwise use the home page specified in the settings 38 url = NetworkSettings.HomePage.get(); 32 39 } 33 40 34 if(text.getLink() != null) { // text item can't already have a link 35 MessageBay.errorMessage("Text item already has link."); 36 return; 37 } 38 39 String url = ""; 40 41 // If no text with url is passed to action create a new text item 42 if(!FreeItems.textOnlyAttachedToCursor()) { 43 url = NetworkSettings.HomePage.get(); // use home page specified by settings 44 text = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(), 45 "Web Browser Session", null); 46 text.setParent(DisplayIO.getCurrentFrame()); 47 FrameMouseActions.pickup(text); 48 } else { 49 url = text.getText(); // get url from text attached to cursor if possible 50 } 51 52 // Set text to session id. TODO: set session id. 53 text.setText("Web Browser Session"); 41 Item linkToBrowserSession = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(), "Web Browser Session", null); 42 linkToBrowserSession.setParent(DisplayIO.getCurrentFrame()); 43 FrameMouseActions.pickup(linkToBrowserSession); 54 44 55 45 // Create new frame 56 Frame frame = FrameIO.CreateNewFrame(text); 57 text.setLink("" + frame.getNumber()); // link this text item to new frame 46 Frame frame = FrameIO.CreateNewFrame(linkToBrowserSession); 47 48 // link this text item to new frame 49 linkToBrowserSession.setLink("" + frame.getNumber()); 58 50 59 51 // Remove everything from new frame … … 76 68 // Start Browser in fullscreen or default, depending on settings 77 69 if(ExploratorySearchSettings.BrowserFullScreen.get()) { 78 wt = frame.addText( 0 + lm, 70 + tm, "@iw: org.expeditee.items.widgets.JfxBrowser "70 wt = frame.addText(144 + lm, 0 + tm, "@iw: org.expeditee.items.widgets.JfxBrowser " 79 71 + ("--anchorLeft " + lm + " --anchorRight " + rm + " --anchorTop " + (tm + ExploratorySearchSettings.BROWSER_VERT_OFFSET) + " --anchorBottom " + bm + " ") 80 72 + (Browser._theBrowser.getContentPane().getWidth() - lm - rm) + " " … … 82 74 System.err.println(wt.getText()); 83 75 } else { 84 wt = frame.addText( 0 + lm, 70 + tm, "@iw: org.expeditee.items.widgets.JfxBrowser " +76 wt = frame.addText(144 + lm, 0 + tm, "@iw: org.expeditee.items.widgets.JfxBrowser " + 85 77 (ExploratorySearchSettings.BrowserDefaultWidth.get() - lm - rm) + " " + 86 78 (ExploratorySearchSettings.BrowserDefaultHeight.get() - tm - bm) + " : " + url, null); 87 79 } 88 89 // Create widget via text annotation90 InteractiveWidget.createWidget(wt);91 80 92 81 FrameIO.SaveFrame(frame); // save frame to disk
Note:
See TracChangeset
for help on using the changeset viewer.