Search in sources :

Example 1 with AbstractBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo in project windowbuilder by eclipse.

the class AbstractViewerInputBindingInfo method getViewerInutElementType.

// //////////////////////////////////////////////////////////////////////////
// 
// Utils
// 
// //////////////////////////////////////////////////////////////////////////
/**
 * @return {@link Class} of element into given viewer input or <code>null</code> if its not set.
 */
public static Class<?> getViewerInutElementType(ObservableInfo observable, DatabindingsProvider provider) throws Exception {
    if (observable.getBindableObject() instanceof WidgetBindableInfo) {
        // prepare widget
        WidgetBindableInfo widget = (WidgetBindableInfo) observable.getBindableObject();
        // prepare input property
        WidgetPropertyBindableInfo property = widget.resolvePropertyReference("setInput");
        // find input binding
        for (AbstractBindingInfo binding : provider.getBindings0()) {
            if (binding.getTarget() == widget && binding.getTargetProperty() == property) {
                AbstractViewerInputBindingInfo viewerBinding = (AbstractViewerInputBindingInfo) binding;
                return viewerBinding.getElementType();
            }
        }
    }
    // 
    return null;
}
Also used : AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo) WidgetPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetPropertyBindableInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetBindableInfo)

Example 2 with AbstractBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo in project windowbuilder by eclipse.

the class DataBindingContextInfo method addSourceCode.

// //////////////////////////////////////////////////////////////////////////
// 
// Code generation
// 
// //////////////////////////////////////////////////////////////////////////
public void addSourceCode(AstEditor editor, List<String> lines, CodeGenerationSupport generationSupport) throws Exception {
    // sets variable
    if (getVariableIdentifier() == null) {
        setVariableIdentifier("bindingContext");
    }
    // create content
    lines.add("org.eclipse.core.databinding.DataBindingContext " + getVariableIdentifier() + " = new org.eclipse.core.databinding.DataBindingContext();");
    // try {
    boolean addTryCatch = Activator.getStore().getBoolean(IPreferenceConstants.INITDB_TRY_CATCH);
    if (m_userTryCatchBlock != null || addTryCatch) {
        lines.add("//");
        lines.add("try {");
    }
    // check add user initialize method
    if (m_addInitializeContext) {
        lines.add("initializeContext(" + getVariableIdentifier() + ");");
    }
    boolean addLineComment = m_addInitializeContext || m_userTryCatchBlock == null && !addTryCatch;
    // add bindings
    for (AbstractBindingInfo binding : m_bindings) {
        if (addLineComment) {
            lines.add("//");
        }
        addLineComment = true;
        binding.addSourceCode(this, lines, generationSupport);
    }
    // } catch () {}
    if (m_userTryCatchBlock != null || addTryCatch) {
        String indent = editor.getGeneration().getIndentation(1);
        int count = lines.size();
        for (int i = 3; i < count; i++) {
            lines.set(i, indent + lines.get(i));
        }
    }
    if (m_userTryCatchBlock != null) {
        lines.add(m_userTryCatchBlock);
    } else if (addTryCatch) {
        lines.add("} catch(Throwable e) {}");
    }
    // add return
    lines.add("//");
    lines.add("return " + getVariableIdentifier() + ";");
}
Also used : AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo)

Example 3 with AbstractBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo in project windowbuilder by eclipse.

the class InputObserveProperty method getBinding.

// //////////////////////////////////////////////////////////////////////////
// 
// SingleObserveBindingProperty
// 
// //////////////////////////////////////////////////////////////////////////
@Override
protected IBindingInfo getBinding() throws Exception {
    BindableInfo observeProperty = (BindableInfo) m_observeProperty;
    List<AbstractBindingInfo> bindings = observeProperty.getBindings();
    return bindings.isEmpty() ? null : bindings.get(0);
}
Also used : AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo) BindableInfo(org.eclipse.wb.internal.rcp.databinding.model.BindableInfo)

Example 4 with AbstractBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method deleteBinding.

@Override
public void deleteBinding(final IBindingInfo ibinding) {
    // delete
    ExecutionUtils.runLog(new RunnableEx() {

        @Override
        public void run() throws Exception {
            AbstractBindingInfo binding = (AbstractBindingInfo) ibinding;
            binding.delete();
        }
    });
    getBindings().remove(ibinding);
    // save
    saveEdit();
}
Also used : AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo) RunnableEx(org.eclipse.wb.internal.core.utils.execution.RunnableEx)

Example 5 with AbstractBindingInfo

use of org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo 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

AbstractBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo)9 RunnableEx (org.eclipse.wb.internal.core.utils.execution.RunnableEx)3 BindableInfo (org.eclipse.wb.internal.rcp.databinding.model.BindableInfo)2 IDesignPageSite (org.eclipse.wb.core.editor.IDesignPageSite)1 IUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)1 EObjectBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo)1 EPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo)1 PropertiesSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport)1 DetailEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailEmfObservableInfo)1 DetailListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo)1 DetailValueEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailValueEmfObservableInfo)1 EmfObservableDetailListCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.EmfObservableDetailListCodeSupport)1 EmfObservableDetailValueCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.EmfObservableDetailValueCodeSupport)1 ListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo)1 MapsEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.MapsEmfObservableInfo)1 EmfListPropertyDetailCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.properties.EmfListPropertyDetailCodeSupport)1 EmfValuePropertyDetailCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.properties.EmfValuePropertyDetailCodeSupport)1 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)1 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)1 WidgetBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetBindableInfo)1