Changeset 748 for trunk/src/org/expeditee/actions
- Timestamp:
- 01/24/14 11:32:31 (10 years ago)
- Location:
- trunk/src/org/expeditee/actions
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Misc.java
r722 r748 4 4 import java.awt.Desktop; 5 5 import java.awt.Image; 6 import java.awt.Polygon;7 6 import java.awt.image.BufferedImage; 8 7 import java.awt.image.VolatileImage; … … 23 22 24 23 import javax.imageio.ImageIO; 25 import javax.script.ScriptEngine;26 import javax.script.ScriptEngineManager;27 import javax.script.ScriptException;28 24 29 25 import org.expeditee.gui.AttributeUtils; … … 42 38 import org.expeditee.gui.TimeKeeper; 43 39 import org.expeditee.importer.FrameDNDTransferHandler; 44 import org.expeditee.io.WebParser;45 import org.expeditee.io.flowlayout.XGroupItem;46 40 import org.expeditee.items.Item; 47 41 import org.expeditee.items.ItemUtils; … … 50 44 import org.expeditee.items.XRayable; 51 45 import org.expeditee.items.widgets.InteractiveWidget; 52 import org.expeditee.items.widgets.JfxBrowser;53 46 import org.expeditee.items.widgets.WidgetCorner; 54 47 import org.expeditee.items.widgets.WidgetEdge; 55 48 import org.expeditee.math.ExpediteeJEP; 56 import org.expeditee.settings.Settings;57 49 import org.expeditee.settings.UserSettings; 58 import org.expeditee.settings.network.NetworkSettings;59 50 import org.expeditee.simple.SString; 60 51 import org.expeditee.stats.CometStats; … … 1111 1102 } 1112 1103 1113 /**1114 * Launches items.widgets.JfxBrowser and uses Text item as URL.1115 * Note: currently doesn't work1116 * @param text Text item which passes contents as URL for browser.1117 * @throws Exception1118 */1119 public static void startBrowser(Item text) throws Exception {1120 if (!(text instanceof Text)) {1121 MessageBay.errorMessage("Must be a text item.");1122 return;1123 }1124 if(text.getLink() != null) {1125 MessageBay.errorMessage("Text item cannot have link.");1126 return;1127 }1128 1129 Text wt = new Text("@iw:org.expeditee.items.widgets.JfxBrowser"); // create new text item for browser widget1130 1131 if(FreeItems.textOnlyAttachedToCursor()) { // navigates to url specified by the text item1132 wt.appendText(":" + text.getText());1133 } else {1134 wt.appendText(":http://www.waikato.ac.nz");1135 }1136 1137 FreeItems.getInstance().clear(); // remove url text from cursor1138 1139 wt.setParent(DisplayIO.getCurrentFrame()); // set parent of text source for InteractiveWidget.createWidget()1140 wt.setXY(FrameMouseActions.getX(), FrameMouseActions.getY());1141 // create widget from text item1142 JfxBrowser browser = (JfxBrowser) InteractiveWidget.createWidget(wt);1143 1144 FrameMouseActions.pickup(browser.getItems()); // attach browser widget to mouse1145 }1146 1147 /**1148 * Text item becomes link to new frame containing items.widgets.JfxBrowser and uses Text item as URL for browser.1149 * Note: currently doesn't work1150 * @param text Text item which passes contents as URL for browser and becomes link to the browser's new frame.1151 * @throws Exception1152 */1153 public static void startBrowserNewFrame(Item text) throws Exception {1154 if (!(text instanceof Text)) {1155 MessageBay.errorMessage("Must be a text item.");1156 return;1157 }1158 if(text.getLink() != null) { // text item can't already have a link1159 MessageBay.errorMessage("Text item already has link.");1160 return;1161 }1162 1163 // If no text with url is passed to action create a new text item with http://www.waikato.ac.nz for a default url1164 if(!FreeItems.textOnlyAttachedToCursor()) {1165 text = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(),1166 NetworkSettings.HomePage.get(), null);1167 text.setParent(DisplayIO.getCurrentFrame()); // set parent of text source for InteractiveWidget.createWidget()1168 FrameMouseActions.pickup(text); // Attach new text link to cursor1169 }1170 1171 // Create JfxBrowser widget on a new frame1172 Frame frame = FrameIO.CreateNewFrame(text); // create new frame for browser1173 text.setLink("" + frame.getNumber()); // link this text item to new frame1174 // Create widget via text annotation1175 Text wt = frame.addText(0, JfxBrowser.VERT_OFFSET, "@iw: org.expeditee.items.widgets.JfxBrowser "+ (Browser._theBrowser.getWidth() - JfxBrowser.HORZ_CROP)+1176 " " + (Browser._theBrowser.getHeight() - JfxBrowser.VERT_CROP) + " : ".concat(text.getText()), null);1177 InteractiveWidget.createWidget(wt);1178 1179 FrameIO.SaveFrame(frame); // save frame to disk1180 }1181 1182 1104 private static boolean startWidget(String name) throws Exception { 1183 1105 String fullName = Actions.getClassName(name); … … 1245 1167 } 1246 1168 1247 public static void parsePage(Item text) throws Exception {1248 if (!(text instanceof Text) || !FreeItems.textOnlyAttachedToCursor()) {1249 MessageBay.errorMessage("Must provide a text item.");1250 return;1251 }1252 if(text.getLink() != null) { // text item can't already have a link1253 MessageBay.errorMessage("Text item already has link.");1254 return;1255 }1256 1257 // Create JfxBrowser widget on a new frame1258 Frame frame = FrameIO.CreateNewFrame(text); // create new frame for browser1259 text.setLink("" + frame.getNumber()); // link this text item to new frame1260 frame.addText(100, 100, "test", null);1261 1262 WebParser.parseURL(text.getText(), frame);1263 System.out.println(text.getText());1264 }1265 1266 1169 /** 1267 1170 * Rebuilds the home frame restoring its original presentation. … … 1274 1177 FrameUtils.CreateDefaultProfile(UserSettings.UserName.get(), homeFrame); 1275 1178 } 1276 1277 /** 1278 * Adds a text item to the cursor which is linked to a new frame with the web browser active overlay and a JavaFX browser. 1279 * @param text The text item attached to the cursor. 1280 */ 1281 public static void startBrowserSession(Text text) { 1282 try { 1283 if (!(text instanceof Text)) { 1284 MessageBay.errorMessage("Must be a text item."); 1285 return; 1286 } 1287 1288 if(text.getLink() != null) { // text item can't already have a link 1289 MessageBay.errorMessage("Text item already has link."); 1290 return; 1291 } 1292 1293 String url = ""; 1294 1295 // If no text with url is passed to action create a new text item 1296 if(!FreeItems.textOnlyAttachedToCursor()) { 1297 url = NetworkSettings.HomePage.get(); // use home page specified by settings 1298 text = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(), 1299 "Web Browser Session", null); 1300 text.setParent(DisplayIO.getCurrentFrame()); 1301 FrameMouseActions.pickup(text); 1302 } else { 1303 url = text.getText(); // get url from text attached to cursor if possible 1304 } 1305 1306 // Set text to session id. TODO: set session id. 1307 text.setText("Web Browser Session"); 1308 1309 // Create new frame 1310 Frame frame = FrameIO.CreateNewFrame(text); 1311 text.setLink("" + frame.getNumber()); // link this text item to new frame 1312 1313 // Remove everything from new page 1314 frame.removeAllItems(frame.getItems()); 1315 1316 // Add web browser active overlay 1317 frame.addText(1100, 50, "@ao: 2", null, "overlayset2"); 1318 // Add @old 1319 frame.addText(1100, 20, "@old", null); 1320 1321 // Create widget via text annotation 1322 Text wt = frame.addText(0, 80, "@iw: org.expeditee.items.widgets.JfxBrowser "+ (Browser._theBrowser.getWidth() - JfxBrowser.HORZ_CROP)+ 1323 " " + (Browser._theBrowser.getHeight() - JfxBrowser.VERT_CROP) + " : ".concat(url), null); 1324 InteractiveWidget.createWidget(wt); 1325 1326 FrameIO.SaveFrame(frame); // save frame to disk 1327 } catch(Exception e) { 1328 e.printStackTrace(); 1329 } 1330 } 1331 1179 1332 1180 /** 1333 1181 * Adds a text item to the cursor which is linked to a new frame with the mindmap active overlay. … … 1463 1311 } 1464 1312 1465 public static void gotoURL(Text link, String URL) {1466 Frame frame = FrameIO.CreateNewFrame(link);1467 link.setAction(null);1468 link.setLink("" + frame.getNumber());1469 1470 WebParser.parseURL(URL, frame);1471 1472 frame.change();1473 1474 FrameIO.SaveFrame(frame);1475 }1476 1477 1313 public static void testProgress() { 1478 1314 new Thread(new Runnable() {
Note:
See TracChangeset
for help on using the changeset viewer.