Ignore:
Timestamp:
01/24/14 11:32:31 (10 years ago)
Author:
ngw8
Message:

Changed JFX files to no longer use reflection (as some new features were impossible via reflection) and just import javafx instead. This will probably cause Eclipse to complain if you're using a Java version <= 7, but building/running Expeditee will still work (using Eclipse or Ant).
Have also added an Ant target that builds without ant JFX stuff. See the comments near the top of JfxBrowser.java or WebParser.java for details

Location:
trunk/src/org/expeditee/actions
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Misc.java

    r722 r748  
    44import java.awt.Desktop;
    55import java.awt.Image;
    6 import java.awt.Polygon;
    76import java.awt.image.BufferedImage;
    87import java.awt.image.VolatileImage;
     
    2322
    2423import javax.imageio.ImageIO;
    25 import javax.script.ScriptEngine;
    26 import javax.script.ScriptEngineManager;
    27 import javax.script.ScriptException;
    2824
    2925import org.expeditee.gui.AttributeUtils;
     
    4238import org.expeditee.gui.TimeKeeper;
    4339import org.expeditee.importer.FrameDNDTransferHandler;
    44 import org.expeditee.io.WebParser;
    45 import org.expeditee.io.flowlayout.XGroupItem;
    4640import org.expeditee.items.Item;
    4741import org.expeditee.items.ItemUtils;
     
    5044import org.expeditee.items.XRayable;
    5145import org.expeditee.items.widgets.InteractiveWidget;
    52 import org.expeditee.items.widgets.JfxBrowser;
    5346import org.expeditee.items.widgets.WidgetCorner;
    5447import org.expeditee.items.widgets.WidgetEdge;
    5548import org.expeditee.math.ExpediteeJEP;
    56 import org.expeditee.settings.Settings;
    5749import org.expeditee.settings.UserSettings;
    58 import org.expeditee.settings.network.NetworkSettings;
    5950import org.expeditee.simple.SString;
    6051import org.expeditee.stats.CometStats;
     
    11111102        }
    11121103       
    1113         /**
    1114          * Launches items.widgets.JfxBrowser and uses Text item as URL.
    1115          * Note: currently doesn't work
    1116          * @param text Text item which passes contents as URL for browser.
    1117          * @throws Exception
    1118          */
    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 widget
    1130                
    1131                 if(FreeItems.textOnlyAttachedToCursor()) {                      // navigates to url specified by the text item
    1132                         wt.appendText(":" + text.getText());
    1133                 } else {
    1134                         wt.appendText(":http://www.waikato.ac.nz");
    1135                 }
    1136                
    1137                 FreeItems.getInstance().clear();                                        // remove url text from cursor
    1138                
    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 item
    1142                 JfxBrowser browser = (JfxBrowser) InteractiveWidget.createWidget(wt);
    1143                        
    1144                 FrameMouseActions.pickup(browser.getItems());           // attach browser widget to mouse
    1145         }
    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 work
    1150          * @param text Text item which passes contents as URL for browser and becomes link to the browser's new frame.
    1151          * @throws Exception
    1152          */
    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 link
    1159                         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 url
    1164                 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 cursor
    1169                 }
    1170                
    1171                 // Create JfxBrowser widget on a new frame
    1172                 Frame frame = FrameIO.CreateNewFrame(text);                     // create new frame for browser
    1173                 text.setLink("" + frame.getNumber());                           // link this text item to new frame
    1174                 // Create widget via text annotation
    1175                 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 disk
    1180         }
    1181        
    11821104        private static boolean startWidget(String name) throws Exception {
    11831105                String fullName = Actions.getClassName(name);
     
    12451167        }
    12461168       
    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 link
    1253                         MessageBay.errorMessage("Text item already has link.");
    1254                         return;
    1255                 }
    1256                
    1257                 // Create JfxBrowser widget on a new frame
    1258                 Frame frame = FrameIO.CreateNewFrame(text);                     // create new frame for browser
    1259                 text.setLink("" + frame.getNumber());                           // link this text item to new frame
    1260                 frame.addText(100, 100, "test", null);
    1261                
    1262                 WebParser.parseURL(text.getText(), frame);
    1263                 System.out.println(text.getText());
    1264         }
    1265        
    12661169        /**
    12671170         * Rebuilds the home frame restoring its original presentation.
     
    12741177                FrameUtils.CreateDefaultProfile(UserSettings.UserName.get(), homeFrame);
    12751178        }
    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
    13321180        /**
    13331181         * Adds a text item to the cursor which is linked to a new frame with the mindmap active overlay.
     
    14631311        }
    14641312       
    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        
    14771313        public static void testProgress() {
    14781314                new Thread(new Runnable() {
Note: See TracChangeset for help on using the changeset viewer.