Search in sources :

Example 16 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class TabContainerUiContentProvider method getErrorMessage.

@Override
public String getErrorMessage() {
    // no errors
    if (m_showEmptyPage) {
        return null;
    }
    // find first with error
    int count = m_folder.getItemCount();
    for (int i = 0; i < count; i++) {
        IUiContentProvider contentProvider = (IUiContentProvider) m_folder.getItem(i).getData();
        String errorMessage = contentProvider.getErrorMessage();
        if (errorMessage != null) {
            return errorMessage;
        }
    }
    return null;
}
Also used : IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider) Point(org.eclipse.swt.graphics.Point)

Example 17 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class TabContainerUiContentProvider method getProviders.

protected final List<IUiContentProvider> getProviders() {
    List<IUiContentProvider> providers = Lists.newArrayList();
    if (!m_showEmptyPage) {
        int count = m_folder.getItemCount();
        for (int i = 0; i < count; i++) {
            IUiContentProvider provider = (IUiContentProvider) m_folder.getItem(i).getData();
            providers.add(provider);
        }
    }
    return providers;
}
Also used : IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider) Point(org.eclipse.swt.graphics.Point)

Example 18 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class UpdateStrategyPropertiesUiContentProvider method createContent.

@Override
public void createContent(final Composite parent, int columns) {
    // create expandable composite
    m_expandableComposite = new ExpandableComposite(parent, SWT.NONE);
    m_expandableComposite.setExpanded(true);
    GridDataFactory.create(m_expandableComposite).fillH().grabH().spanH(columns);
    m_expandableComposite.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            compositeExpansionStateChanging();
            parent.layout();
        }
    });
    // calculate columns
    int subColumns = 0;
    for (IUiContentProvider provider : m_providers) {
        subColumns = Math.max(subColumns, provider.getNumberOfControls());
    }
    // create sub content providers
    Composite clientComposite = new Composite(m_expandableComposite, SWT.NONE);
    GridLayoutFactory.create(clientComposite).columns(subColumns).noMargins();
    m_expandableComposite.setClient(clientComposite);
    // 
    for (IUiContentProvider provider : m_providers) {
        provider.createContent(clientComposite, subColumns);
    }
    compositeExpansionStateChanging();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)

Example 19 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class UiConfigurationTest method test_ObservableInfo.

