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