001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package org.terracotta.dso.views;
006:
007: import org.eclipse.jface.viewers.ITreeContentProvider;
008: import org.eclipse.jface.viewers.Viewer;
009:
010: import com.terracottatech.config.Application;
011: import com.terracottatech.config.DsoApplication;
012: import com.terracottatech.config.TcConfigDocument.TcConfig;
013:
014: public class ConfigContentProvider implements ITreeContentProvider {
015: RootsWrapper rootsWrapper;
016: LocksWrapper locksWrapper;
017: AutolocksWrapper autolocksWrapper;
018: NamedLocksWrapper namedLocksWrapper;
019: TransientFieldsWrapper transientFieldsWrapper;
020: InstrumentedClassesWrapper instrumentedClassesWrapper;
021: IncludesWrapper includesWrapper;
022: ExcludesWrapper excludesWrapper;
023: DistributedMethodsWrapper distributedMethodsWrapper;
024: AdditionalBootJarClassesWrapper additionalBootJarClassesWrapper;
025:
026: public Object[] getChildren(Object parentElement) {
027: if (parentElement instanceof RootsWrapper) {
028: return ((RootsWrapper) parentElement).createRootWrappers();
029: } else if (parentElement instanceof TransientFieldsWrapper) {
030: return ((TransientFieldsWrapper) parentElement)
031: .createTransientFieldWrappers();
032: } else if (parentElement instanceof AdditionalBootJarClassesWrapper) {
033: return ((AdditionalBootJarClassesWrapper) parentElement)
034: .createBootClassWrappers();
035: } else if (parentElement instanceof DistributedMethodsWrapper) {
036: return ((DistributedMethodsWrapper) parentElement)
037: .createDistributedMethodWrappers();
038: } else if (parentElement instanceof LocksWrapper) {
039: LocksWrapper locks = (LocksWrapper) parentElement;
040: return new Object[] {
041: autolocksWrapper = new AutolocksWrapper(locks),
042: namedLocksWrapper = new NamedLocksWrapper(locks) };
043: } else if (parentElement instanceof InstrumentedClassesWrapper) {
044: InstrumentedClassesWrapper ic = ((InstrumentedClassesWrapper) parentElement);
045: return new Object[] {
046: includesWrapper = new IncludesWrapper(ic),
047: excludesWrapper = new ExcludesWrapper(ic) };
048: } else if (parentElement instanceof AutolocksWrapper) {
049: return ((AutolocksWrapper) parentElement)
050: .createAutolockWrappers();
051: } else if (parentElement instanceof NamedLocksWrapper) {
052: return ((NamedLocksWrapper) parentElement)
053: .createNamedLockWrappers();
054: } else if (parentElement instanceof IncludesWrapper) {
055: return ((IncludesWrapper) parentElement)
056: .createIncludeWrappers();
057: } else if (parentElement instanceof ExcludesWrapper) {
058: return ((ExcludesWrapper) parentElement)
059: .createExcludeWrappers();
060: }
061:
062: return null;
063: }
064:
065: public Object getParent(Object element) {
066: return null;
067: }
068:
069: public boolean hasChildren(Object element) {
070: return element instanceof TreeRoot
071: || element instanceof RootsWrapper
072: && ((RootsWrapper) element).sizeOfRootArray() > 0
073: || element instanceof LocksWrapper
074: || element instanceof AutolocksWrapper
075: && ((AutolocksWrapper) element).sizeOfAutolockArray() > 0
076: || element instanceof NamedLocksWrapper
077: && ((NamedLocksWrapper) element).sizeOfNamedLockArray() > 0
078: || element instanceof InstrumentedClassesWrapper
079: || element instanceof IncludesWrapper
080: && ((IncludesWrapper) element).sizeOfIncludeArray() > 0
081: || element instanceof ExcludesWrapper
082: && ((ExcludesWrapper) element).sizeOfExcludeArray() > 0
083: || element instanceof TransientFieldsWrapper
084: && ((TransientFieldsWrapper) element)
085: .sizeOfFieldNameArray() > 0
086: || element instanceof AdditionalBootJarClassesWrapper
087: && ((AdditionalBootJarClassesWrapper) element)
088: .sizeOfIncludeArray() > 0
089: || element instanceof DistributedMethodsWrapper
090: && ((DistributedMethodsWrapper) element)
091: .sizeOfMethodExpressionArray() > 0;
092: }
093:
094: public Object[] getElements(Object inputElement) {
095: if (inputElement == TreeRoot.EMPTY_ROOT) {
096: return new Object[0];
097: } else if (inputElement instanceof TreeRoot) {
098: TcConfig config = ((TreeRoot) inputElement).getRoot();
099: if (config == null) {
100: return new Object[0];
101: } else {
102: Application app = config.getApplication();
103: if (app == null)
104: app = config.addNewApplication();
105: DsoApplication dsoApp = app.getDso();
106: if (dsoApp == null)
107: dsoApp = app.addNewDso();
108:
109: return new Object[] {
110: rootsWrapper = new RootsWrapper(dsoApp),
111: locksWrapper = new LocksWrapper(dsoApp),
112: transientFieldsWrapper = new TransientFieldsWrapper(
113: dsoApp),
114: instrumentedClassesWrapper = new InstrumentedClassesWrapper(
115: dsoApp),
116: distributedMethodsWrapper = new DistributedMethodsWrapper(
117: dsoApp),
118: additionalBootJarClassesWrapper = new AdditionalBootJarClassesWrapper(
119: dsoApp) };
120: }
121: }
122: return null;
123: }
124:
125: public void dispose() {
126: /**/
127: }
128:
129: public void inputChanged(Viewer viewer, Object oldInput,
130: Object newInput) {
131: /**/
132: }
133: }
|