use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo in project windowbuilder by eclipse.
the class TreeViewerInputBindingInfo method setDefaultProviders.
@Override
public void setDefaultProviders(boolean asList, Class<?> elementType, boolean useViewerSupport) throws Exception {
// create advisor
TreeBeanAdvisorInfo advisor = GlobalFactoryHelper.createTreeBeanAdvisor(m_inputObservable);
if (advisor == null) {
advisor = new TreeBeanAdvisorInfo();
}
advisor.setElementType(elementType);
// create factory
BeansObservableFactoryInfo factory = GlobalFactoryHelper.createTreeObservableFactory(m_inputObservable, asList);
if (factory == null) {
factory = asList ? new BeansListObservableFactoryInfo() : new BeansSetObservableFactoryInfo();
}
factory.setElementType(elementType);
// create content provider
m_contentProvider = asList ? new ObservableListTreeContentProviderInfo(factory, advisor) : new ObservableSetTreeContentProviderInfo(factory, advisor);
// create label provider
KnownElementsObservableInfo allElementsObservable = new KnownElementsObservableInfo(m_contentProvider);
TreeObservableLabelProviderInfo labelProvider = GlobalFactoryHelper.createTreeLabelProvider(m_inputObservable, allElementsObservable);
if (labelProvider == null) {
labelProvider = new TreeObservableLabelProviderInfo(allElementsObservable);
}
labelProvider.setElementType(elementType);
m_labelProvider = labelProvider;
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo in project windowbuilder by eclipse.
the class TreeContentLabelProvidersUiContentProvider method updateFromObject.
// //////////////////////////////////////////////////////////////////////////
//
// Update
//
// //////////////////////////////////////////////////////////////////////////
@Override
public void updateFromObject() throws Exception {
if (m_binding.isDesignerMode()) {
Class<?> elementType = m_binding.getElementType();
if (elementType != null) {
// set element type
setElementType(elementType);
// prepare checked groups
List<Object> checkedObjects = Lists.newArrayList();
// check parent/children/has children
TreeBeanAdvisorInfo advisor = (TreeBeanAdvisorInfo) m_binding.getContentProvider().getAdvisorInfo();
extractProperties(checkedObjects, PARENT_GROUP_NAME, advisor.getParentProperty());
extractProperties(checkedObjects, CHILDREN_GROUP_NAME, advisor.getChildrenProperty());
extractProperties(checkedObjects, HAS_CHILDREN_GROUP_NAME, advisor.getHasChildrenProperty());
// check text/image
TreeObservableLabelProviderInfo labelProvider = (TreeObservableLabelProviderInfo) m_binding.getLabelProvider();
extractProperties(checkedObjects, TEXT_GROUP_NAME, labelProvider.getTextProperty());
extractProperties(checkedObjects, IMAGE_GROUP_NAME, labelProvider.getImageProperty());
// apply checked
if (!checkedObjects.isEmpty()) {
m_propertiesViewer.setCheckedElements(checkedObjects.toArray());
}
}
}
//
calculateFinish();
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo in project windowbuilder by eclipse.
the class TreeContentLabelProvidersUiContentProvider method saveToObject.
@Override
public void saveToObject() throws Exception {
// prepare content provider
ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
// prepare factory
BeansObservableFactoryInfo factory = (BeansObservableFactoryInfo) contentProvider.getFactoryInfo();
// prepare advisor
TreeBeanAdvisorInfo advisor = (TreeBeanAdvisorInfo) contentProvider.getAdvisorInfo();
// prepare label provider
TreeObservableLabelProviderInfo labelProvider = (TreeObservableLabelProviderInfo) m_binding.getLabelProvider();
// extract checked properties
for (Object element : m_propertiesViewer.getCheckedElements()) {
if (element instanceof TreePropertyWrapper) {
TreePropertyWrapper wrapper = (TreePropertyWrapper) element;
String propertyName = wrapper.descriptor.getName();
String groupName = wrapper.parent.name;
// check group
if (PARENT_GROUP_NAME.equals(groupName)) {
advisor.setParentProperty(propertyName);
} else if (CHILDREN_GROUP_NAME.equals(groupName)) {
advisor.setChildrenProperty(propertyName);
factory.setPropertyName(propertyName);
} else if (HAS_CHILDREN_GROUP_NAME.equals(groupName)) {
advisor.setHasChildrenProperty(propertyName);
} else if (TEXT_GROUP_NAME.equals(groupName)) {
labelProvider.setTextProperty(propertyName);
} else if (IMAGE_GROUP_NAME.equals(groupName)) {
labelProvider.setImageProperty(propertyName);
}
}
}
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo in project windowbuilder by eclipse.
the class TreeInputElementUiContentProvider method createDesignerElementTypeUIProvider.
private ChooseClassUiContentProvider createDesignerElementTypeUIProvider() throws Exception {
ChooseClassConfiguration configuration = new ChooseClassConfiguration();
configuration.setDialogFieldLabel(Messages.TreeInputElementUiContentProvider_chooseDesigner);
configuration.setValueScope("beans");
configuration.setChooseInterfaces(true);
configuration.setEmptyClassErrorMessage(Messages.TreeInputElementUiContentProvider_chooseDesignerEmptyMessage);
configuration.setErrorMessagePrefix(Messages.TreeInputElementUiContentProvider_chooseDesignerErrorPrefix);
//
GlobalFactoryHelper.configureChooseElementForTreeViewerInput(m_binding.getInputObservable(), configuration);
//
return new ChooseClassUiContentProvider(configuration) {
@Override
public void updateFromObject() throws Exception {
Class<?> elementType = m_binding.getElementType();
if (elementType != null) {
setClassName(CoreUtils.getClassName(elementType));
} else {
calculateFinish();
}
}
@Override
protected void calculateFinish() {
super.calculateFinish();
if (getErrorMessage() == null) {
// route choose class events to properties editor
ExecutionUtils.runLog(new RunnableEx() {
@Override
public void run() throws Exception {
m_contentLabelProvidersEditor.setElementType(getChoosenClass());
}
});
}
}
@Override
public void saveToObject() throws Exception {
// store element type
Class<?> elementType = getChoosenClass();
//
ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
// to factory
BeansObservableFactoryInfo factory = (BeansObservableFactoryInfo) contentProvider.getFactoryInfo();
factory.setElementType(elementType);
// to advisor
TreeBeanAdvisorInfo advisor = (TreeBeanAdvisorInfo) contentProvider.getAdvisorInfo();
advisor.setElementType(elementType);
// to label provider
TreeObservableLabelProviderInfo labelProvider = (TreeObservableLabelProviderInfo) m_binding.getLabelProvider();
labelProvider.setElementType(elementType);
// to input
InputElementUiContentProvider.setElementTypeToInput(m_binding, elementType);
}
};
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo in project windowbuilder by eclipse.
the class TreeInputElementUiContentProvider method createDesignerProviders.
/**
* Fill Designer page.
*/
private List<IUiContentProvider> createDesignerProviders() {
List<IUiContentProvider> providers = Lists.newArrayList();
providers.add(m_elementTypeDesignerUIProvider);
//
if (m_binding.isDesignerMode()) {
// add life objects
createDefaultProviders(providers, true);
} else {
// create fake objects
ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
// create factory
boolean asList = contentProvider instanceof ObservableListTreeContentProviderInfo;
BeansObservableFactoryInfo factory = null;
try {
factory = GlobalFactoryHelper.createTreeObservableFactory(m_binding.getInputObservable(), asList);
} catch (Throwable e) {
DesignerPlugin.log(e);
}
if (factory == null) {
factory = asList ? new BeansListObservableFactoryInfo() : new BeansSetObservableFactoryInfo();
}
//
m_defaultObjects.add(factory);
factory.createContentProviders(providers, m_provider);
// create advisor
TreeBeanAdvisorInfo advisor = null;
try {
advisor = GlobalFactoryHelper.createTreeBeanAdvisor(m_binding.getInputObservable());
} catch (Throwable e) {
DesignerPlugin.log(e);
}
if (advisor == null) {
advisor = new TreeBeanAdvisorInfo();
}
m_defaultObjects.add(advisor);
advisor.createContentProviders(providers, m_provider);
// content provider always exist
contentProvider.createContentProviders(providers, m_provider, true);
// create label provider
KnownElementsObservableInfo allElementsObservable = new KnownElementsObservableInfo(contentProvider);
TreeObservableLabelProviderInfo labelProvider = null;
try {
labelProvider = GlobalFactoryHelper.createTreeLabelProvider(m_binding.getInputObservable(), allElementsObservable);
} catch (Throwable e) {
DesignerPlugin.log(e);
}
if (labelProvider == null) {
labelProvider = new TreeObservableLabelProviderInfo(allElementsObservable);
}
m_defaultObjects.add(labelProvider);
labelProvider.createContentProviders(providers, m_provider, true);
}
// content provider for properties: parent/children/has children/text/image
m_contentLabelProvidersEditor = new TreeContentLabelProvidersUiContentProvider(m_binding);
providers.add(m_contentLabelProvidersEditor);
return providers;
}
Aggregations