FileDocCategorySizeDatePackage
PaletteFactory.javaAPI DocAndroid 1.5 API3336Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.editors.layout

PaletteFactory

public class PaletteFactory extends Object
Factory that creates the palette for the {@link GraphicalLayoutEditor}.

Fields Summary
Constructors Summary
private PaletteFactory()
Static factory, nothing to instantiate here.

    
Methods Summary
private static voidaddTools(org.eclipse.gef.palette.PaletteRoot paletteRoot)

        PaletteGroup group = new PaletteGroup("Tools");
        
        // Default tools: selection.
        // Do not use the MarqueeToolEntry since we don't support multiple selection.
        /* -- Do not put the selection tool. It's the unique tool so it looks useless.
              Leave this piece of code here in case we want it back later.
        PanningSelectionToolEntry entry = new PanningSelectionToolEntry();
        group.add(entry);
        paletteRoot.setDefaultEntry(entry);
        */

        paletteRoot.add(group);
    
private static voidaddViews(org.eclipse.gef.palette.PaletteRoot paletteRoot, java.lang.String groupName, java.util.List descriptors)

        PaletteDrawer group = new PaletteDrawer(groupName);
        
        for (ElementDescriptor desc : descriptors) {
            PaletteTemplateEntry entry = new PaletteTemplateEntry(
                    desc.getUiName(),           // label
                    desc.getTooltip(),          // short description
                    desc,                       // template
                    desc.getImageDescriptor(),  // small icon
                    desc.getImageDescriptor()   // large icon
                    );
            
            group.add(entry);
        }
        
        paletteRoot.add(group);
    
public static org.eclipse.gef.palette.PaletteRootcreatePaletteRoot(org.eclipse.gef.palette.PaletteRoot currentPalette, com.android.ide.eclipse.adt.sdk.AndroidTargetData targetData)

        
        if (currentPalette == null) {
            currentPalette = new PaletteRoot();
        }

        for (int n = currentPalette.getChildren().size() - 1; n >= 0; n--) {
            currentPalette.getChildren().remove(n);
        }
        
        if (targetData != null) {
            addTools(currentPalette);
            addViews(currentPalette, "Layouts",
                    targetData.getLayoutDescriptors().getLayoutDescriptors());
            addViews(currentPalette, "Views",
                    targetData.getLayoutDescriptors().getViewDescriptors());
        }

        return currentPalette;