Search in sources :

Example 1 with ChooseClassAndPropertiesUiContentProvider

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

the class TreeViewerInputBindingInfo method createContentProviders.

// //////////////////////////////////////////////////////////////////////////
// 
// Editing
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public void createContentProviders(List<IUiContentProvider> providers, IPageListener listener, DatabindingsProvider provider) throws Exception {
    // configure page
    listener.setTitle(Messages.TreeViewerInputBindingInfo_title);
    listener.setMessage(Messages.TreeViewerInputBindingInfo_errorMessage);
    // 
    providers.add(new LabelUiContentProvider(Messages.TreeViewerInputBindingInfo_viewerLabel, m_viewerBindable.getPresentation().getTextForBinding()));
    providers.add(new LabelUiContentProvider(Messages.TreeViewerInputBindingInfo_inputLabel, m_inputObservable.getPresentationText()));
    // 
    TreeInputElementUiContentProvider inputEditor = new TreeInputElementUiContentProvider(this, listener, provider);
    // 
    if (m_inputObservable instanceof DetailBeanObservableInfo) {
        m_inputObservable.createContentProviders(providers, null, provider);
        // 
        ChooseClassAndPropertiesUiContentProvider masterUIContentProvider = (ChooseClassAndPropertiesUiContentProvider) providers.get(providers.size() - 1);
        // 
        ChooseClassConfiguration configuration = new ChooseClassConfiguration();
        configuration.setDialogFieldLabel(Messages.TreeViewerInputBindingInfo_chooseLabel);
        configuration.setValueScope("beans1");
        configuration.setChooseInterfaces(true);
        configuration.setEmptyClassErrorMessage(Messages.TreeViewerInputBindingInfo_chooseEmptyMessage);
        configuration.setErrorMessagePrefix(Messages.TreeViewerInputBindingInfo_chooseErrorPrefix);
        // 
        TreeDetailUiContentProvider detailUIContentProvider = new TreeDetailUiContentProvider(configuration, (DetailBeanObservableInfo) m_inputObservable);
        providers.add(detailUIContentProvider);
        // 
        new ChooseClassAndPropertiesRouter(masterUIContentProvider, detailUIContentProvider);
        new ChooseClassRouter(detailUIContentProvider, new MultiTargetRunnable(detailUIContentProvider, inputEditor.getElementTypeUIProviders()));
    }
    // 
    providers.add(inputEditor);
    // 
    super.createContentProviders(providers, listener, provider);
}
Also used : ChooseClassAndPropertiesRouter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesRouter) LabelUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.LabelUiContentProvider) TreeDetailUiContentProvider(org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.TreeDetailUiContentProvider) ChooseClassRouter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassRouter) TreeInputElementUiContentProvider(org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.TreeInputElementUiContentProvider) ChooseClassAndPropertiesUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesUiContentProvider) MultiTargetRunnable(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.MultiTargetRunnable) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo) ChooseClassConfiguration(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)

Example 2 with ChooseClassAndPropertiesUiContentProvider

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

the class AutomaticDatabindingSecondPage method createControl.

