use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class DatabindingsProvider method createObservable.
public ObservableInfo createObservable(IObservableFactory factory, BindableInfo bindable, BindableInfo property, Type type) throws Exception {
boolean version_1_3 = Activator.getStore().getBoolean(IPreferenceConstants.GENERATE_CODE_FOR_VERSION_1_3);
ObservableInfo newObservable = factory.createObservable(bindable, property, type, version_1_3);
//
for (IBindingInfo ibinding : getBindings()) {
if (ibinding instanceof BindingInfo) {
BindingInfo binding = (BindingInfo) ibinding;
// check target
ObservableInfo targetObservable = binding.getTargetObservable();
if (targetObservable.canShared() && binding.getTarget() == bindable && binding.getTargetProperty() == property && targetObservable.getClass() == newObservable.getClass()) {
return targetObservable;
}
// check model
ObservableInfo modelObservable = binding.getModelObservable();
if (modelObservable.canShared() && binding.getModel() == bindable && binding.getModelProperty() == property && modelObservable.getClass() == newObservable.getClass()) {
return modelObservable;
}
} else {
AbstractViewerInputBindingInfo binding = (AbstractViewerInputBindingInfo) ibinding;
// check viewer input
ObservableInfo inputObservable = binding.getInputObservable();
if (inputObservable.canShared() && binding.getModel() == bindable && binding.getModelProperty() == property && inputObservable.getClass() == newObservable.getClass()) {
return inputObservable;
}
}
}
return newObservable;
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class DatabindingsProvider method createBinding.
// //////////////////////////////////////////////////////////////////////////
//
// Creation/Editing
//
// //////////////////////////////////////////////////////////////////////////
@Override
public IBindingInfo createBinding(IObserveInfo target, IObserveInfo targetProperty, IObserveInfo model, IObserveInfo modelProperty) throws Exception {
// prepare target
BindableInfo targetBindable = (BindableInfo) target;
BindableInfo targetBindableProperty = (BindableInfo) targetProperty;
IObservableFactory targetFactory = targetBindableProperty.getObservableFactory();
// prepare model
BindableInfo modelBindable = (BindableInfo) model;
BindableInfo modelBindableProperty = (BindableInfo) modelProperty;
IObservableFactory modelFactory = modelBindableProperty.getObservableFactory();
// calculate type
Type type = org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider.calculateObserveType(targetFactory, modelFactory);
// handle input type
if (type == Type.Input) {
// XXX
throw new UnsupportedOperationException();
}
// create binding
BindingInfo binding = new BindingInfo(targetBindable, targetBindableProperty, modelBindable, modelBindableProperty);
binding.setDocumentEditor(new AttributeDocumentEditor(binding));
//
return binding;
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class DatabindingsProvider method getContentProviders.
// //////////////////////////////////////////////////////////////////////////
//
// UI editing
//
// //////////////////////////////////////////////////////////////////////////
@Override
public List<IUiContentProvider> getContentProviders(IBindingInfo ibinding, IPageListener listener) throws Exception {
List<IUiContentProvider> providers = Lists.newArrayList();
BindingInfo binding = (BindingInfo) ibinding;
binding.createContentProviders(providers, listener, this);
return providers;
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class DatabindingsProvider method configureMoveUpDown.
private int configureMoveUpDown(IBindingInfo binding, int sourceIndex, int targetIndex) {
if (!(binding instanceof ColumnBindingInfo)) {
List<IBindingInfo> bindings = getBindings();
IBindingInfo target = bindings.get(targetIndex);
boolean up = sourceIndex > targetIndex;
// configure target index
if (target instanceof ColumnBindingInfo) {
ColumnBindingInfo column = (ColumnBindingInfo) target;
// calculate column index
if (up) {
targetIndex = bindings.indexOf(column.getJTableBinding());
} else {
// skip all columns
targetIndex += column.getJTableBinding().getColumns().size();
//
target = bindings.get(targetIndex);
if (target instanceof JTableBindingInfo) {
// skip all columns
JTableBindingInfo tableBinding = (JTableBindingInfo) target;
targetIndex += tableBinding.getColumns().size();
} else if (target instanceof JListBindingInfo) {
// skip detail binding
targetIndex++;
}
}
} else if (target instanceof DetailBindingInfo) {
if (up) {
DetailBindingInfo detail = (DetailBindingInfo) target;
targetIndex = bindings.indexOf(detail.getJListBinding());
} else {
// skip detail binding
targetIndex++;
//
target = bindings.get(targetIndex);
if (target instanceof JTableBindingInfo) {
// skip all columns
JTableBindingInfo tableBinding = (JTableBindingInfo) target;
targetIndex += tableBinding.getColumns().size();
} else if (target instanceof JListBindingInfo) {
// skip detail binding
targetIndex++;
}
}
} else if (target instanceof JTableBindingInfo && !up) {
// skip all columns
JTableBindingInfo tableBinding = (JTableBindingInfo) target;
targetIndex += tableBinding.getColumns().size();
} else if (target instanceof JListBindingInfo && !up) {
// skip detail binding
targetIndex++;
}
}
return targetIndex;
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class DatabindingsProvider method gotoDefinition.
public void gotoDefinition(IBindingInfo ibinding) {
try {
// calculate variable
BindingInfo binding = (BindingInfo) ibinding;
String variable = binding.getVariableIdentifier();
if (variable != null) {
if (variable.endsWith("()")) {
variable = variable.substring(0, variable.length() - 2);
}
// calculate position
int position = m_javaInfoRoot.getEditor().getEnclosingNode(variable).getStartPosition();
// sets position
IDesignPageSite site = IDesignPageSite.Helper.getSite(m_javaInfoRoot);
site.openSourcePosition(position);
}
} catch (Throwable e) {
}
}
Aggregations