Search in sources :

Example 11 with RunnableEx

use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.

the class DatabindingsProvider method addBinding.

public void addBinding(final IBindingInfo ibinding) {
    // add
    getBindings().add(ibinding);
    // post process
    ExecutionUtils.runLog(new RunnableEx() {

        public void run() throws Exception {
            BindingInfo binding = (BindingInfo) ibinding;
            binding.create(m_rootInfo.getBindings());
        }
    });
    // save
    saveEdit();
}
Also used : JTableBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JTableBindingInfo) JComboBoxBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JComboBoxBindingInfo) ColumnBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.ColumnBindingInfo) BindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.BindingInfo) JListBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo) DetailBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.DetailBindingInfo) AutoBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.AutoBindingInfo) VirtualBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.VirtualBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) RunnableEx(org.eclipse.wb.internal.core.utils.execution.RunnableEx)

Example 12 with RunnableEx

use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.

the class DimensionsDialog method editSelectedDimension.

/**
 * Edits the selected {@link MigDimensionInfo}.
 */
private void editSelectedDimension() {
    T dimension = GenericsUtils.<T>first(m_viewer.getSelection());
    editSelectedDimension(dimension);
    applyChanges(new RunnableEx() {

        public void run() throws Exception {
        }
    });
}
Also used : SWT(org.eclipse.swt.SWT) RunnableEx(org.eclipse.wb.internal.core.utils.execution.RunnableEx)

Example 13 with RunnableEx

use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.

the class DimensionsDialog method createButtonsComposite.

/**
 * Creates {@link Composite} with {@link Button}'s.
 */
private void createButtonsComposite(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridDataFactory.create(composite).fill();
    GridLayoutFactory.create(composite).marginsV(0);
    // 
    createButton(composite, ModelMessages.DimensionsDialog_insertButton, new Listener() {

        public void handleEvent(Event event) {
            addNewDimension(0);
        }
    });
    createButton(composite, ModelMessages.DimensionsDialog_appendButton, new Listener() {

        public void handleEvent(Event event) {
            addNewDimension(1);
        }
    });
    m_editButton = createButton(composite, ModelMessages.DimensionsDialog_editButton, new Listener() {

        public void handleEvent(Event event) {
            editSelectedDimension();
        }
    });
    m_removeButton = createButton(composite, ModelMessages.DimensionsDialog_removeButton, new Listener() {

        public void handleEvent(Event event) {
            final AtomicInteger lastIndex = new AtomicInteger();
            applyChanges(new RunnableEx() {

                public void run() throws Exception {
                    Iterable<T> selectedDimensions = GenericsUtils.<T>iterable(m_viewer.getSelection());
                    for (T dimension : selectedDimensions) {
                        lastIndex.set(dimension.getIndex());
                        dimension.delete();
                    }
                }
            });
            // set selection
            int index = lastIndex.get();
            index = Math.min(index, m_dimensions2.size() - 1);
            m_viewer.getTable().select(index);
            // validate
            updateButtons();
        }
    });
    // 
    new Label(composite, SWT.NONE);
    m_moveUpButton = createButton(composite, ModelMessages.DimensionsDialog_moveUpButton, new Listener() {

        public void handleEvent(Event event) {
            applyChanges(new RunnableEx() {

                public void run() throws Exception {
                    Iterable<T> selectedDimensions = GenericsUtils.<T>iterable(m_viewer.getSelection());
                    moveDimensionsUp(selectedDimensions);
                }
            });
            updateButtons();
        }
    });
    m_moveDownButton = createButton(composite, ModelMessages.DimensionsDialog_moveDownButton, new Listener() {

        public void handleEvent(Event event) {
            applyChanges(new RunnableEx() {

                public void run() throws Exception {
                    Iterable<T> selectedDimensions = GenericsUtils.<T>iterable(m_viewer.getSelection());
                    moveDimensionsDown(selectedDimensions);
                }
            });
            updateButtons();
        }
    });
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) RunnableEx(org.eclipse.wb.internal.core.utils.execution.RunnableEx)

Example 14 with RunnableEx

use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.

the class DimensionsDialog method addNewDimension.

/**
 * Adds new {@link MigDimensionInfo}.
 *
 * @param indexOffset
 *          the offset to add to the current selection index, <code>0</code> to implement insert
 *          and <code>1</code> for append.
 */
private void addNewDimension(int indexOffset) {
    // add new dimension
    final int index = addNewDimension_getIndex(indexOffset);
    applyChanges(new RunnableEx() {

        public void run() throws Exception {
            createNewDimension(index);
        }
    });
    m_viewer.getTable().setSelection(index);
    // edit it
    editSelectedDimension();
}
Also used : RunnableEx(org.eclipse.wb.internal.core.utils.execution.RunnableEx)

Example 15 with RunnableEx

use of org.eclipse.wb.internal.core.utils.execution.RunnableEx in project windowbuilder by eclipse.

the class DimensionsDialog method applyChanges.

/**
 * Applies changes in {@link MigDimensionInfo}-s.
 */
private void applyChanges(final RunnableEx runnable) {
    ExecutionUtils.run(m_layout, new RunnableEx() {

        public void run() throws Exception {
            runnable.run();
            m_layout.writeDimensions();
        }
    });
    m_viewer.refresh();
}
Also used : RunnableEx(org.eclipse.wb.internal.core.utils.execution.RunnableEx)

Aggregations

RunnableEx (org.eclipse.wb.internal.core.utils.execution.RunnableEx)259 ContainerInfo (org.eclipse.wb.internal.swing.model.component.ContainerInfo)57 ComponentInfo (org.eclipse.wb.internal.swing.model.component.ComponentInfo)55 GridBagLayoutInfo (org.eclipse.wb.internal.swing.model.layout.gbl.GridBagLayoutInfo)42 AbstractGridBagLayoutInfo (org.eclipse.wb.internal.swing.model.layout.gbl.AbstractGridBagLayoutInfo)22 ObjectInfo (org.eclipse.wb.core.model.ObjectInfo)14 List (java.util.List)12 Expression (org.eclipse.jdt.core.dom.Expression)11 IAction (org.eclipse.jface.action.IAction)11 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)11 ControlInfo (org.eclipse.wb.internal.swt.model.widgets.ControlInfo)11 FormLayoutInfo (org.eclipse.wb.internal.swing.FormLayout.model.FormLayoutInfo)10 JavaInfo (org.eclipse.wb.core.model.JavaInfo)9 IMenuItemInfo (org.eclipse.wb.internal.core.model.menu.IMenuItemInfo)9 GridLayoutInfo (org.eclipse.wb.internal.xwt.model.layout.grid.GridLayoutInfo)9 MenuItemInfo (org.eclipse.wb.internal.xwt.model.widgets.menu.MenuItemInfo)9 JavaInfoMemento (org.eclipse.wb.internal.core.model.clipboard.JavaInfoMemento)8 AstEditor (org.eclipse.wb.internal.core.utils.ast.AstEditor)8 ControlInfo (org.eclipse.wb.internal.xwt.model.widgets.ControlInfo)8 JTextField (javax.swing.JTextField)7