/** Instantiates mock component by name. */ public static MockComponent createMockComponent(String name, SimpleEditor editor) { if (COMPONENT_DATABASE.getNonVisible(name)) { return new MockNonVisibleComponent( editor, name, getImageFromPath(COMPONENT_DATABASE.getIconName(name))); } else if (name.equals(MockButton.TYPE)) { return new MockButton(editor); } else if (name.equals(MockCanvas.TYPE)) { return new MockCanvas(editor); } else if (name.equals(MockCheckBox.TYPE)) { return new MockCheckBox(editor); } else if (name.equals(MockImage.TYPE)) { return new MockImage(editor); } else if (name.equals(MockLabel.TYPE)) { return new MockLabel(editor); } else if (name.equals(MockPasswordTextBox.TYPE)) { return new MockPasswordTextBox(editor); } else if (name.equals(MockRadioButton.TYPE)) { return new MockRadioButton(editor); } else if (name.equals(MockTextBox.TYPE)) { return new MockTextBox(editor); } else if (name.equals(MockContactPicker.TYPE)) { return new MockContactPicker(editor); } else if (name.equals(MockPhoneNumberPicker.TYPE)) { return new MockPhoneNumberPicker(editor); } else if (name.equals(MockEmailPicker.TYPE)) { return new MockEmailPicker(editor); } else if (name.equals(MockListPicker.TYPE)) { return new MockListPicker(editor); } else if (name.equals(MockHorizontalArrangement.TYPE)) { return new MockHorizontalArrangement(editor); } else if (name.equals(MockVerticalArrangement.TYPE)) { return new MockVerticalArrangement(editor); } else if (name.equals(MockTableArrangement.TYPE)) { return new MockTableArrangement(editor); } else if (name.equals(MockImageSprite.TYPE)) { return new MockImageSprite(editor); } else if (name.equals(MockBall.TYPE)) { return new MockBall(editor); } else if (name.equals(MockImagePicker.TYPE)) { return new MockImagePicker(editor); } else if (name.equals(MockVideoPlayer.TYPE)) { return new MockVideoPlayer(editor); } else if (name.equals(MockWebViewer.TYPE)) { return new MockWebViewer(editor); } else { // TODO(user): add 3rd party mock component proxy here throw new UnsupportedOperationException("unknown component: " + name); } }
/** * 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); } } }