Changeset 504
- Timestamp:
- 11/19/13 12:01:52 (11 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 4 added
- 11 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r492 r504 106 106 final ArrayList<Class<?>> classes = new ArrayList<Class<?>>(); 107 107 108 String realPackageName = packageName; 108 109 packageName = packageName.replace(".", "/"); 109 110 URL packageURL = classLoader.getResource(packageName); … … 162 163 163 164 for (File actual: contenuti) { 164 String entryName = actual.getName();165 String entryName = realPackageName + actual.getName(); 165 166 166 167 if (entryName.endsWith(".class") && !entryName.contains("$")) { 167 168 entryName = entryName.substring(0, entryName.lastIndexOf('.')); 169 entryName.replace('/', '.'); 168 170 169 171 names.add(entryName); -
trunk/src/org/expeditee/actions/Misc.java
r464 r504 12 12 import java.util.ArrayList; 13 13 import java.util.Collection; 14 import java.util.HashMap;15 14 import java.util.LinkedList; 16 15 import java.util.List; 17 import java.util.Set;18 16 19 17 import javax.imageio.ImageIO; 20 21 import org.expeditee.actions.Simple;22 18 23 19 import org.expeditee.gui.AttributeUtils; … … 28 24 import org.expeditee.gui.FrameIO; 29 25 import org.expeditee.gui.FrameMouseActions; 30 import org.expeditee.gui.FrameUtils;31 26 import org.expeditee.gui.MessageBay; 32 27 import org.expeditee.gui.Reminders; 33 28 import org.expeditee.gui.TimeKeeper; 34 29 import org.expeditee.importer.FrameDNDTransferHandler; 35 import org.expeditee.io.FrameReader;36 30 import org.expeditee.items.Item; 37 38 31 import org.expeditee.items.ItemUtils; 39 32 import org.expeditee.items.Line; 40 33 import org.expeditee.items.Text; 41 42 34 import org.expeditee.math.ExpediteeJEP; 43 35 import org.expeditee.simple.SString; -
trunk/src/org/expeditee/gui/Browser.java
r467 r504 30 30 import org.expeditee.agents.mail.MailSession; 31 31 import org.expeditee.importer.FrameDNDTransferHandler; 32 import org.expeditee.io.ItemSelection; 32 33 import org.expeditee.items.Item; 33 34 import org.expeditee.items.widgets.WidgetCacheManager; … … 397 398 398 399 public void windowDeactivated(WindowEvent e) { 400 ItemSelection.cut(FreeItems.getInstance()); 399 401 } 400 402 -
trunk/src/org/expeditee/gui/FrameIO.java
r454 r504 58 58 IMAGES_PATH = PARENT_FOLDER + IMAGES_FOLDER; 59 59 HELP_PATH = PARENT_FOLDER + "documentation" + File.separator; 60 DICT_PATH = PARENT_FOLDER + "dict" + File.separator; 60 61 PROFILE_PATH = PARENT_FOLDER + "profiles" + File.separator; 61 62 EXPORTS_DIR = PARENT_FOLDER + "exports" + File.separator; … … 83 84 84 85 public static String HELP_PATH; 86 87 public static String DICT_PATH; 85 88 86 89 public static String PROFILE_PATH; -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r454 r504 22 22 import org.expeditee.actions.Navigation; 23 23 import org.expeditee.actions.Simple; 24 import org.expeditee.io.ItemSelection; 24 25 import org.expeditee.items.Circle; 25 26 import org.expeditee.items.Dot; … … 586 587 } 587 588 588 /**589 * Used to add items to a frame when pasting text from the clipboard.590 *591 * @param text592 * the next paragraph of text to be pasted.593 * @param lastItem594 * the item to drop from when pasting the next paragraph of text.595 * @return the new text item created from pasting the text.596 */597 private static Item addTextItemToCurrentFrame(String text, Item lastItem,598 boolean bDrop) {599 if (text.trim().length() > 0) {600 if (lastItem != null && bDrop)601 Drop(lastItem, true);602 603 Text textItem = createText();604 textItem.setText(text.substring(0, text.length() - 1));605 606 if (lastItem != null && !bDrop) {607 textItem.setY(lastItem.getY() + lastItem.getBoundsHeight());608 } else {609 textItem.setY(FrameMouseActions.getY());610 }611 textItem.setX(FrameMouseActions.getX());612 textItem.justify(false);613 DisplayIO.getCurrentFrame().addItem(textItem);614 return textItem;615 }616 return lastItem;617 }618 619 589 private static void copyItemToClipboard(Item on) { 620 590 if (on == null || !(on instanceof Text)) … … 797 767 break; 798 768 case KeyEvent.VK_V: 799 try { 800 // read in the data from the clipboard 801 String clip = ((String) Toolkit.getDefaultToolkit() 802 .getSystemClipboard().getContents(null) 803 .getTransferData(DataFlavor.stringFlavor)); 804 // Covert the line separator char when pasting in 805 // windows (\r\n) or max (\r) 806 clip = StringUtils.convertNewLineChars(clip); 807 808 Item clicked = FrameUtils.getCurrentItem(); 809 810 if (clicked != null) { 811 // check permissions 812 if (!clicked.hasPermission(UserAppliedPermission.full) 813 && clicked.getParent() != null 814 && clicked.getParent().getNameItem() != clicked) { 815 MessageBay.displayMessage("Insufficient Permission"); 816 return; 817 } 818 819 Text text = createText(); 820 text.setText(clip); 821 List<Item> clipboard = new ArrayList<Item>(); 822 clipboard.add(text); 823 FrameMouseActions.merge(clipboard, clicked); 824 text.delete(); 825 } else { 826 StringTokenizer st = new StringTokenizer(clip, "\n", true); 827 828 String temp = ""; 829 // int y = FrameMouseActions.getY(); 830 Item lastItem = null; 831 832 boolean drop = currentFrame.hasAnnotation("next"); 833 // separate the clipboard content into items based on 834 // blank lines 835 while (st.hasMoreTokens()) { 836 String s = st.nextToken(); 837 // if this is a blank line, then it is an item separator 838 if (s.trim().length() == 0) { 839 lastItem = addTextItemToCurrentFrame(temp, 840 lastItem, drop); 841 temp = ""; 842 } else { 843 temp += s + "\n"; 844 if (st.hasMoreTokens()) 845 st.nextToken(); 846 } 847 } 848 // the last item will not be finished by the above loop 849 addTextItemToCurrentFrame(temp, lastItem, drop); 850 FrameIO.ForceSaveFrame(DisplayIO.getCurrentFrame()); 851 DisplayIO.setCurrentFrame(currentFrame, false); 852 } 853 } catch (Exception ex) { 854 } 855 // if this is a copy command 856 break; 769 ItemSelection.paste(); 770 return; 857 771 case KeyEvent.VK_C: 858 if (current == null) 772 if(FreeItems.itemsAttachedToCursor()) { 773 ItemSelection.copyClone(FreeItems.getInstance()); 859 774 return; 860 861 if (current instanceof Text) { 862 if (current != null && !current.hasPermission(UserAppliedPermission.copy)) { 863 MessageBay 864 .displayMessage("Insufficient permission to copy that item"); 865 return; 866 } 775 } 776 if(current instanceof Text) { 867 777 copyItemToClipboard(current); 868 // MessageBay.displayMessage("Item copied to clipboard");869 return;870 }871 if (current != null && !current.hasPermission(UserAppliedPermission.full)) {872 MessageBay873 .displayMessage("Insufficient permission edit that item");874 return;875 778 } 876 779 Text item = null; … … 895 798 return; 896 799 case KeyEvent.VK_X: 897 if (current == null) 898 return; 899 if (current != null && !current.hasPermission(UserAppliedPermission.full)) { 900 MessageBay 901 .displayMessage("Insufficient permission to cut that item"); 902 return; 903 } 904 copyItemToClipboard(current); 905 if (current instanceof Text && ((Text) current).hasSelection()) { 906 ((Text) current).cutSelectedText(); 907 ((Text) current).clearSelection(); 908 } else { 909 FrameMouseActions.delete(current); 910 } 800 ItemSelection.cut(FreeItems.getInstance()); 911 801 return; 912 802 case KeyEvent.VK_M: -
trunk/src/org/expeditee/gui/FrameUtils.java
r454 r504 6 6 import java.awt.Rectangle; 7 7 import java.io.File; 8 import java.io.FileInputStream; 8 9 import java.io.FileNotFoundException; 10 import java.io.FileOutputStream; 9 11 import java.io.IOException; 12 import java.io.InputStream; 13 import java.net.JarURLConnection; 14 import java.net.URL; 10 15 import java.util.ArrayList; 16 import java.util.Arrays; 11 17 import java.util.Collection; 12 18 import java.util.Collections; 13 19 import java.util.Comparator; 20 import java.util.Enumeration; 14 21 import java.util.LinkedHashSet; 15 22 import java.util.LinkedList; 16 23 import java.util.List; 24 import java.util.jar.JarEntry; 25 import java.util.jar.JarFile; 26 import java.util.zip.ZipEntry; 17 27 18 28 import org.expeditee.agents.SearchGreenstone; … … 28 38 import org.expeditee.items.Line; 29 39 import org.expeditee.items.PermissionPair; 30 import org.expeditee.items.UserAppliedPermission;31 40 import org.expeditee.items.Picture; 32 41 import org.expeditee.items.Text; 42 import org.expeditee.items.UserAppliedPermission; 33 43 import org.expeditee.items.XRayable; 34 44 import org.expeditee.items.widgets.InteractiveWidget; … … 1516 1526 yPos = intialYPos + spacing; 1517 1527 1518 // Iterate through the help folder and add links 1528 // Load documentation 1529 extractDocumentation(); 1530 1531 // Add documentation links 1519 1532 File helpDirectory = new File(FrameIO.HELP_PATH); 1520 1533 if (helpDirectory != null) { … … 1661 1674 } 1662 1675 } 1676 1677 private static void extractDocumentation() { 1678 try { 1679 ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 1680 URL docURL = classLoader.getResource("org/expeditee/resources"); 1681 1682 String path; 1683 String classPath; 1684 1685 // copy files from the jar file to the profile folder 1686 if (docURL.getProtocol().equals("jar")) { 1687 JarURLConnection ju_connection=(JarURLConnection)docURL.openConnection(); 1688 JarFile jf =ju_connection.getJarFile(); 1689 Enumeration<JarEntry> jarEntries = jf.entries(); 1690 1691 ZipEntry ze; 1692 1693 while(jarEntries.hasMoreElements()) { 1694 ze = jarEntries.nextElement(); 1695 if(!(ze.getName().startsWith("org/expeditee/resources/documentation") || ze.getName().startsWith("org/expeditee/resources/dict"))) { 1696 continue; 1697 } 1698 // NOTE: assumes HELP_PATH is "${PARENT_FOLDER}/documentation/" and DICT_PATH is "${PARENT_FOLDER}/dict/" 1699 File out = new File(FrameIO.PARENT_FOLDER + ze.getName().substring("org/expeditee/resources/".length())); 1700 // System.out.println("Didn't crash here " + out.getPath()); 1701 if(out.exists()) { 1702 continue; 1703 } 1704 if(ze.isDirectory()) { 1705 // System.out.println(out.getPath() + " IS DIRECTORY"); 1706 out.mkdirs(); 1707 continue; 1708 } 1709 FileOutputStream fOut = null; 1710 InputStream fIn = null; 1711 try { 1712 // System.out.println(out.getPath()); 1713 fOut = new FileOutputStream(out); 1714 fIn = classLoader.getResourceAsStream(ze.getName()); 1715 byte[] bBuffer = new byte[1024]; 1716 int nLen; 1717 while ((nLen = fIn.read(bBuffer)) > 0) { 1718 fOut.write(bBuffer, 0, nLen); 1719 } 1720 fOut.flush(); 1721 } catch (Exception e) { 1722 e.printStackTrace(); 1723 } finally { 1724 if(fOut != null) { 1725 fOut.close(); 1726 } 1727 if(fIn != null) { 1728 fIn.close(); 1729 } 1730 } 1731 } 1732 1733 // Copy files from the source folder to the profile folder 1734 } else { 1735 File folder = new File(docURL.toURI().getPath()); 1736 LinkedList<File> items = new LinkedList<File>(); 1737 items.addAll(Arrays.asList(folder.listFiles())); 1738 LinkedList<File> files = new LinkedList<File>(); 1739 while (items.size() > 0) { 1740 File file = items.remove(0); 1741 if(file.isFile()) { 1742 if(!file.getName().contains(".svn")) { 1743 files.add(file); 1744 } 1745 } else { 1746 if (!file.getName().contains(".svn")) { 1747 items.addAll(Arrays.asList(file.listFiles())); 1748 } 1749 } 1750 } 1751 for (File file : files) { 1752 if(file.getPath().contains("org/expeditee/resources/documentation")) { 1753 path = FrameIO.HELP_PATH; 1754 classPath = "org/expeditee/resources/documentation"; 1755 } else if (file.getPath().contains("org/expeditee/resources/dict")) { 1756 path = FrameIO.DICT_PATH; 1757 classPath = "org/expeditee/resources/dict"; 1758 } else { 1759 continue; 1760 } 1761 File out = new File(path + file.getPath().substring(file.getPath().indexOf(classPath) + classPath.length())); 1762 if(out.exists()) { 1763 continue; 1764 } 1765 out.getParentFile().mkdirs(); 1766 FileOutputStream fOut = null; 1767 FileInputStream fIn = null; 1768 try { 1769 // System.out.println(out.getPath()); 1770 fOut = new FileOutputStream(out); 1771 fIn = new FileInputStream(file); 1772 byte[] bBuffer = new byte[1024]; 1773 int nLen; 1774 while ((nLen = fIn.read(bBuffer)) > 0) { 1775 fOut.write(bBuffer, 0, nLen); 1776 } 1777 fOut.flush(); 1778 } catch (Exception e) { 1779 e.printStackTrace(); 1780 } finally { 1781 if(fOut != null) { 1782 fOut.close(); 1783 } 1784 if(fIn != null) { 1785 fIn.close(); 1786 } 1787 } 1788 1789 } 1790 } 1791 } 1792 catch (Exception e) 1793 { 1794 e.printStackTrace(); 1795 } 1796 } 1663 1797 1664 1798 public static Text getLastEdited() { -
trunk/src/org/expeditee/gui/UserSettings.java
r490 r504 74 74 static { 75 75 String expeditee_home = System.getProperty("expeditee.home"); 76 77 76 if (expeditee_home != null) { 78 FrameIO.changeParentFolder(expeditee_home + File.separator); 79 } 80 else { 81 String jarPath = getJarLocation(); 82 83 if (jarPath != null){ 84 FrameIO.changeParentFolder(jarPath); 85 } 86 else { 87 88 FrameIO.changeParentFolder("." + File.separator + "expeditee" 89 + File.separator); 90 } 91 } 92 77 FrameIO.changeParentFolder(expeditee_home + File.separator); 78 } else { 79 FrameIO.changeParentFolder(getSaveLocation()); 80 } 81 93 82 UserSettings.FrameDirs.add(FrameIO.FRAME_PATH); 94 83 UserSettings.FrameDirs.add(FrameIO.PUBLIC_PATH); … … 100 89 101 90 /** 102 * Find where abouts the Jar is located that is running expeditee. The103 * reason for this was so that the framesets could be stored in the same104 * location as the jar file for now. Using the current directory fails to105 * achieve this as the current directory not the same as the directory the106 * jar is stored in if the user double clicks on the jar file in Linux or107 * runs the jar from the command line from another directory.108 * 109 * @return the full path location of the Jar91 * Find the appropriate directory to store application settings in for 92 * the current OS. 93 * This has only been tested on Linux so far, so if it doesn't work it 94 * may need to be modified or reverted. Should return: 95 * Linux: ~/.expeditee 96 * Windows: %appdata%\.expeditee 97 * Mac: ~/Library/Application\ Support/.expeditee 98 * @return the path to store expeditee's settings 110 99 */ 111 public static String getJarLocation() { 112 // Get a File object for the package 113 File directory = null; 114 115 ClassLoader cld = Thread.currentThread().getContextClassLoader(); 116 URL resource = cld.getResource("org"); 117 directory = new File(resource.getFile()); 118 119 int splitPoint = directory.getPath().indexOf('!'); 120 if (splitPoint > 0) { 121 String jarName = directory.getPath().substring("file:".length(), 122 splitPoint); 123 // Windows HACK 124 if (jarName.indexOf(":") >= 0) 125 jarName = jarName.substring(1); 126 127 if (jarName.indexOf("%20") > 0) { 128 jarName = jarName.replace("%20", " "); 129 } 130 131 int lastFileSeparator = jarName.lastIndexOf(File.separator); 132 133 DisplayIO.TITLE = jarName.substring(lastFileSeparator + 1, jarName.length() - 4); 134 135 return jarName.substring(0, lastFileSeparator + 1); 100 public static String getSaveLocation() { 101 String OS=System.getProperty("os.name").toLowerCase(); 102 if(OS.indexOf("win")>0) { //windoze 103 return System.getenv("APPDATA")+File.separator+".expeditee"+File.separator; 104 } else if(OS.indexOf("mac")>0) { //mac 105 return System.getProperty("user.home")+File.separator+"Library"+File.separator+"Application Support"+File.separator+".expeditee"+File.separator; 106 } else { //linux or other 107 return System.getProperty("user.home")+File.separator+".expeditee"+File.separator; 136 108 } 137 return null;138 109 } 139 110 } -
trunk/src/org/expeditee/importer/FrameDNDTransferHandler.java
r270 r504 54 54 // TODO: Image 55 55 _standardFileImporters.add(new ImageImporter()); 56 _standardFileImporters.add(new pdfImporter()); 56 57 _standardFileImporters.add(new TextImporter()); 57 58 _standardFileImporters.add(new FilePathImporter()); // Filepath importer -
trunk/src/org/expeditee/io/ExpReader.java
r427 r504 46 46 * @return true if s begins with a tag 47 47 */ 48 pr ivatestatic boolean isValidLine(String s) {48 protected static boolean isValidLine(String s) { 49 49 return s.length() >= 2 && s.charAt(1) == ' ' 50 50 && Character.isLetter(s.charAt(0)); … … 184 184 * The line of text read in from the file to process. 185 185 */ 186 pr ivatevoid processBodyLine(Item item, String line) {186 protected void processBodyLine(Item item, String line) { 187 187 // separate the tag from the value 188 188 Character tag = getTag(line); … … 203 203 } 204 204 205 pr ivatestatic Character getTag(String line) {205 protected static Character getTag(String line) { 206 206 assert (line.length() > 0); 207 207 return line.charAt(0); 208 208 } 209 209 210 pr ivatestatic String getValue(String line) {210 protected static String getValue(String line) { 211 211 if (line.length() > 2) 212 212 return line.substring(2); … … 250 250 251 251 // Returns a point from a String containing two ints separated by a space 252 pr ivatejava.awt.Point separateValues(String line) {252 protected java.awt.Point separateValues(String line) { 253 253 int x = Integer.parseInt(line.substring(0, line.indexOf(" "))); 254 254 int y = Integer.parseInt(line.substring(line.indexOf(" ") + 1)); -
trunk/src/org/expeditee/io/ExpWriter.java
r362 r504 31 31 private ProxyWriter _writer = null; 32 32 33 pr ivateStringBuilder _stringWriter = null;33 protected StringBuilder _stringWriter = null; 34 34 35 35 private static final char TERMINATOR = 'Z'; … … 130 130 } 131 131 132 pr ivatevoid writeTerminator() throws IOException {132 protected void writeTerminator() throws IOException { 133 133 writeLine(TERMINATOR + "\n"); 134 134 } 135 135 136 136 // writes the given line out to the file 137 pr ivatevoid writeLine(String line) throws IOException {137 protected void writeLine(String line) throws IOException { 138 138 // do not write empty lines 139 139 if (line == null) … … 152 152 return; 153 153 154 writeItemAlways(item); 155 } 156 157 protected void writeItemAlways(Item item) throws IOException { 154 158 if (item.isLineEnd()) 155 159 writeLineEnd(item); … … 173 177 174 178 // writes out all lines to the file 175 pr ivatevoid writeLineData() throws IOException {179 protected void writeLineData() throws IOException { 176 180 List<Line> seen = new LinkedList<Line>(); 177 181 … … 206 210 207 211 // writes out any constraints to the file 208 pr ivatevoid writeConstraintData() throws IOException {212 protected void writeConstraintData() throws IOException { 209 213 // outputs any constraints the points have 210 214 -
trunk/src/org/expeditee/items/Text.java
r475 r504 1321 1321 1322 1322 float y = -1; 1323 1324 synchronized (_textLayouts) { 1325 for (TextLayout layout : _textLayouts) { 1326 Rectangle2D bounds = layout.getLogicalHighlightShape(0, 1327 layout.getCharacterCount()).getBounds2D(); 1328 1329 if (y < 0) 1330 y = 0; 1331 else 1332 y += getLineDrop(layout); 1333 1334 maxX = Math.max(maxX, (int) bounds.getMaxX()); 1335 minX = Math.min(minX, (int) bounds.getMinX()); 1336 maxY = Math.max(maxY, (int) (bounds.getMaxY() + y)); 1337 minY = Math.min(minY, (int) (bounds.getMinY() + y)); 1338 } 1323 1324 // Fix concurrency error in ScaleFrameset 1325 List<TextLayout> tmpTextLayouts; 1326 synchronized(_textLayouts) { 1327 tmpTextLayouts = new LinkedList<TextLayout>(_textLayouts); 1328 } 1329 1330 for (TextLayout layout : tmpTextLayouts) { 1331 Rectangle2D bounds = layout.getLogicalHighlightShape(0, 1332 layout.getCharacterCount()).getBounds2D(); 1333 1334 if (y < 0) 1335 y = 0; 1336 else 1337 y += getLineDrop(layout); 1338 1339 maxX = Math.max(maxX, (int) bounds.getMaxX()); 1340 minX = Math.min(minX, (int) bounds.getMinX()); 1341 maxY = Math.max(maxY, (int) (bounds.getMaxY() + y)); 1342 minY = Math.min(minY, (int) (bounds.getMinY() + y)); 1339 1343 } 1340 1344
Note:
See TracChangeset
for help on using the changeset viewer.