CasViewerEclipsePlugin/uimaj-ep-casviewer-core/src/main/java/org/apache/uima/casviewer/ui/internal/style/ColoredTypeTreeSectionPart.java [233:423]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public TypeNode getTypeNode (String typeFullName) {
        if (_typeHierarchy != null) {
            return _typeHierarchy.getTypeNode(typeFullName);
        }
        return null;
    }
    
    public Control getTreeControl ()
    {
        return treeViewer.getControl();
    }
    
    public TreeViewer getTreeViewer ()
    {
        return treeViewer;
    }
    
    public void addTypesToHierarchy (ArrayList types)
    {
        _typeHierarchy.addTypesToHierarchy(types);
        // Refresh Tree
        treeViewer.refresh();
        section.redraw();
        section.update();    
    }
    
    public TypeTree getTypeSystemTree ()
    {
        return _typeHierarchy;
    }
    
    /*************************************************************************/
    
    private FSIndex getIndexForType(CAS aTCAS, String typeName)
    {
        return getIndexForType(aTCAS, aTCAS.getTypeSystem().getType(typeName));
    }
    
    private FSIndex getIndexForType(CAS aTCAS, Type aType)
    {
        if (aType != null) {
            return null;
        }
        
        Iterator iter = aTCAS.getIndexRepository().getLabels();
        while (iter.hasNext())
        {
            String label = (String) iter.next();
            FSIndex index = aTCAS.getIndexRepository().getIndex(label);
            if (aTCAS.getTypeSystem().subsumes(index.getType(), aType))
            {
                return aTCAS.getIndexRepository().getIndex(label, aType);
            }
        }
        return null;
    }
    
    /**
     * 
     * 
     * @param tcas
     * @param tsDesc
     * @param AnnotationTypes   List of types having annotations in CAS
     * @return void
     */
