use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindingElementsComposite method moveBinding.
private void moveBinding(boolean up) {
List<IBindingInfo> bindings = m_databindingsProvider.getBindings();
IBindingInfo binding = getSelectionBinding();
int sourceIndex = bindings.indexOf(binding);
int targetIndex = sourceIndex + (up ? -1 : 1);
//
m_databindingsProvider.moveBinding(binding, sourceIndex, targetIndex, true);
//
m_bindingViewer.refresh();
handleBindingSelection((IStructuredSelection) m_bindingViewer.getSelection());
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindingElementsComposite method handleBindingSelection.
// //////////////////////////////////////////////////////////////////////////
//
// Events
//
// //////////////////////////////////////////////////////////////////////////
protected void handleBindingSelection(IStructuredSelection selection) {
// handle recursion
if (m_skipSelectionEvent) {
return;
}
m_skipSelectionEvent = true;
//
try {
// configure actions
boolean enabled = !UiUtils.isEmpty(selection);
m_editAction.setEnabled(enabled);
m_editActionMenu.setEnabled(enabled);
m_deleteAction.setEnabled(enabled);
m_deleteActionMenu.setEnabled(enabled);
//
IBindingInfo binding = enabled ? (IBindingInfo) selection.getFirstElement() : null;
//
boolean moveUpEnabled = false;
boolean moveDownEnabled = false;
if (enabled) {
List<IBindingInfo> bindings = m_databindingsProvider.getBindings();
int size = bindings.size();
if (size > 1) {
int index = bindings.indexOf(binding);
if (index > 0) {
moveUpEnabled = m_databindingsProvider.canMoveBinding(binding, index - 1, true);
}
if (index < size - 1) {
moveDownEnabled = m_databindingsProvider.canMoveBinding(binding, index + 1, true);
}
}
}
//
m_upAction.setEnabled(moveUpEnabled);
m_upActionMenu.setEnabled(moveUpEnabled);
//
m_downAction.setEnabled(moveDownEnabled);
m_downActionMenu.setEnabled(moveDownEnabled);
//
m_gotoDefinitionAction.setEnabled(enabled);
m_gotoDefinitionActionMenu.setEnabled(enabled);
// handle selection
if (enabled && m_listener != null) {
m_listener.selectionChanged(binding);
}
// return focus to bounded table
m_bindingViewer.getTable().setFocus();
} finally {
m_skipSelectionEvent = false;
}
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindingElementsComposite method deleteBindind.
protected void deleteBindind() {
// prepare selection
IBindingInfo binding = getSelectionBinding();
// open confirm
boolean canDelete = canDeleteBinding(m_databindingsProvider, binding, getShell());
// handle delete
if (canDelete) {
// delete
List<IBindingInfo> bindings = m_databindingsProvider.getBindings();
int index = bindings.indexOf(binding);
m_databindingsProvider.deleteBinding(binding);
if (!isDisposed()) {
m_bindingViewer.refresh();
// invoke events
if (m_listener != null) {
m_listener.selectionChanged(null);
}
// update selection
if (index == bindings.size()) {
index--;
}
if (index != -1) {
m_bindingViewer.setSelection(new StructuredSelection(bindings.get(index)), true);
}
}
}
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class EditComposite method editBinding.
protected final void editBinding() {
// prepare binding
IBindingInfo binding = m_bindingComposite.getSelectionBinding();
// show edit dialog
BindDialog dialog = new BindDialog(getShell(), m_plugin, m_databindingsProvider, binding, false, false);
// handle done
if (dialog.open() == Window.OK) {
m_databindingsProvider.editBinding(binding);
if (!isDisposed()) {
m_targetObserveComposite.refresh();
m_modelObserveComposite.refresh();
m_bindingComposite.getViewer().refresh();
}
}
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class ControllerSupport method moveBeans.
private static void moveBeans(DatabindingsProvider provider) throws Exception {
AstEditor controllerASTEditor = provider.getAstEditor();
TypeDeclaration controllerRootNode = provider.getRootNode();
List<IBindingInfo> bindings = provider.getBindings();
int size = bindings.size();
Set<IObserveInfo> observes = Sets.newHashSet();
for (int i = size - 1; i >= 0; i--) {
IBindingInfo binding = bindings.get(i);
IObserveInfo model = binding.getModel();
if (observes.add(model)) {
moveBean(provider, model, controllerASTEditor, controllerRootNode);
}
IObserveInfo target = binding.getTarget();
if (observes.add(target)) {
moveBean(provider, target, controllerASTEditor, controllerRootNode);
}
}
//
controllerASTEditor.commitChanges();
controllerASTEditor.getModelUnit().getBuffer().save(null, true);
}
Aggregations