public StereotypeImageEditor(Composite parent, int style) { TabbedPropertySheetWidgetFactory factory = AbstractEditor.factory; composite = factory.createFlatFormComposite(parent); FormData data; browseButton = factory.createButton(composite, "", SWT.PUSH); // $NON-NLS-1$ browseButton.setImage(Activator.getDefault().getImage(addImagePath)); removeButton = factory.createButton(composite, "", SWT.PUSH); // $NON-NLS-1$ removeButton.setImage(Activator.getDefault().getImage("/icons/delete.gif")); // $NON-NLS-1$ CLabel iconLabel = factory.createCLabel(composite, "Content: "); // browseButton layout data = new FormData(); data.left = new FormAttachment(0, 85); data.top = new FormAttachment(0, ITabbedPropertyConstants.HSPACE); browseButton.setLayoutData(data); // removeButton layout data = new FormData(); data.left = new FormAttachment(browseButton, ITabbedPropertyConstants.HSPACE); data.top = new FormAttachment(browseButton, 0, SWT.CENTER); removeButton.setLayoutData(data); // iconLabel layout data = new FormData(); data.left = new FormAttachment(0, 0); data.top = new FormAttachment(browseButton, 0, SWT.CENTER); iconLabel.setLayoutData(data); browseButton.addSelectionListener(this); removeButton.addSelectionListener(this); }
protected Control createResourceComposite( Section section, TabbedPropertySheetWidgetFactory widgetFactory) { final Composite client = widgetFactory.createComposite(section); client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); client.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); resourceText = widgetFactory.createText(client, ""); resourceText.setLayoutData( GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create()); final ControlDecoration cd = new ControlDecoration(resourceText, SWT.LEFT); cd.setImage(Pics.getImage(PicsConstants.hint)); cd.setDescriptionText(Messages.filewidget_resource_hint); final Button browseResourceButton = widgetFactory.createButton(client, Messages.Browse, SWT.PUSH); browseResourceButton.setLayoutData(GridDataFactory.fillDefaults().create()); browseResourceButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final SelectDocumentInBonitaStudioRepository selectDocumentInBonitaStudioRepository = new SelectDocumentInBonitaStudioRepository(Display.getDefault().getActiveShell()); if (IDialogConstants.OK_ID == selectDocumentInBonitaStudioRepository.open()) { resourceText.setText( selectDocumentInBonitaStudioRepository.getSelectedDocument().getName()); } } }); return client; }
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; }
@Override public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); final TabbedPropertySheetWidgetFactory factory = getWidgetFactory(); _panel = factory.createComposite(parent); _panel.setLayout(new GridLayout(3, false)); _newBPELLink = new Link(_panel, SWT.NONE); _newBPELLink.setText("<a>BPEL File:</a>"); _newBPELLink.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { openFile(); } }); _bpelFileText = factory.createText(_panel, "", SWT.READ_ONLY); _bpelFileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); _bpelFileText.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent event) { final QName newValue = _bpelFileText.getText().length() == 0 ? null : QName.valueOf(_bpelFileText.getText()); if (!_updating && ((newValue == null && _implementation.getProcess() != null) || (newValue != null && !newValue.equals(_implementation.getProcess())))) { wrapOperation( new Runnable() { public void run() { _implementation.setProcess(newValue); } }); } } }); _browseBPELButton = factory.createButton(_panel, "Browse...", SWT.PUSH); _browseBPELButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { handleBrowse(); } }); }
private void createUseResourceButton(Composite radioComposite) { useResourceButton = widgetFactory.createButton(radioComposite, Messages.useResource, SWT.RADIO); useResourceButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { if (initialValueSection != null && !initialValueSection.isDisposed()) { if (useResourceButton.getSelection() && (element.getInputType() != FileWidgetInputType.RESOURCE || element.isDuplicate() != multiple || initialValueSection.getClient() == null)) { editingDomain .getCommandStack() .execute( SetCommand.create( editingDomain, element, FormPackage.Literals.FILE_WIDGET__INPUT_TYPE, FileWidgetInputType.RESOURCE)); if (initialValueSection.getClient() != null) { initialValueSection.getClient().dispose(); } if (element.isDuplicate()) { multiple = true; initialValueSection.setClient( createMultipleResourceComposite( initialValueSection, FileGridPropertySectionContribution.this.widgetFactory)); } else { multiple = false; initialValueSection.setClient( createResourceComposite( initialValueSection, FileGridPropertySectionContribution.this.widgetFactory)); } initialValueSection.setExpanded(true); bindFields(); } } } }); }
@Override public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { super.createControls(parent, tabbedPropertySheetPage); TabbedPropertySheetWidgetFactory factory = getWidgetFactory(); FormData data; inputButton = factory.createButton(composite, "Input?", SWT.CHECK); data = new FormData(); data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH); data.top = new FormAttachment(composite, VSPACE * 2, SWT.BOTTOM); inputButton.setLayoutData(data); outputButton = factory.createButton(composite, "Output?", SWT.CHECK); data = new FormData(); data.left = new FormAttachment(inputButton, HSPACE, SWT.RIGHT); data.top = new FormAttachment(inputButton, 0, SWT.TOP); outputButton.setLayoutData(data); multiportButton = factory.createButton(composite, "Multiport?", SWT.CHECK); data = new FormData(); data.left = new FormAttachment(outputButton, HSPACE, SWT.RIGHT); data.top = new FormAttachment(outputButton, 0, SWT.TOP); multiportButton.setLayoutData(data); inputButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PictogramElement pe = getSelectedPictogramElement(); if (pe != null) { EObject port = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe); if (actorViewModel.isPort(port, null)) { setIoKind( port, inputButton.getSelection(), actorViewModel.isPort(port, PortKind.OUTPUT)); } } } }); outputButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PictogramElement pe = getSelectedPictogramElement(); if (pe != null) { EObject port = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe); if (actorViewModel.isPort(port, null)) { setIoKind( port, actorViewModel.isPort(port, PortKind.INPUT), outputButton.getSelection()); } } } }); multiportButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { PictogramElement pe = getSelectedPictogramElement(); if (pe != null) { EObject port = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe); if (actorViewModel.isPort(port, null)) { setMultiport(port, multiportButton.getSelection()); } } } }); }
/** * Method createControls. * * @param parent Composite * @param aTabbedPropertySheetPage TabbedPropertySheetPage * @see org.eclipse.ui.views.properties.tabbed.ISection#createControls(Composite, * TabbedPropertySheetPage) */ @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); // Tell element to build its own detailed tab layout final TabbedPropertySheetWidgetFactory widgetFactory = aTabbedPropertySheetPage.getWidgetFactory(); final Composite composite = widgetFactory.createFlatFormComposite(parent); FormData data = null; // Position (read-only) widgetFactory.setBorderStyle(SWT.NULL); fPositionText = widgetFactory.createText(composite, "", SWT.NULL); data = new FormData(); data.left = new FormAttachment(0, R4EUIConstants.TABBED_PROPERTY_LABEL_WIDTH); data.right = new FormAttachment(100, 0); // $codepro.audit.disable numericLiterals data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE); fPositionText.setEditable(false); fPositionText.setToolTipText(R4EUIConstants.CONTENTS_POSITION_TOOLTIP); fPositionText.setLayoutData(data); final CLabel positionLabel = widgetFactory.createCLabel(composite, R4EUIConstants.POSITION_LABEL); data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(fPositionText, -ITabbedPropertyConstants.HSPACE); data.top = new FormAttachment(fPositionText, 0, SWT.CENTER); positionLabel.setToolTipText(R4EUIConstants.CONTENTS_POSITION_TOOLTIP); positionLabel.setLayoutData(data); // Assigned To fAssignedToComposite = widgetFactory.createComposite(composite); data = new FormData(); data.left = new FormAttachment(0, R4EUIConstants.TABBED_PROPERTY_LABEL_WIDTH); data.right = new FormAttachment(100, 0); // $codepro.audit.disable numericLiterals data.top = new FormAttachment(fPositionText, ITabbedPropertyConstants.VSPACE); fAssignedToComposite.setToolTipText(R4EUIConstants.ASSIGNED_TO_TOOLTIP); fAssignedToComposite.setLayoutData(data); fAssignedToComposite.setLayout(new GridLayout(3, false)); widgetFactory.setBorderStyle(SWT.BORDER); fAssignedToText = widgetFactory.createText(fAssignedToComposite, ""); fAssignedToText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); fAssignedToText.setEditable(false); fAssignedToButton = widgetFactory.createButton(fAssignedToComposite, R4EUIConstants.ADD_LABEL, SWT.NONE); fAssignedToButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); fAssignedToButton.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { ((R4EUIContent) fProperties.getElement()).addAssignees(UIUtils.getAssignParticipants()); refresh(); R4EUIModelController.getNavigatorView().getTreeViewer().refresh(); } }); fUnassignedFromButton = widgetFactory.createButton(fAssignedToComposite, R4EUIConstants.REMOVE_LABEL, SWT.NONE); fUnassignedFromButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); fUnassignedFromButton.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { ((R4EUIContent) fProperties.getElement()) .removeAssignees(UIUtils.getUnassignParticipants(fProperties.getElement())); refresh(); R4EUIModelController.getNavigatorView().getTreeViewer().refresh(); } }); final CLabel assignedToLabel = widgetFactory.createCLabel(composite, R4EUIConstants.ASSIGNED_TO_LABEL); data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(fAssignedToComposite, -ITabbedPropertyConstants.HSPACE); data.top = new FormAttachment(fAssignedToComposite, 0, SWT.CENTER); assignedToLabel.setToolTipText(R4EUIConstants.ASSIGNED_TO_TOOLTIP); assignedToLabel.setLayoutData(data); }
/* (non-Javadoc) * @see org.bonitasoft.studio.common.properties.IExtensibleGridPropertySectionContribution#createControl(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory, org.bonitasoft.studio.common.properties.ExtensibleGridPropertySection) */ @Override public void createControl( Composite composite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection extensibleGridPropertySection) { SimulationTransition transition; if (((Activity) eObject).getLoopTransition() == null) { transition = SimulationFactory.eINSTANCE.createSimulationTransition(); editingDomain .getCommandStack() .execute( new SetCommand( editingDomain, eObject, SimulationPackage.Literals.SIMULATION_ACTIVITY__LOOP_TRANSITION, transition)); } else { transition = ((Activity) eObject).getLoopTransition(); } composite.setLayout(new GridLayout(2, false)); Composite radioComposite = widgetFactory.createComposite(composite); radioComposite.setLayout(new FillLayout()); radioComposite.setLayoutData(GridDataFactory.fillDefaults().create()); Button expressionRadio = widgetFactory.createButton(radioComposite, "Expression", SWT.RADIO); Button probaRadio = widgetFactory.createButton(radioComposite, "Probability", SWT.RADIO); final Composite stackComposite = widgetFactory.createComposite(composite); stackComposite.setLayoutData(GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).create()); final StackLayout stackLayout = new StackLayout(); stackComposite.setLayout(stackLayout); final Composite probaComposite = widgetFactory.createComposite(stackComposite); FillLayout layout = new FillLayout(); layout.marginWidth = 10; probaComposite.setLayout(layout); Text probaText = widgetFactory.createText(probaComposite, "", SWT.BORDER); ControlDecoration controlDecoration = new ControlDecoration(probaText, SWT.LEFT | SWT.TOP); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); controlDecoration.setImage(fieldDecoration.getImage()); controlDecoration.setDescriptionText(Messages.mustBeAPercentage); final Composite expressionComposite = widgetFactory.createComposite(stackComposite); FillLayout layout2 = new FillLayout(); layout2.marginWidth = 10; expressionComposite.setLayout(layout2); ExpressionViewer expressionText = new ExpressionViewer( expressionComposite, SWT.BORDER, widgetFactory, editingDomain, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION); Expression selection = transition.getExpression(); if (selection == null) { selection = ExpressionFactory.eINSTANCE.createExpression(); editingDomain .getCommandStack() .execute( SetCommand.create( editingDomain, transition, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION, selection)); } context.bindValue( ViewerProperties.singleSelection().observe(expressionText), EMFEditProperties.value( editingDomain, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION) .observe(eObject)); expressionText.setInput(eObject); boolean useExpression = transition.isUseExpression(); if (useExpression) { stackLayout.topControl = expressionComposite; } else { stackLayout.topControl = probaComposite; } expressionRadio.setSelection(useExpression); probaRadio.setSelection(!useExpression); expressionRadio.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (((Button) e.getSource()).getSelection()) { stackLayout.topControl = expressionComposite; } else { stackLayout.topControl = probaComposite; } stackComposite.layout(); } }); context = new EMFDataBindingContext(); context.bindValue( SWTObservables.observeSelection(expressionRadio), EMFEditObservables.observeValue( editingDomain, transition, SimulationPackage.Literals.SIMULATION_TRANSITION__USE_EXPRESSION)); context.bindValue( SWTObservables.observeText(probaText, SWT.Modify), EMFEditObservables.observeValue( editingDomain, transition, SimulationPackage.Literals.SIMULATION_TRANSITION__PROBABILITY), new UpdateValueStrategy() .setConverter( StringToNumberConverter.toDouble(BonitaNumberFormat.getPercentInstance(), false)) .setAfterGetValidator( new WrappingValidator( controlDecoration, new StringToDoubleValidator( StringToNumberConverter.toDouble( BonitaNumberFormat.getPercentInstance(), false)))), new UpdateValueStrategy() .setConverter( NumberToStringConverter.fromDouble( BonitaNumberFormat.getPercentInstance(), false))); }
protected Control createMultipleResourceComposite( Section section, TabbedPropertySheetWidgetFactory widgetFactory) { final Composite client = widgetFactory.createComposite(section); client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); client.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); resourceTableViewer = new TableViewer(client, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL); resourceTableViewer .getControl() .setLayoutData( GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 60).create()); resourceTableViewer.setContentProvider(new ArrayContentProvider()); resourceTableViewer.setLabelProvider(new LabelProvider()); final ControlDecoration cd = new ControlDecoration(resourceTableViewer.getControl(), SWT.TOP | SWT.LEFT); cd.setImage(Pics.getImage(PicsConstants.hint)); cd.setDescriptionText(Messages.filewidget_resource_hint_multiple); final Composite buttonComposite = widgetFactory.createComposite(client); buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create()); buttonComposite.setLayout( GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 3).create()); final Button addResourceButton = widgetFactory.createButton(buttonComposite, Messages.Add, SWT.PUSH); addResourceButton.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).hint(85, SWT.DEFAULT).create()); addResourceButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final SelectDocumentInBonitaStudioRepository selectDocumentInBonitaStudioRepository = new SelectDocumentInBonitaStudioRepository(Display.getDefault().getActiveShell()); if (IDialogConstants.OK_ID == selectDocumentInBonitaStudioRepository.open()) { editingDomain .getCommandStack() .execute( AddCommand.create( editingDomain, element, FormPackage.Literals.FILE_WIDGET__INTIAL_RESOURCE_LIST, selectDocumentInBonitaStudioRepository.getSelectedDocument().getName())); resourceTableViewer.refresh(); } } }); final Button removeResourceButton = widgetFactory.createButton(buttonComposite, Messages.Remove, SWT.PUSH); removeResourceButton.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).hint(85, SWT.DEFAULT).create()); removeResourceButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { editingDomain .getCommandStack() .execute( RemoveCommand.create( editingDomain, element, FormPackage.Literals.FILE_WIDGET__INTIAL_RESOURCE_LIST, ((IStructuredSelection) resourceTableViewer.getSelection()).toList())); resourceTableViewer.refresh(); } }); resourceTableViewer.setInput( EMFEditProperties.list( editingDomain, FormPackage.Literals.FILE_WIDGET__INTIAL_RESOURCE_LIST) .observe(element)); return client; }
/* * (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()); } }