// //////////////////////////////////////////////////////////////////////////
// 
// Tests
// 
// //////////////////////////////////////////////////////////////////////////
public void test_ObservableInfo() throws Exception {
    CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "import org.eclipse.core.databinding.Binding;", "public class Test {", "  protected Shell m_shell;", "  private Text m_text;", "  private CheckboxTableViewer m_viewer;", "  private DataBindingContext m_bindingContext;", "  public static void main(String[] args) {", "    Test test = new Test();", "    test.open();", "  }", "  public void open() {", "    Display display = new Display();", "    createContents();", "    m_shell.open();", "    m_shell.layout();", "    while (!m_shell.isDisposed()) {", "      if (!display.readAndDispatch()) {", "        display.sleep();", "      }", "    }", "  }", "  protected void createContents() {", "    m_shell = new Shell();", "    m_text = new Text(m_shell, SWT.SINGLE);", "    m_viewer = new CheckboxTableViewer(m_shell, SWT.BORDER);", "    m_bindingContext = initDataBindings();", "  }", "  private DataBindingContext initDataBindings() {", "    IObservableValue observeValue = BeansObservables.observeValue(getClass(), \"name\");", "    IObservableValue observeDetailValue = BeansObservables.observeDetailValue(observeValue, \"empty\", boolean.class);", "    IObservableValue observeWidget = SWTObservables.observeFont(m_shell);", "    IObservableValue observeText = SWTObservables.observeText(m_text, SWT.Modify);", "    IObservableSet observeSet = BeansObservables.observeSet(getClass(), \"name\");", "    IObservableSet observeViewerSet = ViewersObservables.observeCheckedElements(m_viewer, String.class);", "    DataBindingContext bindingContext = new DataBindingContext();", "    bindingContext.bindValue(observeWidget, observeValue, null, null);", "    bindingContext.bindValue(observeText, observeDetailValue, null, null);", "    bindingContext.bindSet(observeViewerSet, observeSet, null, null);", "    return bindingContext;", "  }", "}" });
    assertNotNull(shell);
    // 
    DatabindingsProvider provider = getDatabindingsProvider();
    // 
    List<IUiContentProvider> providers = Lists.newArrayList();
    // 
    BindingUiContentProviderContext context = new BindingUiContentProviderContext();
    context.setDirection("Target");
    assertEquals("Target", context.getDirection());
    assertNull(context.getValue("MyValueKey"));
    context.setValue("MyValueKey", "MyValue");
    assertEquals("MyValue", context.getValue("MyValueKey"));
    context.setValue("MyValueKey", null);
    assertNull(context.getValue("MyValueKey"));
    // ------------------------------------------------------------------------
    assertEquals(3, provider.getBindings().size());
    assertInstanceOf(BindingInfo.class, provider.getBindings().get(0));
    BindingInfo binding0 = (BindingInfo) provider.getBindings().get(0);
    // 
    binding0.getModelObservable().createContentProviders(providers, context, provider);
    assertTrue(providers.isEmpty());
    // 
    binding0.getTargetObservable().createContentProviders(providers, context, provider);
    // 
    assertEquals(1, providers.size());
    assertInstanceOf(SwtDelayUiContentProvider.class, providers.get(0));
    // ------------------------------------------------------------------------
    assertInstanceOf(BindingInfo.class, provider.getBindings().get(1));
    BindingInfo binding1 = (BindingInfo) provider.getBindings().get(1);
    // 
    providers.clear();
    binding1.getTargetObservable().createContentProviders(providers, context, provider);
    // 
    assertEquals(2, providers.size());
    assertInstanceOf(SwtTextEventsUiContentProvider.class, providers.get(0));
    assertInstanceOf(SwtDelayUiContentProvider.class, providers.get(1));
    // 
    providers.clear();
    binding1.getModelObservable().createContentProviders(providers, context, provider);
    // 
    assertEquals(1, providers.size());
    assertInstanceOf(ObservableDetailUiContentProvider.class, providers.get(0));
    // 
    ChooseClassAndPropertiesConfiguration detailActual = (ChooseClassAndPropertiesConfiguration) getConfiguration(providers.get(0));
    // 
    ChooseClassAndPropertiesConfiguration detailExpected = new ChooseClassAndPropertiesConfiguration();
    detailExpected.setDialogFieldLabel("Master bean class:");
    detailExpected.setValueScope("beans");
    detailExpected.setChooseInterfaces(true);
    detailExpected.setEmptyClassErrorMessage("Choose a master bean class that contains properties.");
    detailExpected.setErrorMessagePrefix("Master bean class");
    detailExpected.setPropertiesLabel("Properties (for detail):");
    detailExpected.setPropertiesErrorMessage("Choose a detail property.");
    detailExpected.addDefaultStart("detail(");
    // 
    assertEquals(detailExpected, detailActual);
    // --------------------------------------------------------------------------
    assertInstanceOf(BindingInfo.class, provider.getBindings().get(2));
    BindingInfo binding2 = (BindingInfo) provider.getBindings().get(2);
    // 
    providers.clear();
    binding2.getTargetObservable().createContentProviders(providers, context, provider);
    // 
    assertEquals(1, providers.size());
    assertInstanceOf(CheckedElementsUiContentProvider.class, providers.get(0));
    // 
    ChooseClassConfiguration actual = getConfiguration(providers.get(0));
    // 
    ChooseClassConfiguration expected = new ChooseClassConfiguration();
    expected.setDialogFieldLabel("Checked bean class:");
    expected.setValueScope("beans");
    expected.setChooseInterfaces(true);
    expected.setEmptyClassErrorMessage("Choose Target checked bean class.");
    expected.setErrorMessagePrefix("Target checked bean");
    // 
    assertEquals(expected, actual);
}
Also used : BindingUiContentProviderContext(org.eclipse.wb.internal.rcp.databinding.model.context.BindingUiContentProviderContext) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider) ChooseClassAndPropertiesConfiguration(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration) ChooseClassConfiguration(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)

Example 20 with IUiContentProvider

use of org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider in project windowbuilder by eclipse.

the class UiConfigurationTest method test_UpdateSetStrategy.

