Changeset 3d0622cd77233477dd222f1c00c4f35afeb67815

Show
Ignore:
Timestamp:
06/28/09 23:36:50 (14 months ago)
Author:
mb0 <mb0@…>
Children:
49cbb509af4876ed4a2ccd7942c17372373a5ae2
Parents:
80657c560c55a46e8bdb3bcc2aef994a475d2511
git-author:
mb0 <mb0@…> (06/10/09 03:01:59)
git-committer:
mb0 <mb0@…> (06/28/09 23:36:50)
Message:

moved editor related preferences from as3 preference to as3 editor preferences
editor preferences can now be used to override imp editor settings.
tab width can now be set for as3 editor.

new basic editor service that observes the life cycle of an as3 editor.
this is used to suppress the builder to build files that are currently edited.

Location:
org.axdt.as3
Files:
2 added
7 modified

Legend:

Unmodified
Added
Removed
  • org.axdt.as3/plugin.xml

    r69d1ca8 r3d0622c  
    6565            language="AS3"> 
    6666      </proposer> 
     67   </extension> 
     68   <extension 
     69         point="org.eclipse.imp.runtime.editorService"> 
     70      <editorService 
     71            class="org.axdt.as3.imp.services.AS3EditorService" 
     72            language="AS3"> 
     73      </editorService> 
    6774   </extension> 
    6875   <extension 
     
    240247            class="org.axdt.as3.preferences.AS3Preferences"> 
    241248      </initializer> 
     249      <initializer 
     250            class="org.axdt.as3.preferences.AS3EditorPreferences"> 
     251      </initializer> 
    242252   </extension> 
    243253   <extension 
  • org.axdt.as3/src/org/axdt/as3/imp/autoEdit/AS3AutoEditStrategy.java

    r79b60b9 r3d0622c  
    22 
    33import org.axdt.as3.AS3Plugin; 
    4 import org.axdt.as3.preferences.AS3Preferences; 
     4import org.axdt.as3.preferences.AS3EditorPreferences; 
    55import org.axdt.util.AxdtTextHelper; 
    66import org.eclipse.imp.services.IAutoEditStrategy; 
     
    2525 
    2626        public AS3AutoEditStrategy() { 
    27                 IPreferenceStore store = AS3Preferences.getInstance().getStore(); 
    28                 ftab2Space = store.getBoolean(AS3Preferences.TAB_TO_SPACE); 
    29                 fTabRatio = store.getInt(AS3Preferences.TAB_WIDTH); 
    30                 fCloseString = store.getBoolean(AS3Preferences.CLOSE_STRINGS); 
    31                 fCloseBrackets = store.getBoolean(AS3Preferences.CLOSE_BRACKETS); 
    32                 fCloseBraces = store.getBoolean(AS3Preferences.CLOSE_BRACES); 
    33                 fDeletePair = store.getBoolean(AS3Preferences.DELETE_PAIR); 
     27                IPreferenceStore store = AS3EditorPreferences.getInstance().getStore(); 
     28                ftab2Space = store.getBoolean(AS3EditorPreferences.TAB_TO_SPACE); 
     29                fTabRatio = store.getInt(AS3EditorPreferences.TAB_WIDTH); 
     30                fCloseString = store.getBoolean(AS3EditorPreferences.CLOSE_STRINGS); 
     31                fCloseBrackets = store.getBoolean(AS3EditorPreferences.CLOSE_BRACKETS); 
     32                fCloseBraces = store.getBoolean(AS3EditorPreferences.CLOSE_BRACES); 
     33                fDeletePair = store.getBoolean(AS3EditorPreferences.DELETE_PAIR); 
    3434        } 
    3535 
  • org.axdt.as3/src/org/axdt/as3/imp/builders/AS3Builder.java

    r69d1ca8 r3d0622c  
    55import org.axdt.as3.AS3Plugin; 
    66import org.axdt.as3.imp.parser.AS3ParseController; 
     7import org.axdt.as3.imp.services.AS3EditorService; 
    78import org.axdt.as3.preferences.AS3Preferences; 
    89import org.axdt.as3.util.AS3Util; 
     
    2223import org.eclipse.imp.model.ModelFactory.ModelException; 
    2324import org.eclipse.imp.runtime.PluginBase; 
    24 import org.eclipse.jface.preference.IPreferenceStore; 
    2525 
    2626/** 
     
    6666        protected boolean isSourceFile(IFile file) { 
    6767                IPath path = file.getRawLocation(); 
    68                 if (path == null) return false; 
     68                if (path == null || !LANGUAGE.hasExtension(path.getFileExtension()))  
     69                        return false; 
    6970                IContainer sourceFolder = AS3Util.getSourceFolder(file); 
    70  
    71                 if (sourceFolder == null) return false; 
    72  
    73                 return LANGUAGE.hasExtension(path.getFileExtension()); 
     71                return sourceFolder != null; 
    7472        } 
    7573 
     
    10098         */ 
    10199        protected boolean isOutputFolder(IResource resource) { 
    102                 IPreferenceStore store = AS3Preferences.getInstance().getProjectStore(resource); 
    103                 String deployPart = store.getString(AS3Preferences.DEPLOY_PATH); 
    104                 IPath fullPath = resource.getFullPath(); 
    105                 return fullPath.toPortableString().endsWith(deployPart); 
     100                if (resource == null || !(resource instanceof IContainer)) return false; 
     101                IContainer deployContainer = AS3Preferences.getDeployPath(resource); 
     102                return resource.equals(deployContainer); 
    106103        } 
    107104 
     
    112109        protected void compile(final IFile file, IProgressMonitor monitor) { 
    113110                try { 
    114                          
     111                        if (AS3EditorService.isOpen(file.getFullPath())) { 
     112                                // skip if editor is open. the parser scheduler will handle things 
     113                                AS3Plugin.getDefault().debug("skip build for opened file."); 
     114                        } 
    115115                        AS3ParseController parse = getParseController(file); 
    116116 
  • org.axdt.as3/src/org/axdt/as3/imp/foldingUpdater/AS3FoldingUpdater.java

    r1d13b65 r3d0622c  
    55import java.util.List; 
    66 
     7import lpg.runtime.Adjunct; 
     8import lpg.runtime.ILexStream; 
     9import lpg.runtime.IPrsStream; 
     10import lpg.runtime.IToken; 
     11 
     12import org.axdt.as3.imp.parser.Ast.ASTNode; 
     13import org.axdt.as3.imp.parser.Ast.AbstractVisitor; 
     14import org.axdt.as3.imp.parser.Ast.Block; 
     15import org.axdt.as3.imp.parser.Ast.FunctionDefinition; 
     16import org.axdt.as3.imp.parser.Ast.ImportDirectiveList; 
     17import org.axdt.as3.imp.parser.Ast.InterfaceBlock; 
     18import org.axdt.as3.imp.parser.Ast.PackageDefinition; 
     19import org.axdt.as3.preferences.AS3EditorPreferences; 
    720import org.eclipse.imp.parser.IParseController; 
    821import org.eclipse.imp.parser.ISourcePositionLocator; 
     
    1326import org.eclipse.jface.text.source.projection.ProjectionAnnotation; 
    1427import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; 
    15  
    16 import org.axdt.as3.imp.parser.Ast.*; 
    17 import org.axdt.as3.preferences.AS3Preferences; 
    18  
    19 import lpg.runtime.*; 
    2028 
    2129/** 
     
    3038 
    3139        public AS3FoldingUpdater() { 
    32                 IPreferenceStore store = AS3Preferences.getInstance().getStore(); 
    33                 useFolding = store.getBoolean(AS3Preferences.USE_FOLDING); 
    34                 foldComments = store.getBoolean(AS3Preferences.FOLD_COMMENTS); 
    35                 foldHeaders = store.getBoolean(AS3Preferences.FOLD_HEADERS); 
    36                 foldImports = store.getBoolean(AS3Preferences.FOLD_IMPORTS); 
    37                 foldMembers = store.getBoolean(AS3Preferences.FOLD_MEMBERS); 
     40                IPreferenceStore store = AS3EditorPreferences.getInstance().getStore(); 
     41                useFolding = store.getBoolean(AS3EditorPreferences.USE_FOLDING); 
     42                foldComments = store.getBoolean(AS3EditorPreferences.FOLD_COMMENTS); 
     43                foldHeaders = store.getBoolean(AS3EditorPreferences.FOLD_HEADERS); 
     44                foldImports = store.getBoolean(AS3EditorPreferences.FOLD_IMPORTS); 
     45                foldMembers = store.getBoolean(AS3EditorPreferences.FOLD_MEMBERS); 
    3846                autoFolds = new ArrayList<Annotation>(); 
    3947        } 
  • org.axdt.as3/src/org/axdt/as3/preferences/AS3EditorPreferencePage.java

    rfc56e42 r3d0622c  
    22 
    33import org.axdt.preferences.AbstractPreferencePage; 
    4 import org.eclipse.swt.SWT; 
    5 import org.eclipse.swt.widgets.Composite; 
    6 import org.eclipse.swt.widgets.Control; 
    7 import org.eclipse.ui.dialogs.PreferenceLinkArea; 
    8 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; 
    94 
    105public class AS3EditorPreferencePage extends AbstractPreferencePage { 
    11         private static final String IMP_PREF_PAGE = "org.eclipse.imp.runtime.preferencePage"; 
    126 
    137        public AS3EditorPreferencePage() { 
    14                 super(AS3Preferences.getInstance(), AS3Preferences.PAGE_EDITOR); 
     8                super(AS3EditorPreferences.getInstance()); 
    159        } 
    1610 
    17         @Override 
    18         protected Control createContents(Composite parent) { 
    19                 parent = (Composite) super.createContents(parent); 
    20                 new PreferenceLinkArea(parent, SWT.NONE, IMP_PREF_PAGE, 
    21                                 "See <a>IMP Preference</a> for tab width and font preference", 
    22                                 (IWorkbenchPreferenceContainer)getContainer(), null); 
    23                 return parent; 
    24         } 
    2511} 
  • org.axdt.as3/src/org/axdt/as3/preferences/AS3Preferences.java

    r87f02d1 r3d0622c  
    1010public class AS3Preferences extends AbstractPreferences { 
    1111 
    12         public final static String PAGE_EDITOR = "PAGE_EDITOR"; 
    13  
    1412        public final static String SOURCE_PATHS = "SOURCE_PATHS"; 
    1513        public final static String LIBRARY_PATHS = "LIBRARY_PATHS"; 
    1614        public final static String DEPLOY_PATH = "DEPLOY_PATH"; 
    1715        public final static String CONFIG_PATH = "CONFIG_PATH"; 
    18         public final static String TAB_TO_SPACE = "TAB_TO_SPACE"; 
    19         public final static String TAB_WIDTH = "TAB_WIDTH"; 
    20         public final static String CLOSE_STRINGS = "CLOSE_STRINGS"; 
    21         public final static String CLOSE_BRACKETS = "CLOSE_BRACKETS"; 
    22         public final static String CLOSE_BRACES = "CLOSE_BRACES"; 
    23         public final static String DELETE_PAIR = "DELETE_PAIR"; 
    24         public final static String USE_FOLDING = "USE_FOLDING"; 
    25         public final static String FOLD_COMMENTS = "FOLD_COMMENTS"; 
    26         public final static String FOLD_HEADERS = "FOLD_HEADERS"; 
    27         public final static String FOLD_IMPORTS = "FOLD_IMPORTS"; 
    28         public final static String FOLD_MEMBERS = "FOLD_MEMBERS"; 
    2916 
    3017        private static AS3Preferences instance; 
     
    5138                add(CONFIG_PATH, "&Config path", "config"); 
    5239                add(LIBRARY_PATHS, "&Library &paths", "lib"); 
    53                 addPage(PAGE_EDITOR, ""); 
    54                 addGroup(null, false); 
    55                 add(TAB_TO_SPACE, "Convert &tabs", false); 
    56                 add(TAB_WIDTH, "to number of spa&ces", 4); 
    57                 add(USE_FOLDING, "Enable &folding", true); 
    58                 addGroup("Initially fold these elements:", true); 
    59                 add(FOLD_COMMENTS, "&Comments", false); 
    60                 add(FOLD_HEADERS, "&Header comments", true); 
    61                 add(FOLD_MEMBERS, "&Members", false); 
    62                 add(FOLD_IMPORTS, "&Imports", true); 
    63                 addGroup("Automatically close", true); 
    64                 add(CLOSE_STRINGS, "\"&Strings\"", true); 
    65                 add(CLOSE_BRACKETS, "(Parentheses) and [Brac&kets]", true); 
    66                 add(CLOSE_BRACES, "{&Braces} on newline", true); 
    67                 endGroup(); 
    68                 add(DELETE_PAIR, "Delete right matching pair (if direct neighbor)", true); 
    6940        } 
    7041 
  • org.axdt.as3/src/org/axdt/as3/templates/AS3TemplateContext.java

    r888e2ac r3d0622c  
    66import java.util.StringTokenizer; 
    77 
    8 import org.axdt.as3.preferences.AS3Preferences; 
     8import org.axdt.as3.preferences.AS3EditorPreferences; 
    99import org.eclipse.jface.preference.IPreferenceStore; 
    1010import org.eclipse.jface.text.BadLocationException; 
     
    3232                String pattern = template.getPattern(); 
    3333                String delim = d.getLegalLineDelimiters()[0]; 
    34                 IPreferenceStore store = AS3Preferences.getInstance().getStore(); 
    35                 boolean tab2Space = store.getBoolean(AS3Preferences.TAB_TO_SPACE); 
    36                 int tabWidth = store.getInt(AS3Preferences.TAB_WIDTH); 
     34                IPreferenceStore store = AS3EditorPreferences.getInstance().getStore(); 
     35                boolean tab2Space = store.getBoolean(AS3EditorPreferences.TAB_TO_SPACE); 
     36                int tabWidth = store.getInt(AS3EditorPreferences.TAB_WIDTH); 
    3737                StringBuffer buf = new StringBuffer(); 
    3838                for (int i = 0; i < tabWidth; i++)