KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > ConfigurationHelper


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso;
5
6 import org.apache.commons.io.IOUtils;
7 import org.apache.commons.lang.StringUtils;
8 import org.apache.xmlbeans.XmlObject;
9 import org.apache.xmlbeans.XmlString;
10 import org.eclipse.core.resources.IContainer;
11 import org.eclipse.core.resources.IFile;
12 import org.eclipse.core.resources.IFolder;
13 import org.eclipse.core.resources.IMarker;
14 import org.eclipse.core.resources.IProject;
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.jdt.core.Flags;
18 import org.eclipse.jdt.core.IClassFile;
19 import org.eclipse.jdt.core.ICompilationUnit;
20 import org.eclipse.jdt.core.IField;
21 import org.eclipse.jdt.core.IJavaElement;
22 import org.eclipse.jdt.core.IJavaProject;
23 import org.eclipse.jdt.core.IMethod;
24 import org.eclipse.jdt.core.IPackageDeclaration;
25 import org.eclipse.jdt.core.IPackageFragment;
26 import org.eclipse.jdt.core.IPackageFragmentRoot;
27 import org.eclipse.jdt.core.IType;
28 import org.eclipse.jdt.core.JavaCore;
29 import org.eclipse.jdt.core.JavaModelException;
30 import org.eclipse.jdt.core.dom.IMethodBinding;
31 import org.eclipse.jdt.core.dom.MethodDeclaration;
32 import org.eclipse.jdt.core.search.IJavaSearchScope;
33 import org.eclipse.jdt.core.search.SearchEngine;
34 import org.eclipse.jface.text.Document;
35 import org.eclipse.jface.text.FindReplaceDocumentAdapter;
36 import org.eclipse.jface.text.IDocument;
37 import org.eclipse.jface.text.IRegion;
38 import org.eclipse.ui.texteditor.MarkerUtilities;
39 import org.terracotta.dso.editors.ConfigurationEditor;
40
41 import com.tc.aspectwerkz.reflect.MemberInfo;
42 import com.tc.aspectwerkz.reflect.MethodInfo;
43 import com.terracottatech.config.AdditionalBootJarClasses;
44 import com.terracottatech.config.Application;
45 import com.terracottatech.config.Autolock;
46 import com.terracottatech.config.ClassExpression;
47 import com.terracottatech.config.DistributedMethods;
48 import com.terracottatech.config.DsoApplication;
49 import com.terracottatech.config.Include;
50 import com.terracottatech.config.InstrumentedClasses;
51 import com.terracottatech.config.LockLevel;
52 import com.terracottatech.config.Locks;
53 import com.terracottatech.config.MethodNameExpression;
54 import com.terracottatech.config.NamedLock;
55 import com.terracottatech.config.Root;
56 import com.terracottatech.config.Roots;
57 import com.terracottatech.config.Servers;
58 import com.terracottatech.config.TransientFields;
59 import com.terracottatech.config.TcConfigDocument.TcConfig;
60
61 import java.io.InputStream JavaDoc;
62 import java.util.ArrayList JavaDoc;
63 import java.util.Arrays JavaDoc;
64 import java.util.HashMap JavaDoc;
65
66 /**
67  * Utility singleton for use by the various popup actions in
68  * org.terracotta.dso.popup.actions.
69  *
70  * @see org.terracotta.dso.actions.AdaptableAction
71  * @see org.terracotta.dso.actions.AutolockAction
72  * @see org.terracotta.dso.actions.BootJarTypeAction
73  * @see org.terracotta.dso.actions.DistributedMethodAction
74  * @see org.terracotta.dso.actions.ExcludedTypeAction
75  * @see org.terracotta.dso.actions.NameLockedAction
76  * @see org.terracotta.dso.actions.RootFieldAction
77  * @see org.terracotta.dso.actions.TransientFieldAction
78  */

