Changeset 996 for trunk/src


Ignore:
Timestamp:
02/05/16 09:31:23 (8 years ago)
Author:
davidb
Message:

Added new version of Misc which contains open URL and Font Wheel and Restore functions

File:
1 edited

Legend:

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

    r978 r996  
    3030import java.io.InputStreamReader;
    3131import java.lang.reflect.Method;
     32import java.net.URI;
     33import java.net.URISyntaxException;
    3234import java.net.URL;
    3335import java.net.URLClassLoader;
     
    3638import java.util.LinkedList;
    3739import java.util.List;
     40import java.util.Map;
     41import java.util.Map.Entry;
     42import java.util.Set;
    3843import java.util.jar.Attributes;
    3944import java.util.jar.JarFile;
     
    7580import org.nfunk.jep.ParseException;
    7681
     82import com.lowagie.text.Font;
     83
    7784
    7885
     
    138145        }
    139146       
     147        public static void openURL(Item item){
     148               
     149                if(item.getData() != null && item.getData().size() > 0){
     150                       
     151                        String url = item.getData().get(0);
     152                        openURL(url);
     153                }
     154               
     155                //openURL("http://www.google.com");
     156        }
     157        /**
     158         * Treats a string as a URL and attempts to open it
     159         */
     160        public static void openURL(String siteURL){
     161               
     162                try {
     163                        URL check = new URL(siteURL);                   
     164                        Desktop.getDesktop().browse(new URI(siteURL));
     165                       
     166                } catch (IOException| URISyntaxException e) {
     167               
     168                        MessageBay.displayMessage("'" + siteURL + "' is not a valid URL");
     169                }               
     170        }
     171        /**
     172         * Backs up the current frame as a default and saves it to the file
     173         */
     174        public static void setRestorePoint()
     175        {
     176                Frame current = DisplayIO.getCurrentFrame();
     177                current.change();
     178                FrameIO.SaveFrameAsRestore(current, true, true);               
     179        }
    140180        /**
    141181         * Forces a repaint of the current Frame
     
    437477                fontsList.deleteCharAt(fontsList.length() - 1);
    438478
     479                return fontsList.toString();
     480        }
     481        /**
     482         * Creates a new Text Object containing the available fonts already loaded into Expeditee.
     483         */
     484        public static String getExpediteeFontNames(){
     485               
     486                StringBuilder fontsList = new StringBuilder();
     487               
     488                for (String s: Text.FONT_WHEEL){
     489                                               
     490                        fontsList.append(s).append(Text.LINE_SEPARATOR);                       
     491                }
     492
     493                for (Entry<String, java.awt.Font> entry: Text.FONT_WHEEL_ADDITIONAL_LOOKUP.entrySet()){
     494                       
     495                        String fontName = entry.getKey();
     496                        fontsList.append(fontName).append(Text.LINE_SEPARATOR);                 
     497                }
     498                //add the default soon too
     499                fontsList.deleteCharAt(fontsList.length() - 1);
    439500                return fontsList.toString();
    440501        }
Note: See TracChangeset for help on using the changeset viewer.