public void test_UpdateSetStrategy() throws Exception {
    CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "import org.eclipse.core.databinding.Binding;", "public class Test {", "  protected Shell m_shell;", "  private DataBindingContext m_bindingContext;", "  public static void main(String[] args) {", "    Test test = new Test();", "    test.open();", "  }", "  public void open() {", "    Display display = new Display();", "    createContents();", "    m_shell.open();", "    m_shell.layout();", "    while (!m_shell.isDisposed()) {", "      if (!display.readAndDispatch()) {", "        display.sleep();", "      }", "    }", "  }", "  protected void createContents() {", "    m_shell = new Shell();", "    m_bindingContext = initDataBindings();", "  }", "  private DataBindingContext initDataBindings() {", "    IObservableSet observeSet1 = BeansObservables.observeSet(getClass(), \"name\");", "    IObservableSet observeSet2 = BeansObservables.observeSet(getClass(), \"modifiers\");", "    DataBindingContext bindingContext = new DataBindingContext();", "    bindingContext.bindSet(observeSet1, observeSet2, null, null);", "    return bindingContext;", "  }", "}" });
    assertNotNull(shell);
    // 
    DatabindingsProvider provider = getDatabindingsProvider();
    // 
    assertEquals(1, provider.getBindings().size());
    assertInstanceOf(BindingInfo.class, provider.getBindings().get(0));
    BindingInfo binding = (BindingInfo) provider.getBindings().get(0);
    // 
    assertNotNull(binding.getTargetStrategy());
    // 
    List<IUiContentProvider> providers = Lists.newArrayList();
    BindingUiContentProviderContext context = new BindingUiContentProviderContext();
    context.setDirection("Target");
    binding.getTargetStrategy().createContentProviders(providers, context);
    assertEquals(2, providers.size());
    // 
    assertInstanceOf(UpdateStrategyUiContentProvider.class, providers.get(0));
    assertInstanceOf(ChooseClassConfiguration.class, ReflectionUtils.getFieldObject(providers.get(0), "m_configuration"));
    // 
    ChooseClassConfiguration actual = getConfiguration(providers.get(0));
    // 
    ChooseClassConfiguration expected = new ChooseClassConfiguration();
    expected.setDialogFieldLabel("UpdateSetStrategy:");
    expected.setDefaultValues(new String[] { "POLICY_UPDATE", "POLICY_NEVER", "POLICY_ON_REQUEST" });
    expected.setValueScope("org.eclipse.core.databinding.UpdateSetStrategy");
    expected.setRetargetClassName("org.eclipse.core.databinding.UpdateSetStrategy", "POLICY_UPDATE");
    expected.setBaseClassName("org.eclipse.core.databinding.UpdateSetStrategy");
    expected.setConstructorParameters(ArrayUtils.EMPTY_CLASS_ARRAY);
    expected.setEmptyClassErrorMessage("Target strategy class is empty.");
    expected.setErrorMessagePrefix("Target strategy");
    // 
    assertEquals(expected, actual);
    // 
    assertInstanceOf(UpdateStrategyPropertiesUiContentProvider.class, providers.get(1));
    // 
    List<IUiContentProvider> subProviders = (List<IUiContentProvider>) ReflectionUtils.getFieldObject(providers.get(1), "m_providers");
    assertEquals(1, subProviders.size());
    assertInstanceOf(ConverterUiContentProvider.class, subProviders.get(0));
    // 
    ChooseClassConfiguration converterActual = getConfiguration(subProviders.get(0));
    // 
    ChooseClassConfiguration converterExpected = new ChooseClassConfiguration();
    converterExpected.setDialogFieldLabel("Converter:");
    converterExpected.setValueScope("org.eclipse.core.databinding.conversion.IConverter");
    converterExpected.setClearValue("N/S");
    converterExpected.setBaseClassName("org.eclipse.core.databinding.conversion.IConverter");
    converterExpected.setConstructorParameters(ArrayUtils.EMPTY_CLASS_ARRAY);
    converterExpected.setEmptyClassErrorMessage("Target converter class is empty.");
    converterExpected.setErrorMessagePrefix("Target converter");
    // 
    assertEquals(converterExpected, converterActual);
}
Also used : BindingUiContentProviderContext(org.eclipse.wb.internal.rcp.databinding.model.context.BindingUiContentProviderContext) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) List(java.util.List) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider) ChooseClassConfiguration(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)

Aggregations

IUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)22 List (java.util.List)6 Point (org.eclipse.swt.graphics.Point)5 ChooseClassConfiguration (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)5 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)5 BindingInfo (org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo)5 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)5 BindingUiContentProviderContext (org.eclipse.wb.internal.rcp.databinding.model.context.BindingUiContentProviderContext)4 ColumnBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.ColumnBindingInfo)3 IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)2 UiContentProviderComposite (org.eclipse.wb.internal.core.databinding.ui.editor.UiContentProviderComposite)2 AbstractBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo)2 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)2 BeansListObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo)2 BeansObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo)2 BeansSetObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo)2 TreeObservableLabelProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1