Changeset 544
- Timestamp:
- 11/27/13 15:29:04 (10 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameUtils.java
r542 r544 709 709 } else if (attribute.equals("proxy")) { 710 710 proxySetup(item); 711 } else if (attribute.equals("settings")) { 712 generalSetup(item); 711 713 } else if (attribute.equals("fillcolorwheel")) { 712 714 Item.FILL_COLOR_WHEEL = getColorWheel(item); … … 736 738 return errors; 737 739 } 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 } 738 773 739 774 /** … … 748 783 for(Item config : child.getAllItems()) { 749 784 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:")) { 752 788 if(host != null) { 753 789 MessageBay.displayMessage("host was defined multiple times!", Color.ORANGE); 754 790 } 755 791 host = str.substring(5).trim(); 756 } else if(str .startsWith("port:")) {792 } else if(strLower.startsWith("port:")) { 757 793 if(port!= null) { 758 794 MessageBay.displayMessage("port was defined multiple times!", Color.ORANGE); 759 795 } 760 796 port = str.substring(5).trim(); 761 } else if(str .startsWith("user:")) {797 } else if(strLower.startsWith("user:")) { 762 798 if(user != null) { 763 799 MessageBay.displayMessage("user was defined multiple times!", Color.ORANGE); 764 800 } 765 801 user = str.substring(6).trim(); 766 } else if(str .startsWith("pass:")) { // unencrypted password802 } else if(strLower.startsWith("pass:")) { // unencrypted password 767 803 if(pass != null) { 768 804 MessageBay.displayMessage("pass was defined multiple times!", Color.ORANGE); 769 805 } 770 806 pass = str.substring(6).trim(); 771 } else if(str .startsWith("@iw:")) { // widget807 } else if(strLower.startsWith("@iw:")) { // widget 772 808 // 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")) { 774 810 if(passwordWidget == null) { 775 811 try { -
trunk/src/org/expeditee/gui/UserSettings.java
r504 r544 70 70 71 71 public static Text StatTemplate = null; 72 73 // The URL to prepend to web searches 74 public static final String defaultSearchEngine = "https://duckduckgo.com/?q="; 75 public static String searchEngine = defaultSearchEngine; 72 76 73 77 // add default values -
trunk/src/org/expeditee/items/widgets/JfxBrowser.java
r543 r544 19 19 import org.expeditee.gui.FreeItems; 20 20 import org.expeditee.gui.MessageBay; 21 import org.expeditee.gui.UserSettings; 21 22 import org.expeditee.items.Text; 22 23 … … 292 293 // TODO: can/should we support other protocols such as ftp ??? 293 294 if(!(textLower.startsWith("http://") || text.startsWith("https://"))) { 294 // check if it's a search (will be a search if there is a ' ' before the first '.') 295 // TODO: maybe support changing the default search engine (using a settings frame like the proxy settings frame) 295 // check if it's a search 296 296 int firstSpace = text.indexOf(" "); 297 297 int firstDot = text.indexOf("."); 298 if(firstSpace != -1 && firstSpace < firstDot) { 298 int firstSlash = text.indexOf('/'); 299 int firstQuestion = text.indexOf('?'); 300 if(firstDot == -1 || // no '.' and no protocol -> search 301 (firstSpace != -1 && firstSpace <= firstDot + 1) || // ' ' before '.' -> search 302 (firstSlash == -1 && firstQuestion == -1)) { // no '/' or '?' -> search 299 303 // make it a search 300 text = "https://duckduckgo.com/?q="+ text;304 text = UserSettings.searchEngine + text; 301 305 } else { 302 306 // add the missing protocol
Note:
See TracChangeset
for help on using the changeset viewer.