/** * Creates a new component palette panel. * * @param editor parent editor of this panel */ public YoungAndroidPalettePanel(YaFormEditor editor) { this.editor = editor; stackPalette = new StackPanel(); categoryPanels = new HashMap<ComponentCategory, VerticalPanel>(); for (ComponentCategory category : ComponentCategory.values()) { if (showCategory(category)) { VerticalPanel categoryPanel = new VerticalPanel(); categoryPanel.setWidth("100%"); categoryPanels.put(category, categoryPanel); stackPalette.add(categoryPanel, category.getName()); } } stackPalette.setWidth("100%"); initWidget(stackPalette); }
/** * Loads all components to be shown on this palette. Specifically, for each component (except for * those whose category is UNINITIALIZED, or whose category is INTERNAL and we're running on a * production server, or who are specifically marked as not to be shown on the palette), this * creates a corresponding {@link SimplePaletteItem} with the passed {@link DropTargetProvider} * and adds it to the panel corresponding to its category. * * @param dropTargetProvider provider of targets that palette items can be dropped on */ @Override public void loadComponents(DropTargetProvider dropTargetProvider) { for (String component : COMPONENT_DATABASE.getComponentNames()) { String categoryString = COMPONENT_DATABASE.getCategoryString(component); String helpString = COMPONENT_DATABASE.getHelpString(component); String categoryDocUrlString = COMPONENT_DATABASE.getCategoryDocUrlString(component); Boolean showOnPalette = COMPONENT_DATABASE.getShowOnPalette(component); Boolean nonVisible = COMPONENT_DATABASE.getNonVisible(component); ComponentCategory category = ComponentCategory.valueOf(categoryString); if (showOnPalette && showCategory(category)) { addPaletteItem( new SimplePaletteItem( new SimpleComponentDescriptor( component, editor, helpString, categoryDocUrlString, showOnPalette, nonVisible), dropTargetProvider), category); } } }