79
80 public class ConfigurationHelper {
81   private TcPlugin m_plugin;
82   private IProject m_project;
83   private IJavaProject m_javaProject;
84   private PatternHelper m_patternHelper;
85
86   public ConfigurationHelper(IProject project) {
87     m_plugin = TcPlugin.getDefault();
88     m_project = project;
89     m_javaProject = JavaCore.create(m_project);
90     m_patternHelper = PatternHelper.getHelper();
91   }
92   
93   public boolean isAdaptable(IJavaElement element) {
94     if(element instanceof ICompilationUnit) {
95       return isAdaptable((ICompilationUnit)element);
96     }
97     else if(element instanceof IClassFile) {
98       return isAdaptable((IClassFile)element);
99     }
100     else if(element instanceof IType) {
101       return isAdaptable((IType)element);
102     }
103     else if(element instanceof IPackageDeclaration) {
104       return isAdaptable((IPackageDeclaration)element);
105     }
106     else if(element instanceof IPackageFragment) {
107       return isAdaptable((IPackageFragment)element);
108     }
109     else if(element instanceof IJavaProject) {
110       return isAdaptable((IJavaProject)element);
111     }
112     
113     return false;
114   }
115   
116   public boolean isAdaptable(ICompilationUnit module) {
117     return isAdaptable(module.findPrimaryType());
118   }
119
120   public boolean isAdaptable(IClassFile classFile) {
121     try {
122       return isAdaptable(classFile.getType());
123     } catch(JavaModelException jme) {
124       return false;
125     }
126   }
127
128   public boolean isAdaptable(IType type) {
129     if(type != null) {
130       return m_plugin.isBootClass(type) ||
131              isAdaptable(PatternHelper.getFullyQualifiedName(type));
132     }
133     return false;
134   }
135   
136   public boolean isAdaptable(IPackageDeclaration packageDecl) {
137     TcConfig config = getConfig();
138     
139     if(config != null) {
140       InstrumentedClasses classes = getInstrumentedClasses();
141       
142       if(classes != null) {
143         XmlObject[] objects = classes.selectPath("*");
144         
145         if(objects != null && objects.length > 0) {
146           XmlObject object;
147           String JavaDoc expr;
148           
149           for(int i = objects.length-1; i >= 0; i--) {
150             object = objects[i];
151             
152             if(object instanceof Include) {
153               expr = ((Include)object).getClassExpression();
154               
155               if(m_patternHelper.matchesPackageDeclaration(expr, packageDecl)) {
156                 return true;
157               }
158             }
159             else if(object instanceof ClassExpression) {
160               expr = ((ClassExpression)object).getStringValue();
161               
162               if(m_patternHelper.matchesPackageDeclaration(expr, packageDecl)) {
163                 return false;
164               }
165             }
166           }
167         }
168       }
169     }
170     
171     return false;
172   }
173   
174   public boolean isAdaptable(IPackageFragment fragment) {
175     TcConfig config = getConfig();
176     
177     if(config != null) {
178       InstrumentedClasses classes = getInstrumentedClasses();
179       
180       if(classes != null) {
181         XmlObject[] objects = classes.selectPath("*");
182         
183         if(objects != null && objects.length > 0) {
184           XmlObject object;
185           String JavaDoc expr;
186           
187           for(int i = objects.length-1; i >= 0; i--) {
188             object = objects[i];
189             
190             if(object instanceof Include) {
191               expr = ((Include)object).getClassExpression();
192               
193               if(m_patternHelper.matchesPackageFragment(expr, fragment)) {
194                 return true;
195               }
196             }
197             else if(object instanceof ClassExpression) {
198               expr = ((ClassExpression)object).getStringValue();
199               
200               if(m_patternHelper.matchesPackageFragment(expr, fragment)) {
201                 return false;
202               }
203             }
204           }
205         }
206       }
207     }
208     
209     return false;
210   }
211   
212   public boolean isAdaptable(final IJavaProject javaProject) {
213     if(javaProject != null) {
214       IPackageFragment[] fragments = getSourceFragments(javaProject);
215       
216       if(fragments.length > 0) {
217         for(int i = 0; i < fragments.length; i++) {
218           if(!isAdaptable(fragments[i])) {
219             return false;
220           }
221         }
222         
223         return true;
224       }
225     }
226     
227     return false;
228   }
229
230   public boolean isAdaptable(String JavaDoc classExpr) {
231     TcConfig config = getConfig();
232     
233     if(config != null) {
234       InstrumentedClasses classes = getInstrumentedClasses();
235       
236       if(classes != null) {
237         XmlObject[] objects = classes.selectPath("*");
238         
239         if(objects != null && objects.length > 0) {
240           XmlObject object;
241           String JavaDoc expr;
242           
243           for(int i = objects.length-1; i >= 0; i--) {
244             object = objects[i];
245             
246             if(object instanceof Include) {
247               expr = ((Include)object).getClassExpression();
248               
249               if(m_patternHelper.matchesClass(expr, classExpr)) {
250                 return true;
251               }
252             }
253             else if(object instanceof ClassExpression) {
254               expr = ((ClassExpression)object).getStringValue();
255               
256               if(m_patternHelper.matchesClass(expr, classExpr)) {
257                 return false;
258               }
259             }
260           }
261         }
262       }
263     }
264     
265     return m_plugin.isBootClass(classExpr);
266   }
267
268   public boolean declaresRoot(IType type) {
269     return declaresRoot(type.getFullyQualifiedName());
270   }
271   
272   public boolean declaresRoot(String JavaDoc typeName) {
273     if(typeName == null) return false;
274     
275     Roots roots = getRoots();
276     if(roots != null) {
277       String JavaDoc rootFieldName;
278       String JavaDoc rootTypeName;
279       
280       for(int i = 0; i < roots.sizeOfRootArray(); i++) {
281         rootFieldName = roots.getRootArray(i).getFieldName();
282         if(rootFieldName != null && rootFieldName.length() > 0) {
283           int dotIndex = rootFieldName.lastIndexOf('.');
284           if(dotIndex != -1) {
285             rootTypeName = rootFieldName.substring(0, dotIndex);
286             if(typeName.equals(rootTypeName)) {
287               return true;
288             }
289           }
290         }
291       }
292     }
293     
294     return false;
295   }
296   
297   public void ensureAdaptable(IJavaElement element) {
298     if(element instanceof ICompilationUnit) {
299       ensureAdaptable((ICompilationUnit)element);
300     }
301     else if(element instanceof IClassFile) {
302       ensureAdaptable((IClassFile)element);
303     }
304     else if(element instanceof IType) {
305       ensureAdaptable((IType)element);
306     }
307     else if(element instanceof IPackageDeclaration) {
308       ensureAdaptable((IPackageDeclaration)element);
309     }
310     else if(element instanceof IPackageFragment) {
311       ensureAdaptable((IPackageFragment)element);
312     }
313     else if(element instanceof IJavaProject) {
314       ensureAdaptable((IJavaProject)element);
315     }
316   }
317   
318   public void ensureAdaptable(final ICompilationUnit module) {
319     ensureAdaptable(module.findPrimaryType());
320   }
321   
322   public void ensureAdaptable(final IClassFile classFile) {
323     try {
324       ensureAdaptable(classFile.getType());
325     } catch(JavaModelException jme) {
326       openError("Error ensuring '"+
327                 classFile.getElementName()+"' instrumented", jme);
328     }
329   }
330
331   public void ensureAdaptable(IType type) {
332     while(type != null) {
333       if(!isInterface(type)) {
334         if(!isAdaptable(type)) {
335           internalEnsureAdaptable(type);
336         }
337       }
338       else {
339         break;
340       }
341       
342       IType parentType = type;
343       while(parentType != null) {
344         try {
345           String JavaDoc superTypeSig = parentType.getSuperclassTypeSignature();
346           
347           if(superTypeSig == null) {
348             break;
349           }
350           
351           String JavaDoc superTypeName = JdtUtils.getResolvedTypeName(superTypeSig, type);
352           if(superTypeName == null || superTypeName.equals("java.lang.Object")) {
353             break;
354           }
355           else {
356             IType superType = JdtUtils.findType(m_javaProject, superTypeName);
357
358             if(superType == null) {
359               break;
360             }
361             else if(!isInterface(superType)) {
362               if(!isAdaptable(superType)) {
363                 internalEnsureAdaptable(superType);
364               }
365               else {
366                 break;
367               }
368             }
369             parentType = superType;
370           }
371         } catch(JavaModelException jme) {
372           break;
373         }
374       }
375
376       type = type.getDeclaringType();
377     }
378     
379     ConfigurationEditor editor = getConfigurationEditor();
380     if(false && editor != null) {
381       editor.updateInstrumentedClassesPanel();
382     }
383     else {
384       persistConfiguration();
385     }
386   }
387   
388   private void internalEnsureAdaptable(IType type) {
389     internalEnsureAdaptable(PatternHelper.getFullyQualifiedName(type));
390     
391     if(!isBootJarClass(type)) {
392       int filter = IJavaSearchScope.SYSTEM_LIBRARIES;
393       IJavaElement[] elements = new IJavaElement[]{m_javaProject};
394       IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements, filter);
395       
396       if(scope.encloses(type)) {
397         internalEnsureBootJarClass(type);
398       }
399     }
400   }
401   
402   public void ensureAdaptable(IPackageDeclaration packageDecl) {
403     if(packageDecl != null && !isAdaptable(packageDecl)) {
404       internalEnsureAdaptable(packageDecl);
405       
406       ConfigurationEditor editor = getConfigurationEditor();
407       if(false && editor != null) {
408         editor.updateInstrumentedClassesPanel();
409       }
410       else {
411         persistConfiguration();
412       }
413     }
414   }
415   
416   private void internalEnsureAdaptable(IPackageDeclaration packageDecl) {
417     internalEnsureAdaptable(PatternHelper.getWithinPattern(packageDecl));
418   }
419
420   public void ensureAdaptable(IPackageFragment fragment) {
421     if(fragment != null && !isAdaptable(fragment)) {
422       internalEnsureAdaptable(fragment);
423       
424       ConfigurationEditor editor = getConfigurationEditor();
425       if(false && editor != null) {
426         editor.updateInstrumentedClassesPanel();
427       }
428       else {
429         persistConfiguration();
430       }
431     }
432   }
433   
434   private void internalEnsureAdaptable(IPackageFragment fragment) {
435     internalEnsureAdaptable(PatternHelper.getWithinPattern(fragment));
436   }
437   
438   public void ensureAdaptable(final IJavaProject javaProject) {
439     if(javaProject != null && !isAdaptable(javaProject)) {
440       internalEnsureAdaptable(javaProject);
441       
442       ConfigurationEditor editor = getConfigurationEditor();
443       if(false && editor != null) {
444         editor.updateInstrumentedClassesPanel();
445       }
446       else {
447         persistConfiguration();
448       }
449     }
450   }
451
452   private void internalEnsureAdaptable(final IJavaProject javaProject) {
453     IPackageFragment[] fragments = getSourceFragments(javaProject);
454     
455     for(int i = 0; i < fragments.length; i++) {
456       if(!isAdaptable(fragments[i])) {
457         internalEnsureAdaptable(fragments[i]);
458       }
459     }
460   }
461
462   public void ensureAdaptable(final String JavaDoc classExpr) {
463     if(!isAdaptable(classExpr)) {
464       internalEnsureAdaptable(classExpr);
465       
466       ConfigurationEditor editor = getConfigurationEditor();
467       if(false && editor != null) {
468         editor.updateInstrumentedClassesPanel();
469       }
470       else {
471         persistConfiguration();
472       }
473     }
474   }
475
476   private void internalEnsureAdaptable(final String JavaDoc classExpr) {
477     InstrumentedClasses classes = ensureInstrumentedClasses();
478     Include include = classes.addNewInclude();
479           
480     include.setClassExpression(classExpr);
481   }
482
483   public void ensureNotAdaptable(IJavaElement element) {
484     if(element instanceof ICompilationUnit) {
485       ensureNotAdaptable((ICompilationUnit)element);
486     }
487     else if(element instanceof IType) {
488       ensureNotAdaptable((IType)element);
489     }
490     else if(element instanceof IPackageDeclaration) {
491       ensureNotAdaptable((IPackageDeclaration)element);
492     }
493     else if(element instanceof IPackageFragment) {
494       ensureNotAdaptable((IPackageFragment)element);
495     }
496     else if(element instanceof IJavaProject) {
497       ensureNotAdaptable((IJavaProject)element);
498     }
499   }
500   
501   public void ensureNotAdaptable(final ICompilationUnit module) {
502     if(module != null) {
503       internalEnsureNotAdaptable(module);
504     }
505   }
506   
507   private void internalEnsureNotAdaptable(final ICompilationUnit module) {
508     IType primaryType = module.findPrimaryType();
509     
510     if(primaryType != null) {
511       internalEnsureNotAdaptable(primaryType);
512     }
513   }
514
515   public void ensureNotAdaptable(final IType type) {
516     if(isAdaptable(type)) {
517       baseEnsureNotAdaptable(type);
518       
519       ConfigurationEditor editor = getConfigurationEditor();
520       if(false && editor != null) {
521         editor.updateInstrumentedClassesPanel();
522       }
523       else {
524         persistConfiguration();
525       }
526     }
527   }
528   
529   public void baseEnsureNotAdaptable(final IType type) {
530     internalEnsureNotAdaptable(type);
531   }
532   
533   private void internalEnsureNotAdaptable(final IType type) {
534     internalEnsureNotLocked(type);
535     internalEnsureNotBootJarClass(type);
536     internalEnsureNotAdaptable(PatternHelper.getFullyQualifiedName(type));
537     
538     try {
539       IField[] fields = type.getFields();
540       
541       if(fields != null) {
542         for(int i = 0; i < fields.length; i++) {
543           internalEnsureNotRoot(fields[i]);
544         }
545       }
546       
547       IType[] childTypes = type.getTypes();
548       
549       if(childTypes != null) {
550         for(int i = 0; i < childTypes.length; i++) {
551           internalEnsureNotAdaptable(childTypes[i]);
552           internalEnsureNotBootJarClass(childTypes[i]);
553         }
554       }
555       
556       IMethod[] methods = type.getMethods();
557       
558       if(methods != null) {
559         for(int i = 0; i < methods.length; i++) {
560           internalEnsureNotLocked(methods[i]);
561           internalEnsureLocalMethod(methods[i]);
562         }
563       }
564     } catch(JavaModelException jme) {/**/}
565     
566     testRemoveInstrumentedClasses();
567   }
568
569   public void ensureNotAdaptable(final IPackageDeclaration packageDecl) {
570     if(isAdaptable(packageDecl)) {
571       internalEnsureNotAdaptable(packageDecl);
572       
573       ConfigurationEditor editor = getConfigurationEditor();
574       if(false && editor != null) {
575         editor.updateInstrumentedClassesPanel();
576       }
577       else {
578         persistConfiguration();
579       }
580     }
581   }
582   
583   private void internalEnsureNotAdaptable(final IPackageDeclaration packageDecl) {
584     internalEnsureNotLocked(packageDecl);
585     internalEnsureNotAdaptable(PatternHelper.getWithinPattern(packageDecl));
586   }
587   
588   public void ensureNotAdaptable(final IPackageFragment fragment) {
589     if(isAdaptable(fragment)) {
590       internalEnsureNotAdaptable(fragment);
591       
592       ConfigurationEditor editor = getConfigurationEditor();
593       if(false && editor != null) {
594         editor.updateInstrumentedClassesPanel();
595       }
596       else {
597         persistConfiguration();
598       }
599     }
600   }
601   
602   private void internalEnsureNotAdaptable(final IPackageFragment fragment) {
603     internalEnsureNotLocked(fragment);
604     
605     try {
606       ICompilationUnit[] cus = fragment.getCompilationUnits();
607   
608       if(cus != null) {
609         for(int i = 0; i < cus.length; i++) {
610           internalEnsureNotAdaptable(cus[i]);
611         }
612       }
613     } catch(JavaModelException jme) {
614       internalEnsureNotAdaptable(PatternHelper.getWithinPattern(fragment));
615     }
616   }
617
618   public void ensureNotAdaptable(final IJavaProject javaProject) {
619     if(javaProject != null) {
620       IPackageFragment[] fragments = getSourceFragments(javaProject);
621       
622       for(int i = 0; i < fragments.length; i++) {
623         internalEnsureNotAdaptable(fragments[i]);
624       }
625       
626       ConfigurationEditor editor = getConfigurationEditor();
627       if(false && editor != null) {
628         editor.updateInstrumentedClassesPanel();
629       }
630       else {
631         persistConfiguration();
632       }
633     }
634   }
635   
636   public void ensureNotAdaptable(final String JavaDoc classExpr) {
637     if(isAdaptable(classExpr)) {
638       internalEnsureNotAdaptable(classExpr);
639
640       ConfigurationEditor editor = getConfigurationEditor();
641       if(false && editor != null) {
642         editor.updateInstrumentedClassesPanel();
643       }
644       else {
645         persistConfiguration();
646       }
647     }
648   }
649
650   private void internalEnsureNotAdaptable(final String JavaDoc classExpr) {
651     InstrumentedClasses classes = getInstrumentedClasses();
652     
653     if(classes != null) {
654       int size = classes.sizeOfIncludeArray();
655       String JavaDoc expr;
656     
657       for(int i = size-1; i >= 0; i--) {
658         expr = classes.getIncludeArray(i).getClassExpression();
659
660         if(m_patternHelper.matchesClass(expr, classExpr)) {
661           classes.removeInclude(i);
662         }
663       }
664     }
665   }
666
667   public boolean isExcluded(IJavaElement element) {
668     if(element instanceof ICompilationUnit) {
669       return isExcluded((ICompilationUnit)element);
670     }
671     else if(element instanceof IType) {
672       return isExcluded((IType)element);
673     }
674     else if(element instanceof IPackageDeclaration) {
675       return isExcluded(element.getElementName());
676     }
677     else if(element instanceof IPackageFragment) {
678       return isExcluded((IPackageFragment)element);
679     }
680     else if(element instanceof IJavaProject) {
681       return isExcluded((IJavaProject)element);
682     }
683     
684     return false;
685   }
686   
687   public boolean isExcluded(ICompilationUnit module) {
688     return isExcluded(module.findPrimaryType());
689   }
690
691   public boolean isExcluded(IType type) {
692     return type != null && isExcluded(PatternHelper.getFullyQualifiedName(type));
693   }
694
695   public boolean isExcluded(IPackageFragment fragment) {
696     TcConfig config = getConfig();
697     
698     if(config != null) {
699       InstrumentedClasses classes = getInstrumentedClasses();
700       
701       if(classes != null) {
702         XmlObject[] objects = classes.selectPath("*");
703         
704         if(objects != null && objects.length > 0) {
705           XmlObject object;
706           String JavaDoc expr;
707           
708           for(int i = objects.length-1; i >= 0; i--) {
709             object = objects[i];
710             
711             if(object instanceof Include) {
712               expr = ((Include)object).getClassExpression();
713               
714               if(m_patternHelper.matchesPackageFragment(expr, fragment)) {
715                 return false;
716               }
717             }
718             else if(object instanceof ClassExpression) {
719               expr = ((ClassExpression)object).getStringValue();
720               
721               if(m_patternHelper.matchesPackageFragment(expr, fragment)) {
722                 return true;
723               }
724             }
725           }
726         }
727       }
728     }
729     
730     return false;
731   }
732
733   public boolean isExcluded(final IJavaProject javaProject) {
734     if(javaProject != null) {
735       IPackageFragment[] fragments = getSourceFragments(javaProject);
736       
737       if(fragments.length > 0) {
738         for(int i = 0; i < fragments.length; i++) {
739           if(!isExcluded(fragments[i])) {
740             return false;
741           }
742         }
743         
744         return true;
745       }
746     }
747     
748     return false;
749   }
750
751   public boolean isExcluded(String JavaDoc classExpr) {
752     TcConfig config = getConfig();
753     
754     if(config != null) {
755       InstrumentedClasses classes = getInstrumentedClasses();
756       
757       if(classes != null) {
758         XmlObject[] objects = classes.selectPath("*");
759         
760         if(objects != null && objects.length > 0) {
761           XmlObject object;
762           String JavaDoc expr;
763           
764           for(int i = objects.length-1; i >= 0; i--) {
765             object = objects[i];
766             
767             if(object instanceof Include) {
768               expr = ((Include)object).getClassExpression();
769               
770               if(m_patternHelper.matchesClass(expr, classExpr)) {
771                 return false;
772               }
773             }
774             else if(object instanceof ClassExpression) {
775               expr = ((ClassExpression)object).getStringValue();
776               
777               if(m_patternHelper.matchesClass(expr, classExpr)) {
778                 return true;
779               }
780             }
781           }
782         }
783       }
784     }
785     
786     return false;
787   }
788
789   public void ensureExcluded(final IJavaElement element) {
790     if(element instanceof ICompilationUnit) {
791       ensureExcluded((ICompilationUnit)element);
792     }
793     else if(element instanceof IType) {
794       ensureExcluded((IType)element);
795     }
796     else if(element instanceof IPackageDeclaration) {
797       ensureExcluded(element.getElementName());
798     }
799     else if(element instanceof IPackageFragment) {
800       ensureExcluded((IPackageFragment)element);
801     }
802     else if(element instanceof IJavaProject) {
803       ensureExcluded((IJavaProject)element);
804     }
805   }
806   
807   public void ensureExcluded(final ICompilationUnit module) {
808     if(module != null) {
809       internalEnsureExcluded(module);
810
811       ConfigurationEditor editor = getConfigurationEditor();
812       if(false && editor != null) {
813         editor.updateInstrumentedClassesPanel();
814       }
815       else {
816         persistConfiguration();
817       }
818     }
819   }
820   
821   private void internalEnsureExcluded(final ICompilationUnit module) {
822     internalEnsureExcluded(module.findPrimaryType());
823   }
824
825   public void ensureExcluded(final IType type) {
826     if(type != null && !isExcluded(type)) {
827       internalEnsureExcluded(type);
828
829       ConfigurationEditor editor = getConfigurationEditor();
830       if(false && editor != null) {
831         editor.updateInstrumentedClassesPanel();
832       }
833       else {
834         persistConfiguration();
835       }
836     }
837   }
838
839   private void internalEnsureExcluded(final IType type) {
840     internalEnsureExcluded(PatternHelper.getFullyQualifiedName(type));
841   }
842
843   public void ensureExcluded(final IPackageFragment fragment) {
844     if(fragment != null && !isExcluded(fragment)) {
845       internalEnsureExcluded(fragment);
846
847       ConfigurationEditor editor = getConfigurationEditor();
848       if(false && editor != null) {
849         editor.updateInstrumentedClassesPanel();
850       }
851       else {
852         persistConfiguration();
853       }
854     }
855   }
856   
857   private void internalEnsureExcluded(final IPackageFragment fragment) {
858     internalEnsureExcluded(PatternHelper.getWithinPattern(fragment));
859   }
860
861   public void ensureExcluded(final IJavaProject javaProject) {
862     if(javaProject != null) {
863       IPackageFragment[] fragments = getSourceFragments(javaProject);
864       
865       for(int i = 0; i < fragments.length; i++) {
866         internalEnsureExcluded(fragments[i]);
867       }
868       
869       persistConfiguration();
870     }
871   }
872
873   public void ensureExcluded(final String JavaDoc className) {
874     if(className != null && !isExcluded(className)) {
875       internalEnsureExcluded(className);
876
877       ConfigurationEditor editor = getConfigurationEditor();
878       if(false && editor != null) {
879         editor.updateInstrumentedClassesPanel();
880       }
881       else {
882         persistConfiguration();
883       }
884     }
885   }
886
887   private void internalEnsureExcluded(final String JavaDoc className) {
888     ensureInstrumentedClasses().addExclude(className);
889   }
890
891   public void ensureNotExcluded(IJavaElement element) {
892     if(element instanceof ICompilationUnit) {
893       ensureNotExcluded((ICompilationUnit)element);
894     }
895     else if(element instanceof IType) {
896       ensureNotExcluded((IType)element);
897     }
898     else if(element instanceof IPackageFragment) {
899       ensureNotExcluded((IPackageFragment)element);
900     }
901     else if(element instanceof IJavaProject) {
902       ensureNotExcluded((IJavaProject)element);
903     }
904   }
905   
906   public void ensureNotExcluded(final ICompilationUnit module) {
907     if(module != null) {
908       internalEnsureNotExcluded(module);
909
910       ConfigurationEditor editor = getConfigurationEditor();
911       if(false && editor != null) {
912         editor.updateInstrumentedClassesPanel();
913       }
914       else {
915         persistConfiguration();
916       }
917     }
918   }
919   
920   private void internalEnsureNotExcluded(final ICompilationUnit module) {
921     internalEnsureNotExcluded(module.findPrimaryType());
922   }
923
924   public void ensureNotExcluded(final IType type) {
925     if(type != null && isExcluded(type)) {
926       baseEnsureNotExcluded(PatternHelper.getFullyQualifiedName(type));
927
928       ConfigurationEditor editor = getConfigurationEditor();
929       if(false && editor != null) {
930         editor.updateInstrumentedClassesPanel();
931       }
932       else {
933         persistConfiguration();
934       }
935     }
936   }
937
938   public void baseEnsureNotExcluded(final IType type) {
939     internalEnsureNotExcluded(type);
940   }
941   
942   private void internalEnsureNotExcluded(final IType type) {
943     internalEnsureNotExcluded(PatternHelper.getFullyQualifiedName(type));
944   }
945
946   public void ensureNotExcluded(final IPackageFragment fragment) {
947     if(fragment != null) {
948       ensureNotExcluded(PatternHelper.getWithinPattern(fragment));
949     }
950   }
951   
952   private void internalEnsureNotExcluded(final IPackageFragment fragment) {
953     internalEnsureNotExcluded(PatternHelper.getWithinPattern(fragment));
954   }
955
956   public void ensureNotExcluded(final IJavaProject javaProject) {
957     if(javaProject != null) {
958       IPackageFragment[] fragments = getSourceFragments(javaProject);
959       
960       for(int i = 0; i < fragments.length; i++) {
961         internalEnsureNotExcluded(fragments[i]);
962       }
963       
964       ConfigurationEditor editor = getConfigurationEditor();
965       if(false && editor != null) {
966         editor.updateInstrumentedClassesPanel();
967       }
968       else {
969         persistConfiguration();
970       }
971     }
972   }
973
974   public void ensureNotExcluded(final String JavaDoc classExpr) {
975     if(isExcluded(classExpr)) {
976       baseEnsureNotExcluded(classExpr);
977
978       ConfigurationEditor editor = getConfigurationEditor();
979       if(false && editor != null) {
980         editor.updateInstrumentedClassesPanel();
981       }
982       else {
983         persistConfiguration();
984       }
985     }
986   }
987
988   public void baseEnsureNotExcluded(final String JavaDoc classExpr) {
989     internalEnsureNotExcluded(classExpr);
990   }
991   
992   private void internalEnsureNotExcluded(final String JavaDoc classExpr) {
993     InstrumentedClasses classes = getInstrumentedClasses();
994     
995     if(classes != null) {
996       int size = classes.sizeOfExcludeArray();
997       String JavaDoc expr;
998     
999       for(int i = size-1; i >= 0; i--) {
1000        expr = classes.getExcludeArray(i);
1001
1002        if(m_patternHelper.matchesClass(expr, classExpr)) {
1003          classes.removeExclude(i);
1004        }
1005      }
1006    }
1007  }
1008
1009  public static String JavaDoc getFullName(IField field) {
1010    IType type = field.getDeclaringType();
1011    String JavaDoc parentType = PatternHelper.getFullyQualifiedName(type);
1012    String JavaDoc fieldName = field.getElementName();
1013    
1014    return parentType+"."+fieldName;
1015  }
1016  
1017  public boolean isRoot(IField field) {
1018    return field != null && isRoot(getFullName(field));
1019  }
1020  
1021  public boolean isRoot(String JavaDoc className, String JavaDoc fieldName) {
1022    return isRoot(className+"."+fieldName);
1023  }
1024  
1025  public boolean isRoot(String JavaDoc fieldName) {
1026    TcConfig config = getConfig();
1027    
1028    if(config != null) {
1029      Roots roots = getRoots();
1030      
1031      if(roots != null) {
1032        int size = roots.sizeOfRootArray();
1033        
1034        for(int i = 0; i < size; i++) {
1035          if(fieldName.equals(roots.getRootArray(i).getFieldName())) {
1036            return true;
1037          }
1038        }
1039      }
1040    }
1041    
1042    return false;
1043  }
1044  
1045  public void ensureRoot(IField field) {
1046    if(!isRoot(field)) {
1047      boolean updateInstrumented = false;
1048      boolean updateTransients = false;
1049      IType fieldType = getFieldType(field);
1050
1051      if(fieldType != null &&
1052         !isInterface(fieldType) &&
1053         !isAdaptable(fieldType))
1054      {
1055        internalEnsureAdaptable(fieldType);
1056        updateInstrumented = true;
1057      }
1058
1059      if(isTransient(field)) {
1060        ensureNotTransient(field);
1061        updateTransients = true;
1062      }
1063
1064      internalEnsureRoot(getFullName(field));
1065
1066      ConfigurationEditor editor = getConfigurationEditor();
1067      if(false && editor != null) {
1068        if(updateInstrumented) {
1069          editor.updateInstrumentedClassesPanel();
1070        }
1071        if(updateTransients) {
1072          editor.updateTransientsPanel();
1073        }
1074        editor.updateRootsPanel();
1075      }
1076      else {
1077        persistConfiguration();
1078      }
1079    }
1080  }
1081
1082  public IType getFieldType(IField field) {
1083    try {
1084      String JavaDoc sig = field.getTypeSignature();
1085      IType declaringType = field.getDeclaringType();
1086      String JavaDoc typeName = JdtUtils.getResolvedTypeName(sig, declaringType);
1087      
1088      if(typeName != null) {
1089        return JdtUtils.findType(m_javaProject, typeName);
1090      }
1091    } catch(JavaModelException jme) {/**/}
1092
1093    return null;
1094  }
1095
1096  public IField getField(String JavaDoc fieldName) {
1097    int lastDot = fieldName.lastIndexOf('.');
1098    String JavaDoc declaringTypeName = fieldName.substring(0, lastDot);
1099    
1100    try {
1101      IType declaringType = JdtUtils.findType(m_javaProject, declaringTypeName);
1102      
1103      if(declaringType != null) {
1104        return declaringType.getField(fieldName.substring(lastDot+1));
1105      }
1106    } catch(JavaModelException jme) {/**/}
1107    
1108    return null;
1109  }
1110  
1111  public IType getFieldType(String JavaDoc fieldName) {
1112    IField field = getField(fieldName);
1113        
1114    if(field != null) {
1115      try {
1116        String JavaDoc sig = field.getTypeSignature();
1117        IType declaringType = field.getDeclaringType();
1118        String JavaDoc typeName = JdtUtils.getResolvedTypeName(sig, declaringType);
1119
1120        return JdtUtils.findType(m_javaProject, typeName);
1121      } catch(JavaModelException jme) {/**/}
1122
1123    }
1124    
1125    return null;
1126  }
1127  
1128  public void ensureRoot(final String JavaDoc fieldName) {
1129    if(!isRoot(fieldName)) {
1130      IType fieldType = getFieldType(fieldName);
1131      boolean updateInstrumented = false;
1132      boolean updateTransients = false;
1133      
1134      if(fieldType != null && !isAdaptable(fieldType)) {
1135        ensureAdaptable(fieldType);
1136        updateInstrumented = true;
1137      }
1138      
1139      if(isTransient(fieldName)) {
1140        ensureNotTransient(fieldName);
1141        updateTransients = true;
1142      }
1143      
1144      internalEnsureRoot(fieldName);
1145
1146      ConfigurationEditor editor = getConfigurationEditor();
1147      if(false && editor != null) {
1148        if(updateInstrumented) {
1149          editor.updateInstrumentedClassesPanel();
1150        }
1151        if(updateTransients) {
1152          editor.updateTransientsPanel();
1153        }
1154        editor.updateRootsPanel();
1155      }
1156      else {
1157        persistConfiguration();
1158      }
1159    }
1160  }
1161
1162  private void internalEnsureRoot(final String JavaDoc fieldName) {
1163    ensureRoots().addNewRoot().setFieldName(fieldName);
1164  }
1165
1166  public void ensureNotRoot(final IField field) {
1167    if(field != null && isRoot(field)) {
1168      baseEnsureNotRoot(field);
1169
1170      ConfigurationEditor editor = getConfigurationEditor();
1171      if(false && editor != null) {
1172        editor.updateRootsPanel();
1173      }
1174      else {
1175        persistConfiguration();
1176      }
1177    }
1178  }
1179  
1180  public void baseEnsureNotRoot(final IField field) {
1181    internalEnsureNotRoot(field);
1182  }
1183  
1184  private void internalEnsureNotRoot(final IField field) {
1185    internalEnsureNotRoot(getFullName(field));
1186  }
1187
1188  public void ensureNotRoot(final String JavaDoc fieldName) {
1189    if(isRoot(fieldName)) {
1190      baseEnsureNotRoot(fieldName);
1191
1192      ConfigurationEditor editor = getConfigurationEditor();
1193      if(false && editor != null) {
1194        editor.updateRootsPanel();
1195      }
1196      else {
1197        persistConfiguration();
1198      }
1199    }
1200  }
1201
1202  public void baseEnsureNotRoot(final String JavaDoc fieldName) {
1203    internalEnsureNotRoot(fieldName);
1204  }
1205  
1206  private void internalEnsureNotRoot(final String JavaDoc fieldName) {
1207    Roots roots = getRoots();
1208
1209    if(roots != null) {
1210      int size = roots.sizeOfRootArray();
1211      
1212      for(int i = size-1; i >= 0; i--) {
1213        if(fieldName.equals(roots.getRootArray(i).getFieldName())) {
1214          roots.removeRoot(i);
1215        }
1216      }
1217    
1218      testRemoveRoots();
1219    }
1220  }
1221
1222  public void renameRoot(final String JavaDoc fieldName, final String JavaDoc newFieldName) {
1223    if(isRoot(fieldName)) {
1224      internalRenameRoot(fieldName, newFieldName);
1225
1226      ConfigurationEditor editor = getConfigurationEditor();
1227      if(false && editor != null) {
1228        editor.updateRootsPanel();
1229      }
1230      else {
1231        persistConfiguration();
1232      }
1233    }
1234  }
1235
1236  private void internalRenameRoot(final String JavaDoc fieldName,
1237                                  final String JavaDoc newFieldName)
1238  {
1239    Roots roots = getRoots();
1240
1241    if(roots != null) {
1242      Root root;
1243      int size = roots.sizeOfRootArray();
1244      
1245      for(int i = 0; i < size; i++) {
1246        root = roots.getRootArray(i);
1247        
1248        if(fieldName.equals(root.getFieldName())) {
1249          root.setFieldName(newFieldName);
1250          return;
1251        }
1252      }
1253    }
1254  }
1255
1256  public boolean isTransient(IField field) {
1257    return field != null && isTransient(getFullName(field));
1258  }
1259  
1260    public boolean isTransient(String JavaDoc className, String JavaDoc fieldName) {
1261    return isTransient(className+"."+fieldName);
1262  }
1263  
1264  public boolean isTransient(String JavaDoc fieldName) {
1265    TcConfig config = getConfig();
1266    
1267    if(config != null) {
1268      TransientFields transients = getTransientFields();
1269      
1270      if(transients != null) {
1271        int size = transients.sizeOfFieldNameArray();
1272        
1273        for(int i = 0; i < size; i++) {
1274          if(fieldName.equals(transients.getFieldNameArray(i))) {
1275            return true;
1276          }
1277        }
1278      }
1279    }
1280    
1281    return false;
1282  }
1283  
1284  public void ensureTransient(final IField field) {
1285    if(field != null && !isTransient(field)) {
1286      if(isRoot(field)) {
1287        internalEnsureNotRoot(field);
1288
1289        ConfigurationEditor editor = getConfigurationEditor();
1290        if(false && editor != null) {
1291          editor.updateRootsPanel();
1292        }
1293      }
1294
1295      IType declaringType = field.getDeclaringType();
1296      if(!isAdaptable(declaringType)) {
1297        internalEnsureAdaptable(declaringType);
1298        ConfigurationEditor editor = getConfigurationEditor();
1299        if(false && editor != null) {
1300          editor.updateInstrumentedClassesPanel();
1301        }
1302      }
1303      
1304      ensureTransient(getFullName(field));
1305    }
1306  }
1307  
1308  public void ensureTransient(final String JavaDoc fieldName) {
1309    if(!isTransient(fieldName)) {
1310      boolean updateInstrumented = false;
1311      boolean updateRoots = false;
1312      
1313      IField field = getField(fieldName);
1314      if(field != null) {
1315        IType fieldType = field.getDeclaringType();
1316        if(!isAdaptable(fieldType)) {
1317          ensureAdaptable(fieldType);
1318          updateInstrumented = true;
1319        }
1320      }
1321      
1322      if(isRoot(fieldName)) {
1323        ensureNotRoot(fieldName);
1324        updateRoots = true;
1325      }
1326      
1327      internalEnsureTransient(fieldName);
1328
1329      ConfigurationEditor editor = getConfigurationEditor();
1330      if(false && editor != null) {
1331        if(updateInstrumented) {
1332          editor.updateInstrumentedClassesPanel();
1333        }
1334        if(updateRoots) {
1335          editor.updateRootsPanel();
1336        }
1337        editor.updateTransientsPanel();
1338      }
1339      else {
1340        persistConfiguration();
1341      }
1342    }
1343  }
1344
1345  private void internalEnsureTransient(final String JavaDoc fieldName) {
1346    ensureTransientFields().addFieldName(fieldName);
1347  }
1348
1349  public void ensureNotTransient(final IField field) {
1350    if(field != null) {
1351      ensureNotTransient(getFullName(field));
1352    }
1353  }
1354  
1355  public void ensureNotTransient(final String JavaDoc fieldName) {
1356    if(isTransient(fieldName)) {
1357      internalEnsureNotTransient(fieldName);
1358
1359      ConfigurationEditor editor = getConfigurationEditor();
1360      if(false && editor != null) {
1361        editor.updateTransientsPanel();
1362      }
1363      else {
1364        persistConfiguration();
1365      }
1366    }
1367  }
1368  
1369  private void internalEnsureNotTransient(final String JavaDoc fieldName) {
1370    TransientFields transients = getTransientFields();
1371
1372    if(transients != null) {
1373      int size = transients.sizeOfFieldNameArray();
1374      
1375      for(int i = size-1; i >= 0; i--) {
1376        if(fieldName.equals(transients.getFieldNameArray(i))) {
1377          transients.removeFieldName(i);
1378        }
1379      }
1380    
1381      testRemoveTransientFields();
1382    }
1383  }
1384
1385  private TransientFields getTransientFields() {
1386    DsoApplication dsoApp = getDsoApplication();
1387    return dsoApp != null ? dsoApp.getTransientFields() : null;
1388  }
1389  
1390  private TransientFields ensureTransientFields() {
1391    DsoApplication dsoApp = ensureDsoApplication();
1392    TransientFields transients = dsoApp.getTransientFields();
1393    
1394    if(transients == null) {
1395      transients = dsoApp.addNewTransientFields();
1396    }
1397   
1398    return transients;
1399  }
1400
1401  private void testRemoveTransientFields() {
1402    DsoApplication dsoApp = getDsoApplication();
1403    
1404    if(dsoApp != null) {
1405      TransientFields transients = dsoApp.getTransientFields();
1406      
1407      if(transients != null) {
1408        if(transients.sizeOfFieldNameArray() == 0) {
1409          dsoApp.unsetTransientFields();
1410          testRemoveDsoApplication();
1411        }
1412      }
1413    }
1414  }
1415  
1416  public boolean matches(final String JavaDoc expression, final MemberInfo methodInfo) {
1417    return m_patternHelper.matchesMember(expression, methodInfo);
1418  }
1419
1420  public boolean matches(final String JavaDoc expression, final IMethod method) {
1421    return m_patternHelper.matchesMethod(expression, method);
1422  }
1423
1424  public boolean isDistributedMethod(final MethodDeclaration methodDecl) {
1425    IMethodBinding binding = methodDecl.resolveBinding();
1426    
1427    if(binding != null && !binding.getDeclaringClass().isInterface()) {
1428      return isDistributedMethod(PatternHelper.methodDecl2IMethod(methodDecl));
1429    }
1430    
1431    return false;
1432  }
1433
1434  public boolean isDistributedMethod(final IMethod method) {
1435    MethodInfo methodInfo = m_patternHelper.getMethodInfo(method);
1436    return methodInfo != null && isDistributedMethod(methodInfo);
1437  }
1438
1439  public boolean isDistributedMethod(final MethodInfo methodInfo) {
1440    TcConfig config = getConfig();
1441    
1442    if(config != null) {
1443      DistributedMethods methods = getDistributedMethods();
1444      
1445      if(methods != null) {
1446        int size = methods.sizeOfMethodExpressionArray();
1447        String JavaDoc expr;
1448        
1449        for(int i = 0; i < size; i++) {
1450          expr = methods.getMethodExpressionArray(i).getStringValue();
1451          
1452          if(m_patternHelper.matchesMember(expr, methodInfo)) {
1453            return true;
1454          }
1455        }
1456      }
1457    }
1458    
1459    return false;
1460  }
1461  
1462  public void ensureDistributedMethod(final IMethod method) {
1463    if(!isDistributedMethod(method)) {
1464      internalEnsureDistributedMethod(method);
1465
1466      ConfigurationEditor editor = getConfigurationEditor();
1467      if(false && editor != null) {
1468        editor.updateDistributedMethodsPanel();
1469      }
1470      else {
1471        persistConfiguration();
1472      }
1473    }
1474  }
1475
1476  private void internalEnsureDistributedMethod(final IMethod method) {
1477    IType declaringType = method.getDeclaringType();
1478    
1479    if(!isAdaptable(declaringType)) {
1480      internalEnsureAdaptable(declaringType);
1481    }
1482    
1483    DistributedMethods methods = ensureDistributedMethods();
1484    MethodNameExpression expr = methods.addNewMethodExpression();
1485      
1486    try {
1487      expr.setStringValue(PatternHelper.getJavadocSignature(method));
1488    } catch(JavaModelException jme) {
1489      openError("Error ensuring method '"+
1490                method.getElementName()+"' distributed", jme);
1491      return;
1492    }
1493  }
1494
1495  public void ensureLocalMethod(final IMethod method) {
1496    if(isDistributedMethod(method)) {
1497      internalEnsureLocalMethod(method);
1498
1499      ConfigurationEditor editor = getConfigurationEditor();
1500      if(false && editor != null) {
1501        editor.updateDistributedMethodsPanel();
1502      }
1503      else {
1504        persistConfiguration();
1505      }
1506    }
1507  }
1508  
1509  private void internalEnsureLocalMethod(final IMethod method) {
1510    DistributedMethods methods = getDistributedMethods();
1511    
1512    if(methods != null) {
1513      int size = methods.sizeOfMethodExpressionArray();
1514      String JavaDoc expr;
1515      
1516      for(int i = size-1; i >= 0; i--) {
1517        expr = methods.getMethodExpressionArray(i).getStringValue();
1518        
1519        if(m_patternHelper.matchesMethod(expr, method)) {
1520          methods.removeMethodExpression(i);
1521        }
1522      }
1523    
1524      testRemoveDistributedMethods();
1525    }
1526  }
1527
1528  public boolean isLocked(final IMethod method) {
1529    try {
1530      if(!method.getDeclaringType().isInterface()) {
1531        return isAutolocked(method) || isNameLocked(method);
1532      }
1533    } catch(JavaModelException jme) {/**/}
1534    
1535    return false;
1536  }
1537
1538  public boolean isLocked(final MethodDeclaration methodDecl) {
1539    IMethodBinding binding = methodDecl.resolveBinding();
1540    
1541    if(binding != null && !binding.getDeclaringClass().isInterface()) {
1542      return isLocked(PatternHelper.methodDecl2IMethod(methodDecl));
1543    }
1544    
1545    return false;
1546  }
1547
1548  public boolean isAutolocked(final IJavaElement element) {
1549    if(element instanceof IMethod) {
1550      return isAutolocked((IMethod)element);
1551    }
1552    else if(element instanceof IType) {
1553      return isAutolocked((IType)element);
1554    }
1555    else if(element instanceof IPackageDeclaration) {
1556      return isAutolocked((IPackageDeclaration)element);
1557    }
1558    else if(element instanceof IPackageFragment) {
1559      return isAutolocked((IPackageFragment)element);
1560    }
1561    else if(element instanceof IJavaProject) {
1562      return isAutolocked((IJavaProject)element);
1563    }
1564    
1565    return false;
1566  }
1567  
1568  public boolean isAutolocked(final IMethod method) {
1569    try {
1570      if(!method.getDeclaringType().isInterface()) {
1571        MethodInfo methodInfo = m_patternHelper.getMethodInfo(method);
1572        return methodInfo != null && isAutolocked(methodInfo);
1573      }
1574    } catch(JavaModelException jme) {/**/}
1575    
1576    return false;
1577  }
1578
1579  public boolean isAutolocked(final MethodInfo methodInfo) {
1580    TcConfig config = getConfig();
1581    
1582    if(config != null) {
1583      Locks locks = getLocks();
1584      
1585      if(locks != null) {
1586        int size = locks.sizeOfAutolockArray();
1587        Autolock autolock;
1588        String JavaDoc expr;
1589        
1590        for(int i = 0; i < size; i++) {
1591          autolock = locks.getAutolockArray(i);
1592          expr = autolock.getMethodExpression();
1593          
1594          if(m_patternHelper.matchesMember(expr, methodInfo)) {
1595            return true;
1596          }
1597        }
1598      }
1599    }
1600    
1601    return false;
1602  }
1603
1604  public boolean isAutolocked(final MethodDeclaration methodDecl) {
1605    IMethodBinding binding = methodDecl.resolveBinding();
1606    
1607    if(binding != null && !binding.getDeclaringClass().isInterface()) {
1608      return isAutolocked(PatternHelper.methodDecl2IMethod(methodDecl));
1609    }
1610    
1611    return false;
1612  }
1613  
1614  public boolean isAutolocked(final IType type) {
1615    try {
1616      if(type.isInterface()) {
1617        return false;
1618      }
1619    } catch(JavaModelException jme) {/**/}
1620    
1621    TcConfig config = getConfig();
1622    
1623    if(config != null) {
1624      Locks locks = getLocks();
1625      
1626      if(locks != null) {
1627        int size = locks.sizeOfAutolockArray();
1628        Autolock autolock;
1629        String JavaDoc expr;
1630        String JavaDoc typeExpr;
1631        
1632        typeExpr = PatternHelper.getExecutionPattern(type);
1633        
1634        for(int i = 0; i < size; i++) {
1635          autolock = locks.getAutolockArray(i);
1636          expr = autolock.getMethodExpression();
1637          
1638          if(typeExpr.equals(expr)) {
1639            return true;
1640          }
1641        }
1642      }
1643    }
1644    
1645    return false;
1646  }
1647
1648  public boolean isAutolocked(final IPackageDeclaration packageDecl) {
1649    TcConfig config = getConfig();
1650    
1651    if(config != null) {
1652      Locks locks = getLocks();
1653      
1654      if(locks != null) {
1655        int size = locks.sizeOfAutolockArray();
1656        Autolock autolock;
1657        String JavaDoc expr;
1658        String JavaDoc fragExpr;
1659        
1660        fragExpr = PatternHelper.getExecutionPattern(packageDecl);
1661        
1662        for(int i = 0; i < size; i++) {
1663          autolock = locks.getAutolockArray(i);
1664          expr = autolock.getMethodExpression();
1665          
1666          if(fragExpr.equals(expr)) {
1667            return true;
1668          }
1669        }
1670      }
1671    }
1672    
1673    return false;
1674  }
1675  
1676  public boolean isAutolocked(final IPackageFragment fragment) {
1677    TcConfig config = getConfig();
1678    
1679    if(config != null) {
1680      Locks locks = getLocks();
1681      
1682      if(locks != null) {
1683        int size = locks.sizeOfAutolockArray();
1684        Autolock autolock;
1685        String JavaDoc expr;
1686        String JavaDoc fragExpr;
1687        
1688        fragExpr = PatternHelper.getExecutionPattern(fragment);
1689        
1690        for(int i = 0; i < size; i++) {
1691          autolock = locks.getAutolockArray(i);
1692          expr = autolock.getMethodExpression();
1693          
1694          if(fragExpr.equals(expr)) {
1695            return true;
1696          }
1697        }
1698      }
1699    }
1700    
1701    return false;
1702  }
1703
1704  public boolean isAutolocked(final IJavaProject javaProject) {
1705    if(javaProject != null) {
1706        IPackageFragment[] fragments = getSourceFragments(javaProject);
1707        
1708        if(fragments.length > 0) {
1709          for(int i = 0; i < fragments.length; i++) {
1710            if(!isAutolocked(fragments[i])) {
1711              return false;
1712            }
1713          }
1714          
1715          return true;
1716        }
1717
1718
1719
1720    }
1721    
1722    return false;
1723  }
1724  
1725  public boolean isNameLocked(final IJavaElement element) {
1726    if(element instanceof IMethod) {
1727      return isNameLocked((IMethod)element);
1728    }
1729    else if(element instanceof IType) {
1730      return isNameLocked((IType)element);
1731    }
1732    else if(element instanceof IPackageDeclaration) {
1733      return isNameLocked((IPackageDeclaration)element);
1734    }
1735    else if(element instanceof IPackageFragment) {
1736      return isNameLocked((IPackageFragment)element);
1737    }
1738    else if(element instanceof IJavaProject) {
1739      return isNameLocked((IJavaProject)element);
1740    }
1741    
1742    return false;
1743  }
1744  
1745  public boolean isNameLocked(final IMethod method) {
1746    try {
1747      if(!method.getDeclaringType().isInterface()) {
1748        MethodInfo methodInfo = m_patternHelper.getMethodInfo(method);
1749        return methodInfo != null && isNameLocked(methodInfo);
1750      }
1751    } catch(JavaModelException jme) {/**/}
1752    
1753    return false;
1754  }
1755
1756  public boolean isNameLocked(final MethodInfo methodInfo) {
1757    TcConfig config = getConfig();
1758    
1759    if(config != null) {
1760      Locks locks = getLocks();
1761      
1762      if(locks != null) {
1763        int size = locks.sizeOfNamedLockArray();
1764        NamedLock namedLock;
1765        String JavaDoc expr;
1766
1767        for(int i = 0; i < size; i++) {
1768          namedLock = locks.getNamedLockArray(i);
1769          expr = namedLock.getMethodExpression();
1770          
1771          if(m_patternHelper.matchesMember(expr, methodInfo)) {
1772            return true;
1773          }
1774        }
1775      }
1776    }
1777    
1778    return false;
1779  }
1780
1781  public boolean isNameLocked(final MethodDeclaration methodDecl) {
1782    IMethodBinding binding = methodDecl.resolveBinding();
1783    
1784    if(binding != null && !binding.getDeclaringClass().isInterface()) {
1785      return isNameLocked(PatternHelper.methodDecl2IMethod(methodDecl));
1786    }
1787    
1788    return false;
1789  }
1790  
1791  public boolean isNameLocked(final IType type) {
1792    try {
1793      if(type.isInterface()) {
1794        return false;
1795      }
1796    } catch(JavaModelException jme) {/**/}
1797    
1798    TcConfig config = getConfig();
1799    
1800    if(config != null) {
1801      Locks locks = getLocks();
1802      
1803      if(locks != null) {
1804        int size = locks.sizeOfNamedLockArray();
1805        NamedLock namedLock;
1806        String JavaDoc expr;
1807        String JavaDoc typeExpr;
1808        
1809        typeExpr = PatternHelper.getExecutionPattern(type);
1810
1811        for(int i = 0; i < size; i++) {
1812          namedLock = locks.getNamedLockArray(i);
1813          expr = namedLock.getMethodExpression();
1814          
1815          if(typeExpr.equals(expr)) {
1816            return true;
1817          }
1818        }
1819      }
1820    }
1821    
1822    return false;
1823  }
1824
1825  public boolean isNameLocked(final IPackageDeclaration packageDecl) {
1826    TcConfig config = getConfig();
1827    
1828    if(config != null) {
1829      Locks locks = getLocks();
1830      
1831      if(locks != null) {
1832        int size = locks.sizeOfNamedLockArray();
1833        NamedLock namedLock;
1834        String JavaDoc expr;
1835        String JavaDoc fragExpr;
1836        
1837        fragExpr = PatternHelper.getExecutionPattern(packageDecl);
1838        
1839        for(int i = 0; i < size; i++) {
1840          namedLock = locks.getNamedLockArray(i);
1841          expr = namedLock.getMethodExpression();
1842          
1843          if(fragExpr.equals(expr)) {
1844            return true;
1845          }
1846        }
1847      }
1848    }
1849    
1850    return false;
1851  }
1852  
1853  public boolean isNameLocked(final IPackageFragment fragment) {
1854    TcConfig config = getConfig();
1855    
1856    if(config != null) {
1857      Locks locks = getLocks();
1858      
1859      if(locks != null) {
1860        int size = locks.sizeOfNamedLockArray();
1861        NamedLock namedLock;
1862        String JavaDoc expr;
1863        String JavaDoc fragExpr;
1864        
1865        fragExpr = PatternHelper.getExecutionPattern(fragment);
1866        
1867        for(int i = 0; i < size; i++) {
1868          namedLock = locks.getNamedLockArray(i);
1869          expr = namedLock.getMethodExpression();
1870          
1871          if(fragExpr.equals(expr)) {
1872            return true;
1873          }
1874        }
1875      }
1876    }
1877    
1878    return false;
1879  }
1880
1881  public boolean isNameLocked(final IJavaProject javaProject) {
1882    if(javaProject != null) {
1883      IPackageFragment[] fragments = getSourceFragments(javaProject);
1884      
1885      if(fragments.length > 0) {
1886        for(int i = 0; i < fragments.length; i++) {
1887          if(!isNameLocked(fragments[i])) {
1888            return false;
1889          }
1890        }
1891        
1892        return true;
1893      }
1894    }
1895    
1896    return false;
1897  }
1898
1899  public void ensureNameLocked(final IJavaElement element) {
1900    ensureNameLocked(element, "LockName", LockLevel.WRITE);
1901  }
1902
1903  public void ensureNameLocked(
1904    final IJavaElement element,
1905    final String JavaDoc name,
1906    final LockLevel.Enum level)
1907  {
1908    if(element instanceof IMethod) {
1909      ensureNameLocked((IMethod)element, name, level);
1910    }
1911    else if(element instanceof IType) {
1912      ensureNameLocked((IType)element, name, level);
1913    }
1914    else if(element instanceof IPackageDeclaration) {
1915      ensureNameLocked((IPackageDeclaration)element, name, level);
1916    }
1917    else if(element instanceof IPackageFragment) {
1918      ensureNameLocked((IPackageFragment)element, name, level);
1919    }
1920    else if(element instanceof IJavaProject) {
1921      ensureNameLocked((IJavaProject)element, name, level);
1922    }
1923  }
1924  
1925  public void ensureNameLocked(
1926    final IMethod method,
1927    final String JavaDoc name,
1928    final LockLevel.Enum level)
1929  {
1930    if(!isNameLocked(method)) {
1931      internalEnsureNameLocked(method, name, level);
1932
1933      ConfigurationEditor editor = getConfigurationEditor();
1934      if(false && editor != null) {
1935        editor.updateLocksPanel();
1936      }
1937      else {
1938        persistConfiguration();
1939      }
1940    }
1941  }
1942
1943  private void internalEnsureNameLocked(
1944    final IMethod method,
1945    final String JavaDoc name,
1946    final LockLevel.Enum level)
1947  {
1948    IType declaringType = method.getDeclaringType();
1949    
1950    if(!isAdaptable(declaringType)) {
1951      internalEnsureAdaptable(declaringType);
1952    }
1953
1954    Locks locks = ensureLocks();
1955    NamedLock lock = locks.addNewNamedLock();
1956      
1957    try {
1958      lock.setMethodExpression(PatternHelper.getJavadocSignature(method));
1959      lock.setLockLevel(level);
1960      lock.setLockName(name);
1961    } catch(JavaModelException jme) {
1962      openError("Error ensuring method '"+
1963                method.getElementName()+"' name-locked", jme);
1964      return;
1965    }
1966  }
1967
1968  public void ensureNameLocked(
1969    final IType type,
1970    final String JavaDoc name,
1971    final LockLevel.Enum level)
1972  {
1973    if(!isNameLocked(type)) {
1974      internalEnsureNameLocked(type, name, level);
1975
1976      ConfigurationEditor editor = getConfigurationEditor();
1977      if(false && editor != null) {
1978        editor.updateLocksPanel();
1979      }
1980      else {
1981        persistConfiguration();
1982      }
1983    }
1984  }
1985
1986  private void internalEnsureNameLocked(
1987    final IType type,
1988    final String JavaDoc name,
1989    final LockLevel.Enum level)
1990  {
1991    if(!isAdaptable(type)) {
1992      internalEnsureAdaptable(type);
1993    }
1994
1995    Locks locks = ensureLocks();
1996    NamedLock lock = locks.addNewNamedLock();
1997    String JavaDoc expr = PatternHelper.getExecutionPattern(type);
1998      
1999    lock.setMethodExpression(expr);
2000    lock.setLockLevel(level);
2001    lock.setLockName(name);
2002  }
2003
2004  public void ensureNameLocked(
2005     final IPackageDeclaration packageDecl,
2006     final String JavaDoc name,
2007     final LockLevel.Enum level)
2008  {
2009    if(!isNameLocked(packageDecl)) {
2010      internalEnsureNameLocked(packageDecl, name, level);
2011
2012      ConfigurationEditor editor = getConfigurationEditor();
2013      if(false && editor != null) {
2014        editor.updateLocksPanel();
2015      }
2016      else {
2017        persistConfiguration();
2018      }
2019    }
2020  }
2021
2022   private void internalEnsureNameLocked(
2023     final IPackageDeclaration packageDecl,
2024     final String JavaDoc name,
2025     final LockLevel.Enum level)
2026   {
2027     if(!isAdaptable(packageDecl)) {
2028       internalEnsureAdaptable(packageDecl);
2029     }
2030
2031     Locks locks = ensureLocks();
2032     NamedLock lock = locks.addNewNamedLock();
2033     String JavaDoc expr = PatternHelper.getExecutionPattern(packageDecl);
2034       
2035     lock.setMethodExpression(expr);
2036     lock.setLockName(name);
2037     lock.setLockLevel(level);
2038   }
2039
2040  public void ensureNameLocked(
2041    final IPackageFragment fragment,
2042    final String JavaDoc name,
2043    final LockLevel.Enum level)
2044  {
2045    if(!isNameLocked(fragment)) {
2046      internalEnsureNameLocked(fragment, name, level);
2047
2048      ConfigurationEditor editor = getConfigurationEditor();
2049      if(false && editor != null) {
2050        editor.updateLocksPanel();
2051      }
2052      else {
2053        persistConfiguration();
2054      }
2055    }
2056  }
2057
2058  private void internalEnsureNameLocked(
2059    final IPackageFragment fragment,
2060    final String JavaDoc name,
2061    final LockLevel.Enum level)
2062  {
2063    if(!isAdaptable(fragment)) {
2064      internalEnsureAdaptable(fragment);
2065    }
2066
2067    Locks locks = ensureLocks();
2068    NamedLock lock = locks.addNewNamedLock();
2069    String JavaDoc expr = PatternHelper.getExecutionPattern(fragment);
2070      
2071    lock.setMethodExpression(expr);
2072    lock.setLockName(name);
2073    lock.setLockLevel(level);
2074  }
2075
2076  public void ensureNameLocked(
2077    final IJavaProject javaProject,
2078    final String JavaDoc name,
2079    final LockLevel.Enum level)
2080  {
2081    if(javaProject != null && !isNameLocked(javaProject)) {
2082      internalEnsureNameLocked(javaProject, name, level);
2083
2084      ConfigurationEditor editor = getConfigurationEditor();
2085      if(false && editor != null) {
2086        editor.updateLocksPanel();
2087      }
2088      else {
2089        persistConfiguration();
2090      }
2091    }
2092  }
2093  
2094  private void internalEnsureNameLocked(
2095    final IJavaProject javaProject,
2096    final String JavaDoc name,
2097    final LockLevel.Enum level)
2098  {
2099    IPackageFragment[] fragments = getSourceFragments(javaProject);
2100    
2101    for(int i = 0; i < fragments.length; i++) {
2102      if(!isNameLocked(fragments[i])) {
2103        internalEnsureNameLocked(fragments[i], name, level);
2104      }
2105    }
2106  }
2107
2108  public void ensureAutolocked(final IJavaElement element) {
2109    if(element instanceof IMethod) {
2110      ensureAutolocked((IMethod)element);
2111    }
2112    else if(element instanceof IType) {
2113      ensureAutolocked((IType)element);
2114    }
2115    else if(element instanceof IPackageDeclaration) {
2116      ensureAutolocked((IPackageDeclaration)element);
2117    }
2118    else if(element instanceof IPackageFragment) {
2119      ensureAutolocked((IPackageFragment)element);
2120    }
2121    else if(element instanceof IJavaProject) {
2122      ensureAutolocked((IJavaProject)element);
2123    }
2124  }
2125  
2126  public void ensureAutolocked(final IMethod method) {
2127    if(!isAutolocked(method)) {
2128      internalEnsureAutolocked(method);
2129
2130      ConfigurationEditor editor = getConfigurationEditor();
2131      if(false && editor != null) {
2132        editor.updateLocksPanel();
2133      }
2134      else {
2135        persistConfiguration();
2136      }
2137    }
2138  }
2139
2140  private void internalEnsureAutolocked(final IMethod method) {
2141    IType declaringType = method.getDeclaringType();
2142    
2143    if(!isAdaptable(declaringType)) {
2144      internalEnsureAdaptable(declaringType);
2145    }
2146
2147    Locks locks = ensureLocks();
2148    Autolock lock = locks.addNewAutolock();
2149    
2150    try {
2151      lock.setMethodExpression(PatternHelper.getJavadocSignature(method));
2152      lock.setLockLevel(LockLevel.WRITE);
2153    } catch(JavaModelException jme) {
2154      openError("Error ensuring method '"+
2155                method.getElementName()+"' auto-locked", jme);
2156      return;
2157    }
2158  }
2159
2160  public void ensureAutolocked(final IType type) {
2161    if(!isAutolocked(type)) {
2162      internalEnsureAutolocked(type);
2163
2164      ConfigurationEditor editor = getConfigurationEditor();
2165      if(false && editor != null) {
2166        editor.updateLocksPanel();
2167      }
2168      else {
2169        persistConfiguration();
2170      }
2171    }
2172  }
2173
2174  private void internalEnsureAutolocked(final IType type) {
2175    if(!isAdaptable(type)) {
2176      internalEnsureAdaptable(type);
2177    }
2178
2179    Locks locks = ensureLocks();
2180    Autolock lock = locks.addNewAutolock();
2181    String JavaDoc expr = PatternHelper.getExecutionPattern(type);
2182    
2183    lock.setMethodExpression(expr);
2184    lock.setLockLevel(LockLevel.WRITE);
2185  }
2186
2187  public void ensureAutolocked(final IPackageDeclaration packageDecl) {
2188    if(!isAutolocked(packageDecl)) {
2189      internalEnsureAutolocked(packageDecl);
2190
2191      ConfigurationEditor editor = getConfigurationEditor();
2192      if(false && editor != null) {
2193        editor.updateLocksPanel();
2194      }
2195      else {
2196        persistConfiguration();
2197      }
2198    }
2199  }
2200
2201  private void internalEnsureAutolocked(final IPackageDeclaration packageDecl) {
2202    if(!isAdaptable(packageDecl)) {
2203      internalEnsureAdaptable(packageDecl);
2204    }
2205
2206    Locks locks = ensureLocks();
2207    Autolock lock = locks.addNewAutolock();
2208    String JavaDoc expr = PatternHelper.getExecutionPattern(packageDecl);
2209    
2210    lock.setMethodExpression(expr);
2211    lock.setLockLevel(LockLevel.WRITE);
2212  }
2213  
2214  public void ensureAutolocked(final IPackageFragment fragment) {
2215    if(!isAutolocked(fragment)) {
2216      internalEnsureAutolocked(fragment);
2217
2218      ConfigurationEditor editor = getConfigurationEditor();
2219      if(false && editor != null) {
2220        editor.updateLocksPanel();
2221      }
2222      else {
2223        persistConfiguration();
2224      }
2225    }
2226  }
2227
2228  private void internalEnsureAutolocked(final IPackageFragment fragment) {
2229    if(!isAdaptable(fragment)) {
2230      internalEnsureAdaptable(fragment);
2231    }
2232
2233    Locks locks = ensureLocks();
2234    Autolock lock = locks.addNewAutolock();
2235    String JavaDoc expr = PatternHelper.getExecutionPattern(fragment);
2236    
2237    lock.setMethodExpression(expr);
2238    lock.setLockLevel(LockLevel.WRITE);
2239  }
2240
2241  public void ensureAutolocked(final IJavaProject javaProject) {
2242    if(javaProject != null && !isAutolocked(javaProject)) {
2243      internalEnsureAutolocked(javaProject);
2244
2245      ConfigurationEditor editor = getConfigurationEditor();
2246      if(false && editor != null) {
2247        editor.updateLocksPanel();
2248      }
2249      else {
2250        persistConfiguration();
2251      }
2252    }
2253  }
2254  
2255  private void internalEnsureAutolocked(final IJavaProject javaProject) {
2256    if(javaProject != null) {
2257      IPackageFragment[] fragments = getSourceFragments(javaProject);
2258      
2259      for(int i = 0; i < fragments.length; i++) {
2260        if(!isAutolocked(fragments[i])) {
2261          internalEnsureAutolocked(fragments[i]);
2262        }
2263      }
2264    }
2265  }
2266
2267  public void ensureNotNameLocked(final IJavaElement element) {
2268    if(element instanceof IMethod) {
2269      ensureNotNameLocked((IMethod)element);
2270    }
2271    else if(element instanceof IType) {
2272      ensureNotNameLocked((IType)element);
2273    }
2274    else if(element instanceof IPackageFragment) {
2275      ensureNotNameLocked((IPackageFragment)element);
2276    }
2277    else if(element instanceof IJavaProject) {
2278      ensureNotNameLocked((IJavaProject)element);
2279    }
2280  }
2281
2282  public void ensureNotNameLocked(final IMethod method) {
2283    MethodInfo methodInfo = m_patternHelper.getMethodInfo(method);
2284    
2285    if(methodInfo != null) {
2286      ensureNotNameLocked(methodInfo);
2287    }
2288  }
2289  
2290  public void ensureNotNameLocked(final MethodInfo methodInfo) {
2291    if(isNameLocked(methodInfo)) {
2292      internalEnsureNotNameLocked(methodInfo);
2293
2294      ConfigurationEditor editor = getConfigurationEditor();
2295      if(false && editor != null) {
2296        editor.updateLocksPanel();
2297      }
2298      else {
2299        persistConfiguration();
2300      }
2301    }
2302  }
2303
2304  private void internalEnsureNotNameLocked(final MethodInfo methodInfo) {
2305    Locks locks = getLocks();
2306    
2307    if(locks != null) {
2308      int size = locks.sizeOfNamedLockArray();
2309      String JavaDoc expr;
2310      
2311      for(int i = size-1; i >= 0; i--) {
2312        expr = locks.getNamedLockArray(i).getMethodExpression();
2313        
2314        if(m_patternHelper.matchesMember(expr, methodInfo)) {
2315          locks.removeNamedLock(i);
2316        }
2317      }
2318      
2319      testRemoveLocks();
2320    }
2321  }
2322
2323  public void ensureNotNameLocked(final IType type) {
2324    if(isNameLocked(type)) {
2325      internalEnsureNotNameLocked(type);
2326
2327      ConfigurationEditor editor = getConfigurationEditor();
2328      if(false && editor != null) {
2329        editor.updateLocksPanel();
2330      }
2331      else {
2332        persistConfiguration();
2333      }
2334    }
2335  }
2336  
2337  private void internalEnsureNotNameLocked(final IType type) {
2338    Locks locks = getLocks();
2339    
2340    if(locks != null) {
2341      int size = locks.sizeOfNamedLockArray();
2342      String JavaDoc expr;
2343      String JavaDoc typeExpr;
2344      
2345      typeExpr = PatternHelper.getExecutionPattern(type);
2346      
2347      for(int i = size-1; i >= 0; i--) {
2348        expr = locks.getNamedLockArray(i).getMethodExpression();
2349        
2350        if(typeExpr.equals(expr)) {
2351          locks.removeNamedLock(i);
2352        }
2353      }
2354      
2355      testRemoveLocks();
2356    }
2357  }
2358
2359  public void ensureNotNameLocked(final IPackageDeclaration packageDecl) {
2360    if(isNameLocked(packageDecl)) {
2361      internalEnsureNotNameLocked(packageDecl);
2362
2363      ConfigurationEditor editor = getConfigurationEditor();
2364      if(false && editor != null) {
2365        editor.updateLocksPanel();
2366      }
2367      else {
2368        persistConfiguration();
2369      }
2370    }
2371  }
2372
2373  private void internalEnsureNotNameLocked(final IPackageDeclaration packageDecl) {
2374    Locks locks = getLocks();
2375    
2376    if(locks != null) {
2377      int size = locks.sizeOfNamedLockArray();
2378      String JavaDoc expr;
2379      String JavaDoc fragExpr;
2380      
2381      fragExpr = PatternHelper.getExecutionPattern(packageDecl);
2382      
2383      for(int i = size-1; i >= 0; i--) {
2384        expr = locks.getNamedLockArray(i).getMethodExpression();
2385        
2386        if(fragExpr.equals(expr)) {
2387          locks.removeNamedLock(i);
2388        }
2389      }
2390      
2391      testRemoveLocks();
2392    }
2393  }
2394  
2395  public void ensureNotNameLocked(final IPackageFragment fragment) {
2396    if(isNameLocked(fragment)) {
2397      internalEnsureNotNameLocked(fragment);
2398
2399      ConfigurationEditor editor = getConfigurationEditor();
2400      if(false && editor != null) {
2401        editor.updateLocksPanel();
2402      }
2403      else {
2404        persistConfiguration();
2405      }
2406    }
2407  }
2408
2409  private void internalEnsureNotNameLocked(final IPackageFragment fragment) {
2410    Locks locks = getLocks();
2411    
2412    if(locks != null) {
2413      int size = locks.sizeOfNamedLockArray();
2414      String JavaDoc expr;
2415      String JavaDoc fragExpr;
2416      
2417      fragExpr = PatternHelper.getExecutionPattern(fragment);
2418      
2419      for(int i = size-1; i >= 0; i--) {
2420        expr = locks.getNamedLockArray(i).getMethodExpression();
2421        
2422        if(fragExpr.equals(expr)) {
2423          locks.removeNamedLock(i);
2424        }
2425      }
2426      
2427      testRemoveLocks();
2428    }
2429  }
2430
2431  public void ensureNotNameLocked(final IJavaProject javaProject) {
2432    if(javaProject != null && isNameLocked(javaProject)) {
2433      internalEnsureNotNameLocked(javaProject);
2434
2435      ConfigurationEditor editor = getConfigurationEditor();
2436      if(false && editor != null) {
2437        editor.updateLocksPanel();
2438      }
2439      else {
2440        persistConfiguration();
2441      }
2442    }
2443  }
2444  
2445  private void internalEnsureNotNameLocked(final IJavaProject javaProject) {
2446    IPackageFragment[] fragments = getSourceFragments(javaProject);
2447    
2448    for(int i = 0; i < fragments.length; i++) {
2449      if(isNameLocked(fragments[i])) {
2450        internalEnsureNotNameLocked(fragments[i]);
2451      }
2452    }
2453  }
2454
2455  public void ensureNotAutolocked(final IJavaElement element) {
2456    if(element instanceof IMethod) {
2457      ensureNotAutolocked((IMethod)element);
2458    }
2459    else if(element instanceof IType) {
2460      ensureNotAutolocked((IType)element);
2461    }
2462    else if(element instanceof IPackageFragment) {
2463      ensureNotAutolocked((IPackageFragment)element);
2464    }
2465    else if(element instanceof IJavaProject) {
2466      ensureNotAutolocked((IJavaProject)element);
2467    }
2468  }
2469  
2470  public void ensureNotAutolocked(final IMethod method) {
2471    MethodInfo methodInfo = m_patternHelper.getMethodInfo(method);
2472    
2473    if(methodInfo != null) {
2474      ensureNotAutolocked(methodInfo);
2475    }
2476  }
2477  
2478  public void ensureNotAutolocked(final MethodInfo methodInfo) {
2479    if(isAutolocked(methodInfo)) {
2480      internalEnsureNotAutolocked(methodInfo);
2481
2482      ConfigurationEditor editor = getConfigurationEditor();
2483      if(false && editor != null) {
2484        editor.updateLocksPanel();
2485      }
2486      else {
2487        persistConfiguration();
2488      }
2489    }
2490  }
2491
2492  private void internalEnsureNotAutolocked(final MethodInfo methodInfo) {
2493    Locks locks = getLocks();
2494    
2495    if(locks != null) {
2496      int size = locks.sizeOfAutolockArray();
2497      String JavaDoc expr;
2498      
2499      for(int i = size-1; i >= 0; i--) {
2500        expr = locks.getAutolockArray(i).getMethodExpression();
2501        
2502        if(m_patternHelper.matchesMember(expr, methodInfo)) {
2503          locks.removeAutolock(i);
2504        }
2505      }
2506      
2507      testRemoveLocks();
2508    }
2509  }
2510
2511  public void ensureNotAutolocked(final IType type) {
2512    if(isAutolocked(type)) {
2513      internalEnsureNotAutolocked(type);
2514
2515      ConfigurationEditor editor = getConfigurationEditor();
2516      if(false && editor != null) {
2517        editor.updateLocksPanel();
2518      }
2519      else {
2520        persistConfiguration();
2521      }
2522    }
2523  }
2524  
2525  private void internalEnsureNotAutolocked(final IType type) {
2526    Locks locks = getLocks();
2527    
2528    if(locks != null) {
2529      int size = locks.sizeOfAutolockArray();
2530      String JavaDoc expr;
2531      String JavaDoc typeExpr;
2532      
2533      typeExpr = PatternHelper.getExecutionPattern(type);
2534      
2535      for(int i = size-1; i >= 0; i--) {
2536        expr = locks.getAutolockArray(i).getMethodExpression();
2537        
2538        if(typeExpr.equals(expr)) {
2539          locks.removeAutolock(i);
2540        }
2541      }
2542      
2543      testRemoveLocks();
2544    }
2545  }
2546
2547  public void ensureNotAutolocked(final IPackageDeclaration packageDecl) {
2548    if(isAutolocked(packageDecl)) {
2549      internalEnsureNotAutolocked(packageDecl);
2550
2551      ConfigurationEditor editor = getConfigurationEditor();
2552      if(false && editor != null) {
2553        editor.updateLocksPanel();
2554      }
2555      else {
2556        persistConfiguration();
2557      }
2558    }
2559  }
2560  
2561  private void internalEnsureNotAutolocked(final IPackageDeclaration packageDecl) {
2562    Locks locks = getLocks();
2563      
2564    if(locks != null) {
2565      int size = locks.sizeOfAutolockArray();
2566      String JavaDoc expr;
2567      String JavaDoc fragExpr;
2568      
2569      fragExpr = PatternHelper.getExecutionPattern(packageDecl);
2570      
2571      for(int i = size-1; i >= 0; i--) {
2572        expr = locks.getAutolockArray(i).getMethodExpression();
2573        
2574        if(fragExpr.equals(expr)) {
2575          locks.removeAutolock(i);
2576        }
2577      }
2578      
2579      testRemoveLocks();
2580    }
2581  }
2582  
2583  public void ensureNotAutolocked(final IPackageFragment fragment) {
2584    if(isAutolocked(fragment)) {
2585      internalEnsureNotAutolocked(fragment);
2586
2587      ConfigurationEditor editor = getConfigurationEditor();
2588      if(false && editor != null) {
2589        editor.updateLocksPanel();
2590      }
2591      else {
2592        persistConfiguration();
2593      }
2594    }
2595  }
2596  
2597  private void internalEnsureNotAutolocked(final IPackageFragment fragment) {
2598    Locks locks = getLocks();
2599      
2600    if(locks != null) {
2601      int size = locks.sizeOfAutolockArray();
2602      String JavaDoc expr;
2603      String JavaDoc fragExpr;
2604      
2605      fragExpr = PatternHelper.getExecutionPattern(fragment);
2606      
2607      for(int i = size-1; i >= 0; i--) {
2608        expr = locks.getAutolockArray(i).getMethodExpression();
2609        
2610        if(fragExpr.equals(expr)) {
2611          locks.removeAutolock(i);
2612        }
2613      }
2614      
2615      testRemoveLocks();
2616    }
2617  }
2618
2619  public void ensureNotAutolocked(final IJavaProject javaProject) {
2620    if(javaProject != null && isAutolocked(javaProject)) {
2621      internalEnsureNotAutolocked(javaProject);
2622
2623      ConfigurationEditor editor = getConfigurationEditor();
2624      if(false && editor != null) {
2625        editor.updateLocksPanel();
2626      }
2627      else {
2628        persistConfiguration();
2629      }
2630    }
2631  }
2632  
2633  private void internalEnsureNotAutolocked(final IJavaProject javaProject) {
2634    IPackageFragment[] fragments = getSourceFragments(javaProject);
2635    
2636    for(int i = 0; i < fragments.length; i++) {
2637      if(isAutolocked(fragments[i])) {
2638        internalEnsureNotAutolocked(fragments[i]);
2639      }
2640    }
2641  }
2642
2643  public void ensureNotLocked(final IMethod method) {
2644    MethodInfo methodInfo = m_patternHelper.getMethodInfo(method);
2645    
2646    if(methodInfo != null) {
2647      ensureNotLocked(methodInfo);
2648    }
2649  }
2650
2651  public void ensureNotLocked(final MethodInfo methodInfo) {
2652    if(methodInfo != null) {
2653      boolean persist = false;
2654      
2655      if(isAutolocked(methodInfo)) {
2656        internalEnsureNotAutolocked(methodInfo);
2657        persist = true;
2658      }
2659      
2660      if(isNameLocked(methodInfo)) {
2661        internalEnsureNotNameLocked(methodInfo);
2662        persist = true;
2663      }
2664      
2665      if(persist) {
2666        ConfigurationEditor editor = getConfigurationEditor();
2667        if(false && editor != null) {
2668          editor.updateLocksPanel();
2669        }
2670        else {
2671          persistConfiguration();
2672        }
2673      }
2674    }
2675  }
2676
2677  private void internalEnsureNotLocked(final IMethod method) {
2678    MethodInfo methodInfo = m_patternHelper.getMethodInfo(method);
2679    
2680    if(method != null) {
2681      internalEnsureNotLocked(methodInfo);
2682    }
2683  }
2684
2685  private void internalEnsureNotLocked(final MethodInfo methodInfo) {
2686    if(isAutolocked(methodInfo)) {
2687      internalEnsureNotAutolocked(methodInfo);
2688    }
2689    if(isNameLocked(methodInfo)) {
2690      internalEnsureNotNameLocked(methodInfo);
2691    }
2692  }
2693
2694  public void ensureNotLocked(final IType type) {
2695    boolean persist = false;
2696    
2697    if(isAutolocked(type)) {
2698      internalEnsureNotAutolocked(type);
2699      persist = true;
2700    }
2701    
2702    if(isNameLocked(type)) {
2703      internalEnsureNotNameLocked(type);
2704      persist = true;
2705    }
2706    
2707    if(persist) {
2708      ConfigurationEditor editor = getConfigurationEditor();
2709      if(false && editor != null) {
2710        editor.updateLocksPanel();
2711      }
2712      else {
2713        persistConfiguration();
2714      }
2715    }
2716  }
2717
2718  private void internalEnsureNotLocked(final IType type) {
2719    if(isAutolocked(type)) {
2720      internalEnsureNotAutolocked(type);
2721    }
2722    
2723    if(isNameLocked(type)) {
2724      internalEnsureNotNameLocked(type);
2725    }
2726  }
2727
2728  public void ensureNotLocked(final IPackageFragment fragment) {
2729    boolean persist = false;
2730    
2731    if(isAutolocked(fragment)) {
2732      internalEnsureNotAutolocked(fragment);
2733      persist = true;
2734    }
2735    
2736    if(isNameLocked(fragment)) {
2737      internalEnsureNotNameLocked(fragment);
2738      persist = true;
2739    }
2740    
2741    if(persist) {
2742      ConfigurationEditor editor = getConfigurationEditor();
2743      if(false && editor != null) {
2744        editor.updateLocksPanel();
2745      }
2746      else {
2747        persistConfiguration();
2748      }
2749    }
2750  }
2751
2752  private void internalEnsureNotLocked(final IPackageDeclaration packageDecl) {
2753    if(isAutolocked(packageDecl)) {
2754      internalEnsureNotAutolocked(packageDecl);
2755    }
2756    
2757    if(isNameLocked(packageDecl)) {
2758      internalEnsureNotNameLocked(packageDecl);
2759    }
2760  }
2761
2762  private void internalEnsureNotLocked(final IPackageFragment fragment) {
2763    if(isAutolocked(fragment)) {
2764      internalEnsureNotAutolocked(fragment);
2765    }
2766    
2767    if(isNameLocked(fragment)) {
2768      internalEnsureNotNameLocked(fragment);
2769    }
2770  }
2771
2772  public void ensureNotLocked(final IJavaProject javaProject) {
2773    if(javaProject != null) {
2774      IPackageFragment[] fragments = getSourceFragments(javaProject);
2775      
2776      for(int i = 0; i < fragments.length; i++) {
2777        internalEnsureNotLocked(fragments[i]);
2778      }
2779      
2780      ConfigurationEditor editor = getConfigurationEditor();
2781      if(false && editor != null) {
2782        editor.updateLocksPanel();
2783      }
2784      else {
2785        persistConfiguration();
2786      }
2787    }
2788  }
2789  
2790  public boolean isBootJarClass(ICompilationUnit module) {
2791    return isBootJarClass(module.findPrimaryType());
2792  }
2793
2794  public boolean isBootJarClass(IType type) {
2795    return isBootJarClass(PatternHelper.getFullyQualifiedName(type));
2796  }
2797  
2798  public boolean isBootJarClass(String JavaDoc className) {
2799    AdditionalBootJarClasses classes = getAdditionalBootJarClasses();
2800    
2801    if(classes != null) {
2802      String JavaDoc[] includes = classes.getIncludeArray();
2803
2804      for(int i = 0; i < includes.length; i++) {
2805        if(m_patternHelper.matchesClass(includes[i], className)) {
2806          return true;
2807        }
2808      }
2809    }
2810
2811    return false;
2812  }
2813
2814  public void ensureBootJarClass(final ICompilationUnit module) {
2815    ensureBootJarClass(module.findPrimaryType());
2816  }
2817  
2818  public void ensureBootJarClass(final IType type) {
2819    ensureBootJarClass(PatternHelper.getFullyQualifiedName(type));
2820  }
2821  
2822  private void internalEnsureBootJarClass(final IType type) {
2823    internalEnsureBootJarClass(PatternHelper.getFullyQualifiedName(type));
2824  }
2825  
2826  public void ensureBootJarClass(final String JavaDoc className) {
2827    if(!isBootJarClass(className)) {
2828      internalEnsureBootJarClass(className);
2829
2830      ConfigurationEditor editor = getConfigurationEditor();
2831      if(false && editor != null) {
2832        editor.updateBootClassesPanel();
2833      }
2834      else {
2835        persistConfiguration();
2836      }
2837    }
2838  }
2839
2840  private void internalEnsureBootJarClass(final String JavaDoc className) {
2841    if(!isAdaptable(className)) {
2842      internalEnsureAdaptable(className);
2843    }
2844    ensureAdditionalBootJarClasses().addInclude(className);
2845  }
2846
2847  public void ensureNotBootJarClass(final ICompilationUnit module) {
2848    if(module != null) {
2849      internalEnsureNotBootJarClass(module);
2850
2851      ConfigurationEditor editor = getConfigurationEditor();
2852      if(false && editor != null) {
2853        editor.updateBootClassesPanel();
2854      }
2855      else {
2856        persistConfiguration();
2857      }
2858    }
2859  }
2860  
2861  private void internalEnsureNotBootJarClass(final ICompilationUnit module) {
2862    internalEnsureNotBootJarClass(module.findPrimaryType());
2863  }
2864
2865  public void ensureNotBootJarClass(final IType type) {
2866    if(type != null && isBootJarClass(type)) {
2867      internalEnsureNotBootJarClass(type);
2868
2869      ConfigurationEditor editor = getConfigurationEditor();
2870      if(false && editor != null) {
2871        editor.updateBootClassesPanel();
2872      }
2873      else {
2874        persistConfiguration();
2875      }
2876    }
2877  }
2878  
2879  private void internalEnsureNotBootJarClass(final IType type) {
2880    internalEnsureNotBootJarClass(PatternHelper.getFullyQualifiedName(type));
2881  }
2882
2883  public void ensureNotBootJarClass(final String JavaDoc className) {
2884    if(isBootJarClass(className)) {
2885      internalEnsureNotBootJarClass(className);
2886
2887      ConfigurationEditor editor = getConfigurationEditor();
2888      if(false && editor != null) {
2889        editor.updateBootClassesPanel();
2890      }
2891      else {
2892        persistConfiguration();
2893      }
2894    }
2895  }
2896
2897  private void internalEnsureNotBootJarClass(final String JavaDoc className) {
2898    AdditionalBootJarClasses classes = getAdditionalBootJarClasses();
2899    
2900    if(classes != null) {
2901      String JavaDoc[] includes = classes.getIncludeArray();
2902
2903      for(int i = includes.length-1; i >= 0 ; i--) {
2904        if(m_patternHelper.matchesClass(includes[i], className)) {
2905          classes.removeInclude(i);
2906        }
2907      }
2908    
2909      testRemoveAdditionalBootJarClasses();
2910    }
2911  }
2912
2913  /**
2914   * Are there any bootjar classes specified in the configuration?
2915   */

