private FileWidgetInputType createUseDocumentButton( TabbedPropertySheetWidgetFactory widgetFactory, final Composite radioComposite) { FileWidgetInputType initialInputType = element.getInputType(); if (!ModelHelper.isAnEntryPageFlowOnAPool(ModelHelper.getParentForm(element))) { useDocumentButton = widgetFactory.createButton(radioComposite, Messages.useDocument, SWT.RADIO); useDocumentButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { if (initialValueSection != null && !initialValueSection.isDisposed()) { if (useDocumentButton.getSelection() && (element.getInputType() != FileWidgetInputType.DOCUMENT || element.isDuplicate() != multiple || initialValueSection.getClient() == null)) { boolean recreate = false; if (initialValueSection.getClient() == null || element.getInputType() == FileWidgetInputType.RESOURCE) { recreate = true; } editingDomain .getCommandStack() .execute( SetCommand.create( editingDomain, element, FormPackage.Literals.FILE_WIDGET__INPUT_TYPE, FileWidgetInputType.DOCUMENT)); if (recreate) { if (initialValueSection.getClient() != null) { initialValueSection.getClient().dispose(); } multiple = element.isDuplicate(); initialValueSection.setClient( createInputExpressionComposite( initialValueSection, FileGridPropertySectionContribution.this.widgetFactory)); initialValueSection.setExpanded(true); bindFields(); } } } } }); } else { initialInputType = FileWidgetInputType.URL; } return initialInputType; }
/* * (non-Javadoc) * * @seeorg.bonitasoft.studio.common.properties. * IExtensibleGridPropertySectionContribution * #createControl(org.eclipse.swt.widgets.Composite, * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory, * org.bonitasoft.studio.common.properties.ExtensibleGridPropertySection) */ public void createControl( Composite mainComposite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection extensibleGridPropertySection) { this.widgetFactory = widgetFactory; mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); int col = 3; if (ModelHelper.isAnEntryPageFlowOnAPool(ModelHelper.getParentForm(element))) { col = 2; } mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create()); downloadOnly = widgetFactory.createButton(mainComposite, Messages.downloadOnly, SWT.CHECK); imagePreview = widgetFactory.createButton(mainComposite, Messages.previewAttachment, SWT.CHECK); widgetFactory.createLabel(mainComposite, ""); final Composite radioComposite = widgetFactory.createComposite(mainComposite); radioComposite.setLayoutData( GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .grab(true, false) .span(3, 1) .create()); radioComposite.setLayout( GridLayoutFactory.fillDefaults().numColumns(col).margins(0, 0).create()); FileWidgetInputType initialInputType = createUseDocumentButton(widgetFactory, radioComposite); // createURLButton(widgetFactory, radioComposite); createUseResourceButton(radioComposite); initialValueSection = widgetFactory.createSection(mainComposite, Section.NO_TITLE | Section.CLIENT_INDENT); initialValueSection.setLayout( GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).create()); initialValueSection.setLayoutData( GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create()); if (initialInputType == FileWidgetInputType.DOCUMENT) { initialValueSection.setClient( createInputExpressionComposite(initialValueSection, widgetFactory)); /*}else if(initialInputType == FileWidgetInputType.URL){ initialValueSection.setClient(createInputExpressionComposite(initialValueSection, widgetFactory));*/ } else if (initialInputType == FileWidgetInputType.RESOURCE) { if (element.isDuplicate()) { initialValueSection.setClient( createMultipleResourceComposite(initialValueSection, widgetFactory)); } else { initialValueSection.setClient(createResourceComposite(initialValueSection, widgetFactory)); } } bindFields(); if (initialInputType == FileWidgetInputType.DOCUMENT) { useDocumentButton.setSelection(true); useDocumentButton.notifyListeners(SWT.Selection, new Event()); /*}else if(initialInputType == FileWidgetInputType.URL){ useURLButton.setSelection(true);*/ } else { useResourceButton.setSelection(true); useResourceButton.notifyListeners(SWT.Selection, new Event()); } }