/*    public void setInput (CAS tcas, TypeSystemDescription tsDesc, List annotationTypes)
    {
        // Create Type System Tree
        UimaTypeTree tsTree = UimaTypeUtil.createUimaTypeTreeFromXmlDescriptor(tsDesc);

        // Set background color for types havings annotations
        // List list = annotationTypes;
        if (annotationTypes != null) {
            for (int i=0; i<annotationTypes.size(); ++i) {
                TreeBaseNode node = tsTree.getTypeNode(((Type)annotationTypes.get(i)).getName());
                if (node != null) {
                    TypeColor c = TypeSystemStyle.getTypeStyle().getTypeColor(((Type)annotationTypes.get(i)).getName());
                    if (c != null) {
                        node.setBgColor(c.bgColor);
                        // Trace.trace("Set BG color for " + ((Type)list.get(i)).getName());
                        // Gray out checkbox
                        node.setGrayed(false);
//                    } else {
//                        // Gray out checkbox
//                        node.setGrayed(true);                        
                    }
                    
                }
            }
        }
 
        // Testing
//        FSIndex fsIndex1 = getIndexForType(tcas, "uima.tcas.Annotation");
//        if (fsIndex1 != null) {
//            Trace.trace("FsTotal for Annotation:" + fsIndex1.size());
//        } else {
//            Trace.trace("NO index for type: " + "uima.tcas.Annotation");
//        }
        
        // Set total annotations for each type in the tree
        List list = tsTree.getTypeListFromHierarchy(true, false);
        if (list != null) {
            for (int i=0; i<list.size(); ++i) {
                if (list.get(i) instanceof TypeMetadata) {
                    Type type = tcas.getTypeSystem()
                        .getType(((TypeMetadata)list.get(i)).getName());
                    if (type != null) {
                        TreeBaseNode node = tsTree.getTypeNode(type.getName());
                        if (node == null) {
                            Trace.trace("NOT in tree: " + type.getShortName());
                            
                            continue;
                        }
                        // Set total FS for this type
                        FSIndex fsIndex = getIndexForType(tcas, type);
                        if (fsIndex != null) {
                            node.setFsTotal(fsIndex.size());
                        } else {
                            Trace.trace("NO index for type: " + type.getName());
                        }
                    } else {
                        Trace.trace("NOT in Cas: " + ((TypeMetadata)list.get(i)).getName());
                    }
                }
            }
        }
        
        setInput(tsTree, "Colored Type Tree");
    }
*/
    /*************************************************************************/
        
    protected Section createContents () 
    {
        FormToolkit toolkit = managedForm.getToolkit();
        Section section = getSection();
        section.addControlListener(new ControlAdapter() {
            public void controlResized(ControlEvent e) {
                // section.layout(true);
                managedForm.reflow(true);
            }
        });
        // Expand | Collapse
        section.addExpansionListener(new ExpansionAdapter() {
            public void expansionStateChanged(ExpansionEvent e) {
                // System.out.println("form.reflow");
                // managedForm.getForm().layout(true);
                // Point pt = __parent.getSize();
                // System.err.println("parent x: " + pt.x + " ; parent y: " + pt.y);
                //  pt = getSection().getSize();
                // System.err.println(" Section  x: " + pt.x + " ; y: " + pt.y);
//                if ( e.getState() ) {
//                    // Expand
//                    TableWrapData td = (TableWrapData) section.getLayoutData();
//                    td.maxHeight = 400;
//                }
//                __parent.layout(true);
                
//                ((Composite) getSection().getClient()).layout(true);
//                if (tree == null) {
//                    tree.layout(true);
//                }
//                __managedForm.getForm().layout(true);
                managedForm.reflow(true);
                // pt = getSection().getSize();
                // System.err.println(" Section  x: " + pt.x + " ; y: " + pt.y);
            }
        });        
        section.setExpanded(false);
        
        ///////////////////////////////////////////////////////////////////////
        
        // Create ToolBar
//        Composite sectionToolbarComposite = FormSection.createGridLayoutContainer (toolkit, section,
//                4, 0, 0);
//        section.setTextClient(sectionToolbarComposite);
        
        ///////////////////////////////////////////////////////////////////////
        
        // toolkit.createCompositeSeparator(section);
        
        // Create Composite
        Composite client = FormSection.createGridLayoutContainer (toolkit, section,
                1, 10, 10);        
        GridData gd = new GridData(GridData.FILL_BOTH|GridData.VERTICAL_ALIGN_BEGINNING);
        gd.grabExcessVerticalSpace   = true;
        gd.grabExcessHorizontalSpace = true;
        client.setLayoutData(gd);
        
        toolkit.paintBordersFor(client);        
        section.setClient(client);   
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



CasViewerEclipsePlugin/uimaj-ep-casviewer-core/src/main/java/org/apache/uima/casviewer/ui/internal/style/DefaultColorTreeSectionPart.java [160:278]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public TypeNode getTypeNode (String typeFullName) {
        if (_typeHierarchy != null) {
            return _typeHierarchy.getTypeNode(typeFullName);
        }
        return null;
    }
    
    public Control getTreeControl ()
    {
        return treeViewer.getControl();
    }
    
    public TreeViewer getTreeViewer ()
    {
        return treeViewer;
    }
    
    public void addTypesToHierarchy (ArrayList types)
    {
        _typeHierarchy.addTypesToHierarchy(types);
        // Refresh Tree
        treeViewer.refresh();
        section.redraw();
        section.update();    
    }
    
    public TypeTree getTypeSystemTree ()
    {
        return _typeHierarchy;
    }
    
    /*************************************************************************/
    
    private FSIndex getIndexForType(CAS aTCAS, String typeName)
    {
        return getIndexForType(aTCAS, aTCAS.getTypeSystem().getType(typeName));
    }
    
    private FSIndex getIndexForType(CAS aTCAS, Type aType)
    {
        if (aType != null) {
            return null;
        }
        
        Iterator iter = aTCAS.getIndexRepository().getLabels();
        while (iter.hasNext())
        {
            String label = (String) iter.next();
            FSIndex index = aTCAS.getIndexRepository().getIndex(label);
            if (aTCAS.getTypeSystem().subsumes(index.getType(), aType))
            {
                return aTCAS.getIndexRepository().getIndex(label, aType);
            }
        }
        return null;
    }
    

    /*************************************************************************/
        
    protected Section createContents () 
    {
        FormToolkit toolkit = managedForm.getToolkit();
        Section section = getSection();
        section.addControlListener(new ControlAdapter() {
            public void controlResized(ControlEvent e) {
                // section.layout(true);
                managedForm.reflow(true);
            }
        });
        // Expand | Collapse
        section.addExpansionListener(new ExpansionAdapter() {
            public void expansionStateChanged(ExpansionEvent e) {
                // System.out.println("form.reflow");
                // managedForm.getForm().layout(true);
                // Point pt = __parent.getSize();
                // System.err.println("parent x: " + pt.x + " ; parent y: " + pt.y);
                //  pt = getSection().getSize();
                // System.err.println(" Section  x: " + pt.x + " ; y: " + pt.y);
//                if ( e.getState() ) {
//                    // Expand
//                    TableWrapData td = (TableWrapData) section.getLayoutData();
//                    td.maxHeight = 400;
//                }
//                __parent.layout(true);
                
//                ((Composite) getSection().getClient()).layout(true);
//                if (tree == null) {
//                    tree.layout(true);
//                }
//                __managedForm.getForm().layout(true);
                managedForm.reflow(true);
                // pt = getSection().getSize();
                // System.err.println(" Section  x: " + pt.x + " ; y: " + pt.y);
            }
        });        
        section.setExpanded(false);
        
        ///////////////////////////////////////////////////////////////////////
        
        // Create ToolBar
//        Composite sectionToolbarComposite = FormSection.createGridLayoutContainer (toolkit, section,
//                4, 0, 0);
//        section.setTextClient(sectionToolbarComposite);
        
        ///////////////////////////////////////////////////////////////////////
        
        // toolkit.createCompositeSeparator(section);
        
        // Create Composite
        Composite client = FormSection.createGridLayoutContainer (toolkit, section,
                1, 10, 10);        
        GridData gd = new GridData(GridData.FILL_BOTH|GridData.VERTICAL_ALIGN_BEGINNING);
        gd.grabExcessVerticalSpace   = true;
        gd.grabExcessHorizontalSpace = true;
        client.setLayoutData(gd);
        
        toolkit.paintBordersFor(client);        
        section.setClient(client);   
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