2916  public boolean hasBootJarClasses() {
2917    AdditionalBootJarClasses classes = getAdditionalBootJarClasses();
2918    return classes != null && classes.sizeOfIncludeArray() > 0;
2919  }
2920  
2921  // Validation support
2922

2923  public void validateAll() {
2924    if(getConfig() != null) {
2925      validateLocks();
2926      validateRoots();
2927      validateTransientFields();
2928      validateInstrumentedClasses();
2929      validateBootJarClasses();
2930    }
2931  }
2932  
2933  private static String JavaDoc LOCK_PROBLEM_MARKER = "org.terracotta.dso.LockMethodProblemMarker";
2934  
2935  private static String JavaDoc getRawString(XmlString xmlString) {
2936    String JavaDoc s = xmlString.toString();
2937    s = s.substring(s.indexOf('>')+1);
2938    s = s.substring(0, s.indexOf('<'));
2939    return s;
2940  }
2941  
2942  public void validateLocks() {
2943    clearConfigProblemMarkersOfType(LOCK_PROBLEM_MARKER);
2944    
2945    Locks locks = getLocks();
2946    
2947    if(locks != null) {
2948      Autolock[] autoLocks = locks.getAutolockArray();
2949      NamedLock[] namedLocks = locks.getNamedLockArray();
2950      
2951      if(autoLocks != null) {
2952        for(int i = 0; i < autoLocks.length; i++) {
2953          validateLockMethodExpression(getRawString(autoLocks[i].xgetMethodExpression()));
2954        }
2955      }
2956      
2957      if(namedLocks != null) {
2958        for(int i = 0; i < namedLocks.length; i++) {
2959          validateLockMethodExpression(getRawString(namedLocks[i].xgetMethodExpression()));
2960        }
2961      }
2962    }
2963  }
2964  
2965  private static String JavaDoc ROOT_PROBLEM_MARKER = "org.terracotta.dso.RootProblemMarker";
2966
2967  public void validateRoots() {
2968    clearConfigProblemMarkersOfType(ROOT_PROBLEM_MARKER);
2969    
2970    Roots roots = getRoots();
2971    
2972    if(roots != null) {
2973      Root[] rootArray = roots.getRootArray();
2974    
2975      for(int i = 0; i < rootArray.length; i++) {
2976        validateRoot(rootArray[i]);
2977      }
2978    }
2979  }
2980  
2981  private static boolean isInterface(IType type) {
2982    try {
2983      return type.isInterface();
2984    } catch(JavaModelException jme) {
2985      return false;
2986    }
2987  }
2988  
2989  private static final String JavaDoc[] PRIMITIVE_NAMES = new String JavaDoc[] {
2990    "java.lang.String",
2991    "java.lang.Integer",
2992    "java.lang.Boolean",
2993    "java.lang.Double",
2994    "java.lang.Character",
2995    "java.lang.Byte"
2996  };
2997  
2998  private static final ArrayList JavaDoc<String JavaDoc> PRIMITIVES = new ArrayList JavaDoc<String JavaDoc>(Arrays.asList(PRIMITIVE_NAMES));
2999  
3000  private static boolean isPrimitive(IType type) {
3001    try {
3002      String JavaDoc name = type.getFullyQualifiedName();
3003      return PRIMITIVES.contains(name);
3004    } catch(Exception JavaDoc e) {
3005      return false;
3006    }
3007  }
3008  
3009  private void validateRoot(Root root) {
3010    String JavaDoc rootName = getRawString(root.xgetFieldName());
3011    String JavaDoc msg = validateField(rootName);
3012    
3013    if(msg == null) {
3014      IField field = getField(root.getFieldName());
3015      IType fieldType = getFieldType(field);
3016      
3017      if(fieldType != null &&
3018         !isInterface(fieldType) &&
3019         !isPrimitive(fieldType) &&
3020         !isAdaptable(fieldType) &&
3021         !isBootJarClass(fieldType))
3022      {
3023        String JavaDoc fullName = PatternHelper.getFullyQualifiedName(fieldType);
3024        msg = "Root type '" + fullName + "' not instrumented";
3025      }
3026    }
3027    
3028    if(msg != null) {
3029      reportConfigProblem(rootName, msg, ROOT_PROBLEM_MARKER);
3030    }
3031  }
3032
3033  private static String JavaDoc TRANSIENT_PROBLEM_MARKER = "org.terracotta.dso.TransientProblemMarker";
3034
3035  public void validateTransientFields() {
3036    clearConfigProblemMarkersOfType(TRANSIENT_PROBLEM_MARKER);
3037    
3038    TransientFields transientFields = getTransientFields();
3039    
3040    if(transientFields != null) {
3041      int size = transientFields.sizeOfFieldNameArray();
3042      String JavaDoc field;
3043    
3044      for(int i = 0; i < size; i++) {
3045        field = getRawString(transientFields.xgetFieldNameArray(i));
3046        validateTransientField(field);
3047      }
3048    }
3049  }
3050  
3051  private void validateTransientField(String JavaDoc fieldName) {
3052    String JavaDoc msg = validateField(fieldName);
3053
3054    if(msg == null) {
3055      IField field = getField(fieldName);
3056      IType declaringType = field.getDeclaringType();
3057      
3058      if(declaringType != null && !isAdaptable(declaringType) && !isBootJarClass(declaringType)) {
3059        String JavaDoc fullName = PatternHelper.getFullyQualifiedName(declaringType);
3060        msg = "Declaring type '" + fullName + "' not instrumented";
3061      }
3062    }
3063
3064    if(msg != null) {
3065      reportConfigProblem(fieldName, msg, TRANSIENT_PROBLEM_MARKER);
3066    }
3067  }
3068
3069  private static String JavaDoc
3070    INSTRUMENTED_PROBLEM_MARKER = "org.terracotta.dso.InstrumentedProblemMarker";
3071  
3072  public void validateInstrumentedClasses() {
3073    clearConfigProblemMarkersOfType(INSTRUMENTED_PROBLEM_MARKER);
3074
3075    InstrumentedClasses instrumentedClasses = getInstrumentedClasses();
3076    
3077    if(instrumentedClasses != null) {
3078      validateIncludes(instrumentedClasses);
3079      validateExcludes(instrumentedClasses);
3080    }
3081  }
3082
3083  private void validateIncludes(InstrumentedClasses instrumentedClasses) {
3084    int size = instrumentedClasses.sizeOfIncludeArray();
3085    Include include;
3086    String JavaDoc expr;
3087    
3088    for(int i = 0; i < size; i++) {
3089      include = instrumentedClasses.getIncludeArray(i);
3090      expr = getRawString(include.xgetClassExpression());
3091
3092      validateInstrumentedTypeExpression(expr);
3093    }
3094  }
3095  
3096  private void validateExcludes(InstrumentedClasses instrumentedClasses) {
3097    int size = instrumentedClasses.sizeOfExcludeArray();
3098    String JavaDoc exclude;
3099
3100    for(int i = 0; i < size; i++) {
3101      exclude = getRawString(instrumentedClasses.xgetExcludeArray(i));
3102      validateInstrumentedTypeExpression(exclude);
3103    }
3104  }
3105  
3106  private void validateInstrumentedTypeExpression(String JavaDoc typeExpr) {
3107    String JavaDoc msg = null;
3108    String JavaDoc expr = typeExpr != null ? typeExpr.trim() : null;
3109    
3110    if(expr != null && (expr.indexOf('*') != -1 || expr.indexOf('+') != -1)) {
3111      return;
3112    }
3113    
3114    try {
3115      if(JdtUtils.findType(m_javaProject, expr) != null) {
3116        return;
3117      }
3118    } catch(JavaModelException jme) {/**/}
3119    
3120    if(expr != null && expr.length() > 0) {
3121      String JavaDoc prefix = findTypeExpressionPrefix(expr);
3122      
3123      try {
3124        IPackageFragment[] fragments = m_javaProject.getPackageFragments();
3125        IPackageFragment fragment;
3126        
3127        for(int i = 0; i < fragments.length; i++) {
3128          fragment = fragments[i];
3129          
3130          if(fragment.getKind() == IPackageFragmentRoot.K_SOURCE &&
3131             fragment.getElementName().startsWith(prefix))
3132          {
3133            ICompilationUnit[] cus = fragment.getCompilationUnits();
3134            ICompilationUnit cu;
3135            String JavaDoc cuType;
3136            
3137            for(int j = 0; j < cus.length; j++) {
3138              cu = cus[j];
3139              cuType = PatternHelper.getFullyQualifiedName(cu.findPrimaryType());
3140              
3141              if(cuType.startsWith(prefix)) {
3142                IType[] types = cus[j].getAllTypes();
3143                IType type;
3144                
3145                for(int k = 0; k < types.length; k++) {
3146                  type = types[k];
3147                  
3148                  if(!type.isInterface()) {
3149                    if(matchesType(expr, type)) {
3150                      return;
3151                    }
3152                  }
3153                }
3154              }
3155            }
3156          }
3157        }
3158        
3159        for(int i = 0; i < fragments.length; i++) {
3160          fragment = fragments[i];
3161          
3162          if(fragment.getKind() == IPackageFragmentRoot.K_BINARY &&
3163             fragment.getElementName().startsWith(prefix))
3164          {
3165            IClassFile[] classFiles = fragment.getClassFiles();
3166            IType type;
3167            String JavaDoc typeName;
3168            int flags;
3169            
3170            for(int j = 0; j < classFiles.length; j++) {
3171              type = classFiles[j].getType();
3172              typeName = PatternHelper.getFullyQualifiedName(type);
3173              flags = type.getFlags();
3174              
3175              if(typeName.startsWith(prefix)) {
3176                if(!type.isInterface() &&
3177                   !type.isAnonymous() &&
3178                   !type.isMember() &&
3179                   !type.isEnum() &&
3180                   !type.isAnnotation() &&
3181                   !Flags.isProtected(flags) &&
3182                   !Flags.isPrivate(flags) &&
3183                   !Flags.isStatic(flags))
3184                {
3185                  if(matchesType(expr, type)) {
3186                    return;
3187                  }
3188                }
3189              }
3190            }
3191          }
3192        }
3193        
3194        msg = "No type matches expression '"+expr+"'";
3195      }
3196      catch(JavaModelException jme) {
3197        msg = jme.getMessage();
3198      }
3199    }
3200    else {
3201      msg = "Empty AspectWerks class expression";
3202    }
3203    
3204    if(msg != null) {
3205      reportConfigProblem(typeExpr, msg, INSTRUMENTED_PROBLEM_MARKER);
3206    }
3207  }
3208
3209  private String JavaDoc findTypeExpressionPrefix(String JavaDoc typeExpr) {
3210    String JavaDoc[] elems = StringUtils.split(typeExpr, '.');
3211    char[] codes = new char[] {'*', '?', '.', '$'};
3212    ArrayList JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
3213    String JavaDoc elem;
3214    
3215    for(int i = 0; i < elems.length; i++) {
3216      elem = elems[i];
3217      
3218      if(elem.length() > 0 && StringUtils.containsNone(elems[i], codes)) {
3219        list.add(elem);
3220      }
3221    }
3222    
3223    return StringUtils.join(list.toArray(), '.');
3224  }
3225  
3226  private boolean matchesType(String JavaDoc typeExpr, IType type) {
3227    String JavaDoc name = PatternHelper.getFullyQualifiedName(type);
3228    int nameLen = name.length();
3229    int exprLen = typeExpr.length();
3230    char ec;
3231
3232    if(typeExpr.equals(name)) {
3233      return true;
3234    }
3235    
3236    for(int z = 0; z < exprLen; z++) {
3237      ec = typeExpr.charAt(z);
3238      
3239      if(z == nameLen || name.charAt(z) != ec) {
3240        if(ec == '.' || ec == '*' || ec == '?') {
3241          return m_patternHelper.matchesType(typeExpr, type);
3242        }
3243        break;
3244      }
3245    }
3246
3247    return false;
3248  }
3249  
3250  private void validateLockMethodExpression(String JavaDoc methodExpr) {
3251    String JavaDoc msg = validateMethodExpression(methodExpr);
3252    
3253    if(msg != null) {
3254      reportConfigProblem(methodExpr, msg, LOCK_PROBLEM_MARKER);
3255    }
3256  }
3257
3258  private static String JavaDoc
3259    DISTRIBUTED_METHOD_PROBLEM_MARKER = "org.terracotta.dso.DistributedMethodProblemMarker";
3260
3261  public void validateDistributedMethods() {
3262    clearConfigProblemMarkersOfType(DISTRIBUTED_METHOD_PROBLEM_MARKER);
3263    
3264    DistributedMethods distributedMethods = getDistributedMethods();
3265
3266    if(distributedMethods != null) {
3267      int size = distributedMethods.sizeOfMethodExpressionArray();
3268      String JavaDoc methodExpr;
3269    
3270      for(int i = 0; i < size; i++) {
3271        methodExpr = distributedMethods.getMethodExpressionArray(i).getStringValue();
3272        validateDistributedMethodExpression(methodExpr);
3273      }
3274    }
3275  }
3276  
3277  private void validateDistributedMethodExpression(String JavaDoc methodExpr) {
3278    String JavaDoc msg = validateMethodExpression(methodExpr);
3279    
3280    if(msg != null) {
3281      reportConfigProblem(methodExpr, msg, DISTRIBUTED_METHOD_PROBLEM_MARKER);
3282    }
3283  }
3284
3285  private String JavaDoc validateField(String JavaDoc fullName) {
3286    String JavaDoc msg = null;
3287    int lastDotIndex;
3288
3289    if(fullName != null) {
3290      fullName = fullName.trim();
3291    }
3292    
3293    if(fullName != null &&
3294       (fullName.length() > 0) &&
3295       (lastDotIndex = fullName.lastIndexOf('.')) != -1)
3296    {
3297      String JavaDoc className = fullName.substring(0, lastDotIndex).replace('$', '.');
3298      String JavaDoc fieldName = fullName.substring(lastDotIndex+1);
3299          
3300      try {
3301        IType type;
3302        IField field;
3303        
3304        if((type = JdtUtils.findType(m_javaProject, className)) == null) {
3305          msg = "Class not found: " + className;
3306        }
3307        else if((field = type.getField(fieldName)) == null || !field.exists()) {
3308          msg = "No such field: " + fieldName;
3309        }
3310      } catch(JavaModelException jme) {
3311        msg = jme.getMessage();
3312      }
3313    }
3314    else {
3315      msg = "Must be a fully-qualified field name";
3316    }
3317
3318    return msg;
3319  }
3320
3321  private String JavaDoc validateMethodExpression(String JavaDoc methodExpr) {
3322    String JavaDoc msg = null;
3323
3324    if(methodExpr != null && methodExpr.length() > 0) {
3325      try {
3326        m_patternHelper.testValidateMethodExpression(methodExpr);
3327      } catch(Exception JavaDoc e) {
3328        return e.getMessage();
3329      }
3330      
3331      try {
3332        String JavaDoc prefix = findMethodExpressionPrefix(methodExpr);
3333        
3334        if(prefix != null && prefix.length() > 0) {
3335          try {
3336            IType type = JdtUtils.findType(m_javaProject, prefix);
3337            
3338            if(type != null) {
3339              IMethod[] methods = type.getMethods();
3340              
3341              for(int m = 0; m < methods.length; m++) {
3342                if(m_patternHelper.matchesMethod(methodExpr, methods[m])) {
3343                  return null;
3344                }
3345              }
3346            }
3347          } catch(JavaModelException jme) {/**/}
3348        }
3349
3350        IPackageFragment[] fragments = m_javaProject.getPackageFragments();
3351        IPackageFragment fragment;
3352
3353        for(int i = 0; i < fragments.length; i++) {
3354          fragment = fragments[i];
3355          
3356          if(fragment.getKind() == IPackageFragmentRoot.K_SOURCE &&
3357             fragment.getElementName().startsWith(prefix))
3358          {
3359            ICompilationUnit[] cus = fragment.getCompilationUnits();
3360            ICompilationUnit cu;
3361            String JavaDoc cuType;
3362            
3363            for(int j = 0; j < cus.length; j++) {
3364              cu = cus[j];
3365              cuType = PatternHelper.getFullyQualifiedName(cu.findPrimaryType());
3366              
3367              if(cuType.startsWith(prefix)) {
3368                IType[] types = cus[j].getAllTypes();
3369                IType type;
3370                
3371                for(int k = 0; k < types.length; k++) {
3372                  type = types[k];
3373                  
3374                  if(!type.isInterface() && !type.isAnonymous()) {
3375                    if(matchesMethod(methodExpr, type)) {
3376                      return null;
3377                    }
3378                  }
3379                }
3380              }
3381            }
3382          }
3383        }
3384        
3385        for(int i = 0; i < fragments.length; i++) {
3386          fragment = fragments[i];
3387          
3388          if(fragment.getKind() == IPackageFragmentRoot.K_BINARY &&
3389             fragment.getElementName().startsWith(prefix))
3390          {
3391            IClassFile[] classFiles = fragment.getClassFiles();
3392            IType type;
3393            String JavaDoc typeName;
3394            int flags;
3395            
3396            for(int j = 0; j < classFiles.length; j++) {
3397              type = classFiles[j].getType();
3398              typeName = PatternHelper.getFullyQualifiedName(type);
3399              flags = type.getFlags();
3400              
3401              if(typeName.startsWith(prefix)) {
3402                if(!type.isInterface() &&
3403                   !type.isAnonymous() &&
3404                   !type.isMember() &&
3405                   !type.isEnum() &&
3406                   !type.isAnnotation() &&
3407                   !Flags.isPrivate(flags) &&
3408                   !Flags.isProtected(flags) &&
3409                   !Flags.isStatic(flags))
3410                {
3411                  if(matchesMethod(methodExpr, type)) {
3412                    return null;
3413                  }
3414                }
3415              }
3416            }
3417          }
3418        }
3419          
3420        msg = "No method matching expression '" + methodExpr + "'";
3421      } catch(JavaModelException jme) {
3422        msg = jme.getMessage();
3423      }
3424    }
3425    else {
3426      msg = "Must be a fully-qualified method name";
3427    }
3428    
3429    return msg;
3430  }
3431
3432  private String JavaDoc findMethodExpressionPrefix(String JavaDoc methodExpr) {
3433    String JavaDoc[] comps = StringUtils.split(methodExpr);
3434    String JavaDoc exprBody = comps.length > 1 ? comps[1] : comps[0];
3435    String JavaDoc[] elems = StringUtils.split(exprBody, '.');
3436    char[] codes = new char[] {'*', '?', '(', ')', '$'};
3437    ArrayList JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
3438    String JavaDoc elem;
3439    
3440    for(int i = 0; i < elems.length; i++) {
3441      elem = elems[i];
3442      
3443      if(elem.length() > 0 && StringUtils.containsNone(elems[i], codes)) {
3444        list.add(elem);
3445      }
3446      else {
3447        break;
3448      }
3449    }
3450    
3451    return StringUtils.join(list.toArray(), '.');
3452  }
3453  
3454  private boolean matchesMethod(String JavaDoc methodExpr, IType type) {
3455    String JavaDoc[] comps = StringUtils.split(methodExpr);
3456    String JavaDoc exprBody = comps.length > 1 ? comps[1] : comps[0];
3457    int exprBodyLen = exprBody.length();
3458    String JavaDoc name = PatternHelper.getFullyQualifiedName(type);
3459    int nameLen = name.length();
3460    char ebc;
3461    
3462    for(int z = 0; z < exprBodyLen; z++) {
3463      ebc = exprBody.charAt(z);
3464      
3465      if(z == nameLen || ebc != name.charAt(z)) {
3466        if(ebc == '.' || ebc == '*' || ebc == '?' || ebc == '(') {
3467          try {
3468            IMethod[] methods = type.getMethods();
3469            IMethod method;
3470            
3471            for(int m = 0; m < methods.length; m++) {
3472              method = methods[m];
3473              
3474              if(m_patternHelper.matchesMethod(methodExpr, method)) {
3475                return true;
3476              }
3477            }
3478          } catch(JavaModelException jme) {
3479            return false;
3480          }
3481        }
3482
3483        return false;
3484      }
3485    }
3486    
3487    // exact match
3488
return true;
3489  }
3490  
3491  private static String JavaDoc
3492    BOOT_CLASS_PROBLEM_MARKER = "org.terracotta.dso.BootClassProblemMarker";
3493
3494  public void validateBootJarClasses() {
3495    clearConfigProblemMarkersOfType(BOOT_CLASS_PROBLEM_MARKER);
3496
3497    AdditionalBootJarClasses classes = getAdditionalBootJarClasses();
3498
3499    if(classes != null) {
3500      int size = classes.sizeOfIncludeArray();
3501      String JavaDoc include;
3502      
3503      for(int i = 0; i < size; i++) {
3504        include = getRawString(classes.xgetIncludeArray(i));
3505        validateBootJarClass(include);
3506      }
3507    }
3508  }
3509  
3510  private void validateBootJarClass(String JavaDoc classExpr) {
3511    String JavaDoc msg = null;
3512    String JavaDoc expr = classExpr;
3513    
3514    if(expr != null) {
3515      expr = expr.trim();
3516    }
3517    
3518    try {
3519      if(JdtUtils.findType(m_javaProject, expr) == null) {
3520        msg = "Cannot resolve type '" + expr + "'";
3521      }
3522    } catch(JavaModelException jme) {
3523      msg = "Cannot resolve type '" + expr + "'";
3524    }
3525    
3526    if(msg != null) {
3527      reportConfigProblem(classExpr, msg, BOOT_CLASS_PROBLEM_MARKER);
3528    }
3529  }
3530  
3531  private void reportConfigProblem(
3532    String JavaDoc configText,
3533    String JavaDoc msg,
3534    String JavaDoc markerType)
3535  {
3536    ConfigurationEditor editor = m_plugin.getConfigurationEditor(m_project);
3537    
3538    if(editor != null) {
3539      editor.applyProblemToText(configText, msg, markerType);
3540    }
3541    else {
3542      IFile file = m_plugin.getConfigurationFile(m_project);
3543      InputStream JavaDoc in = null;
3544
3545      try {
3546        String JavaDoc text = IOUtils.toString(in = file.getContents());
3547        Document doc = new Document(text);
3548      
3549        applyProblemToText(doc, configText, msg, markerType);
3550      } catch(Exception JavaDoc e) {
3551        m_plugin.openError("Problem reporting config problem", e);
3552      }
3553      finally {
3554        IOUtils.closeQuietly(in);
3555      }
3556    }
3557  }
3558  
3559  public void applyProblemToText(
3560    IDocument doc,
3561    String JavaDoc text,
3562    String JavaDoc msg,
3563    String JavaDoc markerType)
3564  {
3565    TcPlugin plugin = TcPlugin.getDefault();
3566    FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(doc);
3567    IRegion region;
3568   
3569    try {
3570      text = "\\Q"+text+"\\E";
3571      if((region = finder.find(0, text, true, true, false, true)) != null) {
3572        HashMap JavaDoc<String JavaDoc, Object JavaDoc> map = new HashMap JavaDoc<String JavaDoc, Object JavaDoc>();
3573        int start = region.getOffset();
3574        int end = start + region.getLength();
3575        int line = doc.getLineOfOffset(start)-1;
3576        
3577        MarkerUtilities.setMessage(map, msg);
3578        MarkerUtilities.setLineNumber(map, line);
3579        MarkerUtilities.setCharStart(map, start);
3580        MarkerUtilities.setCharEnd(map, end);
3581          
3582        map.put(IMarker.PRIORITY, new Integer JavaDoc(IMarker.PRIORITY_HIGH));
3583        map.put(IMarker.SEVERITY, new Integer JavaDoc(IMarker.SEVERITY_WARNING));
3584        map.put(IMarker.LOCATION, "line " + line);
3585            
3586        IFile configFile = plugin.getConfigurationFile(m_project);
3587        MarkerUtilities.createMarker(configFile, map, markerType);
3588      }
3589    } catch(Exception JavaDoc e2) {
3590      plugin.openError("Problem creating marker '"+markerType+"'", e2);
3591    }
3592  }
3593
3594  public TcConfig getConfig() {
3595    return m_plugin.getConfiguration(m_project);
3596  }
3597  
3598  private DsoApplication ensureDsoApplication() {
3599    DsoApplication dsoApp = null;
3600    TcConfig config = getConfig();
3601    
3602    if(config != null) {
3603      Application app = config.getApplication();
3604      
3605      if(app == null) {
3606        app = config.addNewApplication();
3607      }
3608      
3609      if((dsoApp = app.getDso()) == null) {
3610        dsoApp = app.addNewDso();
3611        dsoApp.addNewInstrumentedClasses();
3612      }
3613    }
3614    
3615    return dsoApp;
3616  }
3617
3618  private Application getApplication() {
3619    TcConfig config = getConfig();
3620    return config != null ? config.getApplication() : null;
3621  }
3622
3623  private void testRemoveApplication() {
3624    Application app = getApplication();
3625    
3626    if(app != null) {
3627      if(!app.isSetDso()) {
3628        getConfig().unsetApplication();
3629      }
3630    }
3631  }
3632  
3633  private DsoApplication getDsoApplication() {
3634    Application app = getApplication();
3635    return app != null ? app.getDso() : null;
3636  }
3637  
3638  private void testRemoveDsoApplication() {
3639    DsoApplication dsoApp = getDsoApplication();
3640    
3641    if(dsoApp != null) {
3642      InstrumentedClasses classes = dsoApp.getInstrumentedClasses();
3643      boolean hasClasses = classes.sizeOfExcludeArray() > 0 ||
3644                                       classes.sizeOfIncludeArray() > 0;
3645      
3646      if(!dsoApp.isSetAdditionalBootJarClasses() &&
3647         !dsoApp.isSetDistributedMethods() &&
3648         !hasClasses &&
3649         !dsoApp.isSetLocks() &&
3650         !dsoApp.isSetRoots() &&
3651         !dsoApp.isSetTransientFields())
3652      {
3653        getApplication().unsetDso();
3654        testRemoveApplication();
3655      }
3656    }
3657  }
3658  
3659  private Roots getRoots() {
3660    DsoApplication dsoApp = getDsoApplication();
3661    return dsoApp != null ? dsoApp.getRoots() : null;
3662  }
3663  
3664  private Roots ensureRoots() {
3665    DsoApplication dsoApp = ensureDsoApplication();
3666    Roots roots = dsoApp.getRoots();
3667
3668    return roots != null ? roots : dsoApp.addNewRoots();
3669  }
3670  
3671  private void testRemoveRoots() {
3672    DsoApplication dsoApp = getDsoApplication();
3673    
3674    if(dsoApp != null) {
3675      Roots roots = dsoApp.getRoots();
3676    
3677      if(roots.sizeOfRootArray() == 0) {
3678        dsoApp.unsetRoots();
3679        testRemoveDsoApplication();
3680      }
3681    }
3682  }
3683  
3684  private DistributedMethods getDistributedMethods() {
3685    DsoApplication dsoApp = getDsoApplication();
3686    return dsoApp != null ? dsoApp.getDistributedMethods() : null;
3687  }
3688  
3689  private DistributedMethods ensureDistributedMethods() {
3690    DsoApplication dsoApp = ensureDsoApplication();
3691    DistributedMethods methods = dsoApp.getDistributedMethods();
3692    
3693    if(methods == null) {
3694      methods = dsoApp.addNewDistributedMethods();
3695    }
3696    
3697    return methods;
3698  }
3699  
3700  private void testRemoveDistributedMethods() {
3701    DistributedMethods methods = getDistributedMethods();
3702    
3703    if(methods != null) {
3704      if(methods.sizeOfMethodExpressionArray() == 0) {
3705        getDsoApplication().unsetDistributedMethods();
3706        testRemoveDsoApplication();
3707      }
3708    }
3709  }
3710  
3711  private Locks getLocks() {
3712    DsoApplication dsoApp = getDsoApplication();
3713    return dsoApp != null ? dsoApp.getLocks() : null;
3714  }
3715 
3716  private Locks ensureLocks() {
3717    DsoApplication dsoApp = ensureDsoApplication();
3718    Locks locks = dsoApp.getLocks();
3719    
3720    if(locks == null) {
3721      locks = dsoApp.addNewLocks();
3722    }
3723    
3724    return locks;
3725  }
3726  
3727  private void testRemoveLocks() {
3728    Locks locks = getLocks();
3729    
3730    if(locks != null) {
3731      if(locks.sizeOfAutolockArray() == 0 &&
3732         locks.sizeOfNamedLockArray() == 0)
3733      {
3734        getDsoApplication().unsetLocks();
3735        testRemoveDsoApplication();
3736      }
3737    }
3738  }
3739  
3740  private InstrumentedClasses getInstrumentedClasses() {
3741    DsoApplication dsoApp = getDsoApplication();
3742    return dsoApp != null ? dsoApp.getInstrumentedClasses() : null;
3743  }
3744
3745  private InstrumentedClasses ensureInstrumentedClasses() {
3746    DsoApplication dsoApp = ensureDsoApplication();
3747    InstrumentedClasses classes = dsoApp.getInstrumentedClasses();
3748    
3749    if(classes == null) {
3750      classes = dsoApp.addNewInstrumentedClasses();
3751    }
3752    
3753    return classes;
3754  }
3755  
3756  private void testRemoveInstrumentedClasses() {
3757    InstrumentedClasses ic = getInstrumentedClasses();
3758    if(ic != null) {
3759      if(ic.sizeOfExcludeArray() == 0 && ic.sizeOfIncludeArray() == 0) {
3760        getDsoApplication().unsetInstrumentedClasses();
3761        testRemoveDsoApplication();
3762      }
3763    }
3764  }
3765  
3766  private AdditionalBootJarClasses getAdditionalBootJarClasses() {
3767    return ensureDsoApplication().getAdditionalBootJarClasses();
3768  }
3769  
3770  private AdditionalBootJarClasses ensureAdditionalBootJarClasses() {
3771    DsoApplication dsoApp = ensureDsoApplication();
3772    AdditionalBootJarClasses abjc = dsoApp.getAdditionalBootJarClasses();
3773
3774    return abjc != null ? abjc : dsoApp.addNewAdditionalBootJarClasses();
3775  }
3776  
3777  private void testRemoveAdditionalBootJarClasses() {
3778    DsoApplication dsoApp = getDsoApplication();
3779    
3780    if(dsoApp != null) {
3781      AdditionalBootJarClasses abjc = dsoApp.getAdditionalBootJarClasses();
3782    
3783      if(abjc.sizeOfIncludeArray() == 0) {
3784        dsoApp.unsetAdditionalBootJarClasses();
3785        testRemoveDsoApplication();
3786      }
3787    }
3788  }
3789  
3790  public Servers getServers() {
3791    TcConfig config = getConfig();
3792    return config != null ? config.getServers() : null;
3793  }
3794  
3795  private static IPackageFragment[] getSourceFragments(IJavaProject javaProject) {
3796    ArrayList JavaDoc<IPackageFragment> list = new ArrayList JavaDoc<IPackageFragment>();
3797
3798    try {
3799      IPackageFragment[] fragments = javaProject.getPackageFragments();
3800      
3801      for(int i = 0; i < fragments.length; i++) {
3802        if(isSourceFragment(fragments[i])) {
3803          list.add(fragments[i]);
3804        }
3805      }
3806    } catch(JavaModelException jme) {/**/}
3807    
3808    return list.toArray(new IPackageFragment[0]);
3809
3810  }
3811  
3812  private static boolean isSourceFragment(final IPackageFragment fragment) {
3813    try {
3814      return fragment.getKind() == IPackageFragmentRoot.K_SOURCE &&
3815             hasCompilationUnits(fragment);
3816    } catch(JavaModelException jme) {
3817      return false;
3818    }
3819  }
3820  
3821  private static boolean hasCompilationUnits(IPackageFragment fragment) {
3822    try {
3823      IResource resource = fragment.getResource();
3824      int type = resource.getType();
3825      IContainer container = null;
3826
3827      switch(type) {
3828        case IResource.PROJECT: {
3829          IProject project = (IProject)resource;
3830          String JavaDoc name = fragment.getElementName();
3831          
3832          if(name.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) {
3833            container = project;
3834          }
3835          else {
3836            String JavaDoc path = fragment.getElementName().replace('.', '/');
3837            container = project.getFolder(project.getLocation().append(path));
3838          }
3839          break;
3840        }
3841        case IResource.FOLDER:
3842          container = (IFolder)resource;
3843          break;
3844      }
3845
3846      if(container != null) {
3847        IResource[] members = container.members();
3848        IResource member;
3849        
3850        for(int i = 0; i < members.length; i++) {
3851          member = members[i];
3852          
3853          if(member.getType() == IResource.FILE &&
3854             member.getFileExtension().equals("java"))
3855          {
3856            return true;
3857          }
3858        }
3859      }
3860    } catch(CoreException ce) {/**/}
3861    
3862
3863    return false;
3864  }
3865  
3866  private void openError(String JavaDoc msg, Throwable JavaDoc t) {
3867    m_plugin.openError(msg, t);
3868  }
3869  
3870  public ConfigurationEditor getConfigurationEditor() {
3871    return m_plugin.getConfigurationEditor(m_project);
3872  }
3873  
3874  public void persistConfiguration() {
3875    ConfigurationEditor editor = getConfigurationEditor();
3876    
3877    if(false && editor != null) {
3878      editor.setDirty();
3879    }
3880    else {
3881      m_plugin.saveConfiguration(m_project);
3882    }
3883  }
3884  
3885  private void clearConfigProblemMarkersOfType(String JavaDoc markerType) {
3886    m_plugin.clearConfigProblemMarkersOfType(m_project, markerType);
3887  }
3888}
3889
Popular Tags