// //////////////////////////////////////////////////////////////////////////
// 
// GUI
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public void createControl(Composite parent) {
    // prepare page
    int columns = 4;
    Composite pageComposite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.create(pageComposite).columns(columns);
    setControl(pageComposite);
    // choose class and properties
    m_chooseClassAndPropertiesProvider = new ChooseClassAndPropertiesUiContentProvider(createConfiguration()) {

        @Override
        protected void super_createContent(Composite parent, int columns) {
            super.super_createContent(parent, columns - 1);
            // filter ToolBar
            ToolBar toolBar = new ToolBar(parent, SWT.NONE);
            // properties filter
            m_propertiesFilterButton = new ToolItem(toolBar, SWT.CHECK);
            m_propertiesFilterButton.setImage(Activator.getImage("filter_action.gif"));
            m_propertiesFilterButton.setToolTipText(Messages.AutomaticDatabindingSecondPage_filterToolTip);
            m_propertiesFilterButton.setSelection(m_databindingProvider.getPropertiesViewerFilterInitState());
            m_propertiesFilterButton.setEnabled(false);
            m_propertiesFilterButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    handlePropertiesFilter(m_propertiesFilterButton.getSelection());
                }
            });
        }

        @Override
        protected List<PropertyAdapter> getProperties(Class<?> choosenClass) throws Exception {
            return m_databindingProvider.getProperties(choosenClass);
        }

        @Override
        public void updateFromObject() throws Exception {
            // handle initial wizard selection
            if (m_initialBeanClassName != null && m_firstPage.getJavaProject() != null) {
                m_databindingProvider.setCurrentWizardData(m_firstPage, AutomaticDatabindingSecondPage.this);
                setClassNameAndProperty(m_initialBeanClassName, null, true);
            }
        }

        @Override
        protected void saveToObject(Class<?> choosenClass, List<PropertyAdapter> choosenProperties) throws Exception {
        }

        @Override
        protected Class<?> loadClass(String className) throws ClassNotFoundException {
            return m_databindingProvider.loadClass(className);
        }

        @Override
        protected IJavaProject getJavaProject() {
            return m_firstPage.getJavaProject();
        }
    };
    m_chooseClassAndPropertiesProvider.createContent(pageComposite, columns);
    m_chooseClassAndPropertiesProvider.setCompleteListener(this);
    getPropertiesViewer().getCheckable().addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            m_databindingProvider.handlePropertyChecked((PropertyAdapter) event.getElement(), event.getChecked());
            calculateFinish();
        }
    });
    m_chooseClassAndPropertiesProvider.setSupportListener(new ChooseClassAndPropertiesSupportListener() {

        @Override
        public void loadProperties(boolean successful) {
            m_propertiesFilterButton.setEnabled(successful);
            if (successful) {
                for (Object element : getPropertiesViewer().getCheckedElements()) {
                    m_databindingProvider.handlePropertyChecked((PropertyAdapter) element, true);
                }
            }
        }
    });
    m_databindingProvider.configurePropertiesViewer((CheckboxTableViewer) getPropertiesViewer().getViewer());
    // widgets
    Composite widgetComposite = new Composite(pageComposite, SWT.NONE);
    GridDataFactory.create(widgetComposite).fill().grab().spanH(columns);
    m_databindingProvider.fillWidgetComposite(widgetComposite);
    // sets initial values
    ExecutionUtils.runLog(new RunnableEx() {

        @Override
        public void run() throws Exception {
            m_chooseClassAndPropertiesProvider.updateFromObject();
        }
    });
    // enable properties filter
    handlePropertiesFilter(m_databindingProvider.getPropertiesViewerFilterInitState());
}
Also used : ChooseClassAndPropertiesSupportListener(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesSupportListener) Composite(org.eclipse.swt.widgets.Composite) ChooseClassAndPropertiesUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesUiContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) RunnableEx(org.eclipse.wb.internal.core.utils.execution.RunnableEx) IJavaProject(org.eclipse.jdt.core.IJavaProject) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) PropertyAdapter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.PropertyAdapter) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

ChooseClassAndPropertiesUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesUiContentProvider)2 List (java.util.List)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Composite (org.eclipse.swt.widgets.Composite)1 ToolBar (org.eclipse.swt.widgets.ToolBar)1 ToolItem (org.eclipse.swt.widgets.ToolItem)1 ChooseClassAndPropertiesRouter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesRouter)1 ChooseClassAndPropertiesSupportListener (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesSupportListener)1 ChooseClassConfiguration (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)1 ChooseClassRouter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassRouter)1 LabelUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.LabelUiContentProvider)1 MultiTargetRunnable (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.MultiTargetRunnable)1 PropertyAdapter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.PropertyAdapter)1 RunnableEx (org.eclipse.wb.internal.core.utils.execution.RunnableEx)1 DetailBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)1 TreeDetailUiContentProvider (org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.TreeDetailUiContentProvider)1