Search in sources :

Example 6 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class JTableColumnContainerUiContentProvider method saveToObject.

@Override
@SuppressWarnings("unchecked")
protected void saveToObject(List<IUiContentProvider> providers) throws Exception {
    List<ColumnBindingInfo> columns = Lists.newArrayList();
    for (IUiContentProvider provider : providers) {
        UIContentContainer<ColumnBindingInfo> container = (UIContentContainer<ColumnBindingInfo>) provider;
        columns.add(container.getBinding());
    }
    m_binding.setColumns(columns, m_bindings);
}
Also used : ColumnBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.ColumnBindingInfo) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)

Example 7 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider 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;
}
Also used : ObservableCollectionTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo) BeansSetObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo) TreeBeanAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider) BeansObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo) BeansListObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo) TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) ObservableListTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableListTreeContentProviderInfo)

Example 8 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class TreeInputElementUiContentProvider method createJFaceProviders.

/**
 * Fill JFace page.
 */
private List<IUiContentProvider> createJFaceProviders() {
    List<IUiContentProvider> providers = Lists.newArrayList();
    // 
    if (m_binding.isDesignerMode()) {
        // create fake objects
        // create factory
        ObservableFactoryInfo factory = new ObservableFactoryInfo("");
        m_defaultObjects.add(factory);
        factory.createContentProviders(providers, m_provider);
        // create advisor
        TreeStructureAdvisorInfo advisor = new TreeStructureAdvisorInfo("");
        m_defaultObjects.add(advisor);
        advisor.createContentProviders(providers, m_provider);
        // content provider always exist
        m_binding.getContentProvider().createContentProviders(providers, m_provider, false);
        // create label provider
        LabelProviderInfo labelProvider = new LabelProviderInfo("");
        m_defaultObjects.add(labelProvider);
        labelProvider.createContentProviders(providers, m_provider, false);
    } else {
        // add life objects
        createDefaultProviders(providers, false);
    }
    // 
    final ObservableInfo inputObservable = m_binding.getInputObservable();
    if (inputObservable instanceof ListBeanObservableInfo || inputObservable instanceof SetBeanObservableInfo || inputObservable instanceof BeanFieldInputObservableInfo) {
        final ChooseClassUiContentProvider contentProviderJFaceEditor = (ChooseClassUiContentProvider) providers.get(0);
        // 
        try {
            String factoryValue = inputObservable.getBindableProperty().getReference() + ", " + ClassUtils.getShortClassName(inputObservable.getBindableObject().getObjectType()) + ".class)";
            // 
            if (inputObservable instanceof ListBeanObservableInfo) {
                factoryValue = "listFactory(" + factoryValue;
                contentProviderJFaceEditor.getConfiguration().addDefaultStart(factoryValue);
                contentProviderJFaceEditor.addClassToCombo(factoryValue);
            } else if (inputObservable instanceof SetBeanObservableInfo) {
                factoryValue = "setFactory(" + factoryValue;
                contentProviderJFaceEditor.getConfiguration().addDefaultStart(factoryValue);
                contentProviderJFaceEditor.addClassToCombo(factoryValue);
            }
        } catch (Throwable e) {
        }
        // 
        new ChooseClassRouter(contentProviderJFaceEditor, new Runnable() {

            @Override
            public void run() {
                String className = contentProviderJFaceEditor.getClassName();
                if (className.startsWith("listFactory") || className.startsWith("setFactory")) {
                    m_elementTypeJFaceUIProvider.setClassName(CoreUtils.getClassName(inputObservable.getBindableObject().getObjectType()));
                }
            }
        });
    }
    // 
    m_labelProviderJFaceEditor = (ChooseClassUiContentProvider) providers.get(providers.size() - 1);
    new ChooseClassRouter(m_labelProviderJFaceEditor, new Runnable() {

        @Override
        public void run() {
            m_elementTypeJFaceUIProvider.calculateFinish();
        }
    });
    // 
    providers.add(m_elementTypeJFaceUIProvider);
    return providers;
}
Also used : SetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) BeanFieldInputObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.BeanFieldInputObservableInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) MapsBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) SetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo) ChooseClassRouter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassRouter) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider) BeanFieldInputObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.BeanFieldInputObservableInfo) AbstractLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.AbstractLabelProviderInfo) LabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.LabelProviderInfo) ObservableMapLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableMapLabelProviderInfo) TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) BeansListObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo) BeansSetObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo) BeansObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo) ObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableFactoryInfo) TreeStructureAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeStructureAdvisorInfo) ChooseClassUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassUiContentProvider)

Example 9 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class ViewerColumnsUiContentProvider method configureEditingSupport.

// //////////////////////////////////////////////////////////////////////////
// 
// Handle
// 
// //////////////////////////////////////////////////////////////////////////
private void configureEditingSupport() {
    try {
        // prepare selection
        IStructuredSelection selection = (IStructuredSelection) m_tableViewer.getSelection();
        VirtualEditingSupportInfo editingSupport = (VirtualEditingSupportInfo) selection.getFirstElement();
        // create providers
        List<IUiContentProvider> providers = Lists.newArrayList();
        editingSupport.createContentProviders(providers);
        // open dialog
        SimpleBindDialog dialog = new SimpleBindDialog(m_editButton.getShell(), Activator.getDefault(), providers, Messages.ViewerColumnsUiContentProvider_configureEditingSupportLabel, Messages.ViewerColumnsUiContentProvider_configureEditingSupportProperties, Messages.ViewerColumnsUiContentProvider_configureEditingSupportMessage);
        if (dialog.open() == Window.OK) {
            m_tableViewer.refresh();
        }
    } catch (Throwable e) {
        DesignerPlugin.log(e);
    }
}
Also used : SimpleBindDialog(org.eclipse.wb.internal.core.databinding.ui.SimpleBindDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider) VirtualEditingSupportInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.VirtualEditingSupportInfo)

Example 10 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class DatabindingsProvider method getContentProviders.

// //////////////////////////////////////////////////////////////////////////
// 
// UI editing
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public List<IUiContentProvider> getContentProviders(IBindingInfo ibinding, IPageListener listener) throws Exception {
    AbstractBindingInfo binding = (AbstractBindingInfo) ibinding;
    List<IUiContentProvider> providers = Lists.newArrayList();
    binding.createContentProviders(providers, listener, this);
    return providers;
}
Also used : AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)

Aggregations

IUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)22 List (java.util.List)6 Point (org.eclipse.swt.graphics.Point)5 ChooseClassConfiguration (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)5 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)5 BindingInfo (org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo)5 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)5 BindingUiContentProviderContext (org.eclipse.wb.internal.rcp.databinding.model.context.BindingUiContentProviderContext)4 ColumnBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.ColumnBindingInfo)3 IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)2 UiContentProviderComposite (org.eclipse.wb.internal.core.databinding.ui.editor.UiContentProviderComposite)2 AbstractBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo)2 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)2 BeansListObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo)2 BeansObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo)2 BeansSetObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo)2 TreeObservableLabelProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1