Ignore:
Timestamp:
11/27/13 15:29:04 (11 years ago)
Author:
jts21
Message:

Updated JfxBrowser to use search engine variable, and also fixed some logic errors in it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r542 r544  
    709709                                } else if (attribute.equals("proxy")) {
    710710                                        proxySetup(item);
     711                                } else if (attribute.equals("settings")) {
     712                                        generalSetup(item);
    711713                                } else if (attribute.equals("fillcolorwheel")) {
    712714                                        Item.FILL_COLOR_WHEEL = getColorWheel(item);
     
    736738                return errors;
    737739        }
     740       
     741        /**
     742         * Loads general config from a frame
     743         * @author jts21
     744         */
     745        private static void generalSetup(Item item) {
     746                try {
     747                        Frame child = item.getChild();
     748                        String str, strLower;
     749                        String searchEngine = "";
     750                        // gather all the settings
     751                        for(Item config : child.getAllItems()) {
     752                                if(config instanceof Text) {
     753                                        str = config.getText().trim();
     754                                        strLower = str.toLowerCase();
     755                                        if(strLower.startsWith("searchengine:")) {
     756                                                searchEngine = str.substring(13).trim();
     757                                        }
     758                                }
     759                        }
     760                        // set all the settings to their defined values or their defaults
     761                        if(searchEngine.length() == 0 || searchEngine.toLowerCase().equals("default")) {
     762                                UserSettings.searchEngine = UserSettings.defaultSearchEngine;
     763                                MessageBay.displayMessage("Defaulted search engine to " + UserSettings.searchEngine);
     764                        } else {
     765                                UserSettings.searchEngine = searchEngine;
     766                                MessageBay.displayMessage("Set search engine to " + UserSettings.searchEngine);
     767                        }
     768                } catch(Exception e) {
     769                        System.err.println("Failed to load config");
     770                        e.printStackTrace();
     771                }
     772        }
    738773
    739774        /**
     
    748783                        for(Item config : child.getAllItems()) {
    749784                                if(config instanceof Text) {
    750                                         String str = config.getText().trim().toLowerCase();
    751                                         if(str.startsWith("host:")) {
     785                                        String str = config.getText().trim();
     786                                        String strLower = str.toLowerCase();
     787                                        if(strLower.startsWith("host:")) {
    752788                                                if(host != null) {
    753789                                                        MessageBay.displayMessage("host was defined multiple times!", Color.ORANGE);
    754790                                                }
    755791                                                host = str.substring(5).trim();
    756                                         } else if(str.startsWith("port:")) {
     792                                        } else if(strLower.startsWith("port:")) {
    757793                                                if(port!= null) {
    758794                                                        MessageBay.displayMessage("port was defined multiple times!", Color.ORANGE);
    759795                                                }
    760796                                                port = str.substring(5).trim();
    761                                         } else if(str.startsWith("user:")) {
     797                                        } else if(strLower.startsWith("user:")) {
    762798                                                if(user != null) {
    763799                                                        MessageBay.displayMessage("user was defined multiple times!", Color.ORANGE);
    764800                                                }
    765801                                                user = str.substring(6).trim();
    766                                         } else if(str.startsWith("pass:")) {    // unencrypted password
     802                                        } else if(strLower.startsWith("pass:")) {       // unencrypted password
    767803                                                if(pass != null) {
    768804                                                        MessageBay.displayMessage("pass was defined multiple times!", Color.ORANGE);
    769805                                                }
    770806                                                pass = str.substring(6).trim();
    771                                         } else if(str.startsWith("@iw:")) {             // widget
     807                                        } else if(strLower.startsWith("@iw:")) {                // widget
    772808                                                // check if it's a password widget
    773                                                 if(str.substring(4).trim().startsWith("org.expeditee.items.widgets.password")) {
     809                                                if(strLower.substring(4).trim().startsWith("org.expeditee.items.widgets.password")) {
    774810                                                        if(passwordWidget == null) {
    775811                                                                try {
Note: See TracChangeset for help on using the changeset viewer.