private Section createSection(SceneNodeComponent component) { FormToolkit toolkit = GurellaStudioPlugin.getToolkit(); Section section = toolkit.createSection(componentsComposite, TWISTIE | SHORT_TITLE_BAR | NO_TITLE_FOCUS_BOX); section.setText(MetaTypes.getMetaType(component).getName()); section.setLayoutData(new GridData(FILL, FILL, true, false, 1, 1)); section.addExpansionListener(new ExpansionListener(component)); BeanEditor<SceneNodeComponent> editor = createEditor(section, editorContext, component); Signal1<PropertyValueChangedEvent> signal = editor.getContext().propertiesSignal; signal.addListener(e -> notifySceneChanged()); section.setClient(editor); section.setExpanded(getPreferences().getBoolean(component.ensureUuid(), true)); editors.put(component, section); return section; }
private void addMenuItem(Menu menu, final Class<? extends SceneNodeComponent> componentType) { MenuItem item = new MenuItem(menu, PUSH); item.setText(MetaTypes.getMetaType(componentType).getName()); item.addListener(SWT.Selection, (e) -> addComponent(Reflection.newInstance(componentType))); item.setEnabled(target.getComponent(ComponentType.getBaseType(componentType), true) == null); }