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);
}
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());
}
Aggregations