Changeset 126

Show
Ignore:
Timestamp:
08/09/08 22:36:30 (5 months ago)
Author:
mb0
Message:

NEW - # 95: add libraries config
http://axdt.org/ticket/95

simplified implementation. only global setting only for project folders (depth 0). tested with papervision swc and color material example.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • axdt/trunk/org.axdt.as3/src/org/axdt/as3/compiler/AS3CompilerTarget.java

    r92 r126  
    11package org.axdt.as3.compiler; 
     2 
     3import java.util.ArrayList; 
    24 
    35import org.axdt.as3.preferences.AS3Preferences; 
     
    57import org.eclipse.core.resources.IContainer; 
    68import org.eclipse.core.resources.IResource; 
     9import org.eclipse.core.runtime.CoreException; 
    710import org.eclipse.core.runtime.IPath; 
    811 
     
    2225        public IPath[] getSourceLocations() { 
    2326                IContainer[] sourcePaths = AS3Preferences.getSourcePaths(resource); 
    24                 IPath[] paths = new IPath[sourcePaths.length]; 
    25                 for (int i = 0; i < sourcePaths.length; i++) { 
    26                         paths[i] = sourcePaths[i].getLocation(); 
     27                return getResourceLocations(sourcePaths); 
     28        } 
     29 
     30        @Override 
     31        public IPath[] getLibraryLocations() { 
     32                IContainer[] libraryPaths = AS3Preferences.getLibraryPaths(resource); 
     33                ArrayList<IResource> list = new ArrayList<IResource>(); 
     34                for (IContainer lib:libraryPaths) { 
     35                        if (lib != null && lib.exists()) { 
     36                                try { 
     37                                        for (IResource member:lib.members()) { 
     38                                                if ("swc".equals(member.getFileExtension())) { 
     39                                                        list.add(member); 
     40                                                } 
     41                                        } 
     42                                } catch (CoreException e) { 
     43                                        e.printStackTrace(); 
     44                                } 
     45                        } 
    2746                } 
    28                 return paths; 
     47                IResource[] array = list.toArray(new IResource[list.size()]); 
     48                return getResourceLocations(array); 
    2949        } 
    3050} 
  • axdt/trunk/org.axdt.as3/src/org/axdt/as3/preferences/AS3Preferences.java

    r113 r126  
    1212 
    1313        public final static String SOURCE_PATHS = "SOURCE_PATHS"; 
     14        public final static String LIBRARY_PATHS = "LIBRARY_PATHS"; 
    1415        public final static String DEPLOY_PATH = "DEPLOY_PATH"; 
    1516        public final static String TAB_TO_SPACE = "TAB_TO_SPACE"; 
    1617        public final static String TAB_WIDTH = "TAB_WIDTH"; 
    17         public static final String CLOSE_STRINGS = "CLOSE_STRINGS"; 
    18         public static final String CLOSE_BRACKETS = "CLOSE_BRACKETS"; 
    19         public static final String CLOSE_BRACES = "CLOSE_BRACES"; 
     18        public final static String CLOSE_STRINGS = "CLOSE_STRINGS"; 
     19        public final static String CLOSE_BRACKETS = "CLOSE_BRACKETS"; 
     20        public final static String CLOSE_BRACES = "CLOSE_BRACES"; 
    2021        public final static String DELETE_PAIR = "DELETE_PAIR"; 
    2122        public final static String USE_FOLDING = "USE_FOLDING"; 
     
    4647                add(SOURCE_PATHS, "Source &paths", "src"); 
    4748                add(DEPLOY_PATH, "&Deploy path", "deploy"); 
     49                add(LIBRARY_PATHS, "Library &paths", "lib"); 
    4850                add(TAB_TO_SPACE, "Convert &tabs", false); 
    4951                add(TAB_WIDTH, "to number of spa&ces", 4); 
    5052                addGroup("Automatically close", ""); 
    5153                add(CLOSE_STRINGS, "\"&Strings\"", true); 
    52                 add(CLOSE_BRACKETS, "(Parentheses) and [&Brackets]", true); 
     54                add(CLOSE_BRACKETS, "(Parentheses) and [Brac&kets]", true); 
    5355                add(CLOSE_BRACES, "{&Braces} on newline", true); 
    5456                endGroup(); 
     
    8486                return store.getString(AS3Preferences.DEPLOY_PATH); 
    8587        } 
     88 
     89        public static IContainer[] getLibraryPaths(IResource res) { 
     90                IPreferenceStore store = getInstance().getProjectStore(res); 
     91                String sourcePaths = store.getString(AS3Preferences.LIBRARY_PATHS); 
     92                String[] split = sourcePaths.split("[,; ]"); 
     93                IContainer[] paths = new IContainer[split.length]; 
     94                for (int i = 0; i < split.length; i++) { 
     95                        paths[i] = res.getProject().getFolder(split[i]); 
     96                } 
     97                return paths; 
     98        } 
    8699} 
  • axdt/trunk/org.axdt.common/src/org/axdt/compiler/AxdtCompilerTarget.java

    r92 r126  
    3939         * clients should implement this method 
    4040         *  
    41          * @return 
     41         * @return a path to the deploy folder 
    4242         */ 
    4343        public IPath getDeployLocation() { 
     
    4848         * clients should implement this 
    4949         *  
    50          * @return a file array containing all source folder for 
     50         * @return a path array containing all source folders 
    5151         */ 
    5252        public IPath[] getSourceLocations() { 
     
    5454        } 
    5555 
     56        /** 
     57         * clients should implement this 
     58         *  
     59         * @return a path array containing all library folders and files 
     60         */ 
     61        public IPath[] getLibraryLocations() { 
     62                return new IPath[] {getProject().getLocation()}; 
     63        } 
     64 
    5665        public File[] getSourceFolders() { 
    5766                IPath[] paths = getSourceLocations(); 
     67                File[] files = new File[paths.length]; 
     68                for (int i = 0; i < paths.length; i++) { 
     69                        files[i] = new File(paths[i].toOSString()); 
     70                } 
     71                return files; 
     72        } 
     73 
     74        public File[] getLibraries() { 
     75                IPath[] paths = getLibraryLocations(); 
    5876                File[] files = new File[paths.length]; 
    5977                for (int i = 0; i < paths.length; i++) { 
     
    94112                return resource; 
    95113        } 
     114 
     115        protected IPath[] getResourceLocations(IResource[] array) { 
     116                IPath[] paths = new IPath[array.length]; 
     117                for (int i = 0; i < array.length; i++) { 
     118                        paths[i] = array[i].getLocation(); 
     119                } 
     120                return paths; 
     121        } 
    96122} 
  • axdt/trunk/org.axdt.flex3sdk.compiler/src/org/axdt/flex3sdk/Flex3Compiler.java

    r92 r126  
    4747                config.setConfiguration(getConfigFile(target)); 
    4848                config.addSourcePath(target.getSourceFolders()); 
     49                config.addLibraryPath(target.getLibraries()); 
    4950                config.allowSourcePathOverlap(true); 
    5051                app.setConfiguration(config);