use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo 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.ObservableCollectionTreeContentProviderInfo 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.ObservableCollectionTreeContentProviderInfo 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;
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo in project windowbuilder by eclipse.
the class TreeInputElementUiContentProvider method saveToObject.
@Override
public void saveToObject() throws Exception {
// check change mode
boolean editorMode = isDesignerMode();
if (m_binding.isDesignerMode() != editorMode) {
ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
contentProvider.setFactoryInfo((ObservableFactoryInfo) m_defaultObjects.get(0));
contentProvider.setAdvisorInfo((TreeStructureAdvisorInfo) m_defaultObjects.get(1));
m_binding.setLabelProvider((LabelProviderInfo) m_defaultObjects.get(2));
}
// save edit objects
if (editorMode) {
m_designerComposite.performFinish();
} else {
m_jfaceComposite.performFinish();
saveJFaceObjects();
}
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo in project windowbuilder by eclipse.
the class TreeInputElementUiContentProvider method saveJFaceObjects.
private void saveJFaceObjects() throws Exception {
ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
ObservableFactoryInfo factoryInfo = contentProvider.getFactoryInfo();
if (factoryInfo instanceof AbstractFactoryInfo) {
AbstractFactoryInfo aFactoryInfo = (AbstractFactoryInfo) factoryInfo;
//
if (aFactoryInfo.isCancel()) {
//
ObservableFactoryInfo newFactoryInfo = new ObservableFactoryInfo(aFactoryInfo.getOriginalClassName());
newFactoryInfo.setVariableIdentifier(aFactoryInfo.getVariableIdentifier());
contentProvider.setFactoryInfo(newFactoryInfo);
//
boolean version_1_3 = Activator.getStore().getBoolean(IPreferenceConstants.GENERATE_CODE_FOR_VERSION_1_3);
ObservableInfo inputObservable = m_binding.getInputObservable();
ObservableInfo newInputObservable = null;
if (contentProvider instanceof ObservableListTreeContentProviderInfo) {
newInputObservable = new ListBeanObservableInfo((BeanBindableInfo) inputObservable.getBindableObject(), (BeanPropertyBindableInfo) inputObservable.getBindableProperty());
if (version_1_3) {
newInputObservable.setCodeSupport(new ListPropertyCodeSupport());
} else {
newInputObservable.setCodeSupport(new BeanObservableListCodeSupport());
}
} else {
newInputObservable = new SetBeanObservableInfo((BeanBindableInfo) inputObservable.getBindableObject(), (BeanPropertyBindableInfo) inputObservable.getBindableProperty());
if (version_1_3) {
newInputObservable.setCodeSupport(new SetPropertyCodeSupport());
} else {
newInputObservable.setCodeSupport(new BeanObservableSetCodeSupport());
}
}
newInputObservable.setVariableIdentifier(inputObservable.getVariableIdentifier());
m_binding.setInputObservable(newInputObservable);
}
} else if (factoryInfo.getClassName().startsWith("listFactory(") || factoryInfo.getClassName().startsWith("setFactory(")) {
//
AbstractFactoryInfo newFactoryInfo = null;
//
if (contentProvider instanceof ObservableListTreeContentProviderInfo) {
newFactoryInfo = new BeansObservableListFactoryInfo();
} else {
newFactoryInfo = new BeansObservableSetFactoryInfo();
}
//
ObservableInfo inputObservable = m_binding.getInputObservable();
//
newFactoryInfo.setPropertyName(inputObservable.getBindableProperty().getReference());
newFactoryInfo.setElementType(inputObservable.getBindableObject().getObjectType());
newFactoryInfo.setVariableIdentifier(factoryInfo.getVariableIdentifier());
contentProvider.setFactoryInfo(newFactoryInfo);
//
m_binding.setInputObservable(new BeanFieldInputObservableInfo(inputObservable.getBindableObject(), inputObservable.getBindableProperty()));
}
}
Aggregations