Search in sources :

Example 6 with IBindingInfo

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());
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo)

Example 7 with IBindingInfo

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;
    }
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo)

Example 8 with IBindingInfo

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);
            }
        }
    }
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 9 with IBindingInfo

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();
        }
    }
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo)

Example 10 with IBindingInfo

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);
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) AstEditor(org.eclipse.wb.internal.core.utils.ast.AstEditor) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration)

Aggregations

IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)81 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)51 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)48 BindingInfo (org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo)38 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)18 TreeViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo)16 DetailListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo)14 DetailSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)14 ListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo)14 SetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo)14 WritableListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)14 WritableSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo)14 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)13 CheckedElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo)13 ViewerObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo)13 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)12 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)12 ViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ViewerInputBindingInfo)12 MultiSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo)12 SingleSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo)12