List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer
public ComboViewer(Composite parent, int style)
From source file:org.bonitasoft.studio.businessobject.ui.wizard.QueryWizardPage.java
License:Open Source License
protected ComboViewer createReturnTypeComboViewer(final Composite composite) { return new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); }
From source file:org.bonitasoft.studio.condition.ui.expression.ComparisonExpressionEditor.java
License:Open Source License
protected void createReturnTypeComposite(Composite parent) { final Composite returnTypeComposite = new Composite(parent, SWT.NONE); returnTypeComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); returnTypeComposite.setLayoutData(// ww w . j a va 2s . co m GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.BOTTOM).create()); Label typeLabel = new Label(returnTypeComposite, SWT.NONE); typeLabel.setText(Messages.returnType); typeCombo = new ComboViewer(returnTypeComposite, SWT.BORDER | SWT.READ_ONLY); typeCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); typeCombo.setContentProvider(new ExpressionReturnTypeContentProvider()); typeCombo.setLabelProvider(new ConstantTypeLabelProvider()); typeCombo.setInput(new Object()); }
From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { final Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite/*from w ww .j a v a 2s. c o m*/ .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(400, SWT.DEFAULT).create()); mainComposite .setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 10).spacing(15, 5).create()); context = new DataBindingContext(); if (component == null) { component = ConnectorDefinitionFactory.eINSTANCE.createText(); } final Label idLabel = new Label(mainComposite, SWT.NONE); idLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); idLabel.setText(Messages.widgetId + "*"); final Text idText = new Text(mainComposite, SWT.BORDER); idText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); idTextObservable = SWTObservables.observeText(idText, SWT.Modify); bindComponentId(idText); final Label widgetTypeLabel = new Label(mainComposite, SWT.NONE); widgetTypeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); widgetTypeLabel.setText(Messages.widgetType); final ComboViewer typeViewer = new ComboViewer(mainComposite, SWT.BORDER | SWT.READ_ONLY); typeViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); typeViewer.setContentProvider(new ArrayContentProvider()); typeViewer.setLabelProvider(new WidgetLabelProvider()); typeViewer.setInput(widgetTypes); typeViewer.setSelection(new StructuredSelection(component.eClass())); final Label inputLabel = new Label(mainComposite, SWT.NONE); inputLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); inputLabel.setText(Messages.input + " *"); final ComboViewer inputViewer = new ComboViewer(mainComposite, SWT.BORDER | SWT.READ_ONLY); inputViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); inputViewer.setContentProvider(new ArrayContentProvider()); inputViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { Input input = (Input) element; return super.getText(input.getName() + " (" + input.getType() + ")"); } }); inputViewer.setInput(inputs); inputSelectionObservable = ViewersObservables.observeSingleSelection(inputViewer); bindComponentInput(inputViewer); final Label displayNameLabel = new Label(mainComposite, SWT.NONE); displayNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); displayNameLabel.setText(Messages.displayName); final Text displayNameText = new Text(mainComposite, SWT.BORDER); displayNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); context.bindValue(SWTObservables.observeText(displayNameText, SWT.Modify), PojoProperties.value(SelectPageWidgetDialog.class, "displayName").observe(this)); final Label descriptionLabel = new Label(mainComposite, SWT.NONE); descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); descriptionLabel.setText(Messages.description); final Text descriptionText = new Text(mainComposite, SWT.BORDER | SWT.MULTI); descriptionText .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 60).create()); context.bindValue(SWTObservables.observeText(descriptionText, SWT.Modify), PojoProperties.value(SelectPageWidgetDialog.class, "description").observe(this)); section = new Section(parent, Section.NO_TITLE); section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).create()); section.setClient(createSectionClient(component)); section.setExpanded(isExpanded(component)); typeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { EClass eClass = (EClass) ((IStructuredSelection) event.getSelection()).getFirstElement(); String id = null; if (component != null) { id = component.getId(); } String input = null; if (component instanceof WidgetComponent) { input = ((WidgetComponent) component).getInputName(); } component = (Component) ConnectorDefinitionFactory.eINSTANCE.create(eClass); component.setId(id); if (component instanceof WidgetComponent) { ((WidgetComponent) component).setInputName(input); } bindComponentId(idText); bindComponentInput(inputViewer); section.setClient(createSectionClient(component)); section.setExpanded(isExpanded(component)); Shell shell = section.getShell(); Point defaultSize = shell.getSize(); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); shell.setSize(defaultSize.x, size.y); shell.layout(true, true); } }); dialogSupport = DialogSupport.create(this, context); return mainComposite; }
From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java
License:Open Source License
private Control createScriptEditorComposite(ScriptEditor widget) { final Composite mainComposite = new Composite(section, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 0).create()); final Label interpreterLabel = new Label(mainComposite, SWT.NONE); interpreterLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); interpreterLabel.setText(Messages.interpreter + " *"); final ComboViewer interpreterViewer = new ComboViewer(mainComposite, SWT.BORDER | SWT.READ_ONLY); interpreterViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); interpreterViewer.setContentProvider(new ArrayContentProvider()); interpreterViewer.setLabelProvider(new LabelProvider()); List<String> interpreters = new ArrayList<String>(); for (IScriptLanguageProvider provider : ScriptLanguageService.getInstance().getScriptLanguageProviders()) { interpreters.add(provider.getLanguageName()); }/* w w w . j av a2s .c o m*/ interpreterViewer.setInput(interpreters); context.bindValue(ViewersObservables.observeSingleSelection(interpreterViewer), EMFObservables .observeValue(widget, ConnectorDefinitionPackage.Literals.SCRIPT_EDITOR__INTERPRETER)); return mainComposite; }
From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java
License:Open Source License
private Control createRadioGroupComposite(final RadioGroup widget) { final Composite mainComposite = new Composite(section, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 0).create()); final Label orientationLabel = new Label(mainComposite, SWT.NONE); orientationLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); orientationLabel.setText(Messages.orientation); final ComboViewer orientationCombo = new ComboViewer(mainComposite, SWT.READ_ONLY | SWT.BORDER); orientationCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); orientationCombo.setContentProvider(new ArrayContentProvider()); orientationCombo.setLabelProvider(new LabelProvider()); context.bindValue(ViewersObservables.observeInput(orientationCombo), PojoProperties.value(SelectPageWidgetDialog.class, "orientations").observe(this)); context.bindValue(ViewersObservables.observeSingleSelection(orientationCombo), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.RADIO_GROUP__ORIENTATION)); final Label itemsLabel = new Label(mainComposite, SWT.NONE); itemsLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); itemsLabel.setText(Messages.items);//from www . ja v a 2 s. com final Composite itemComposite = new Composite(mainComposite, SWT.NONE); itemComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); itemComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); final TableViewer itemViewer = new TableViewer(itemComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); itemViewer.getTable() .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80).create()); itemViewer.setContentProvider(new ArrayContentProvider()); final TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(100)); itemViewer.getTable().setLayout(layout); final TableViewerColumn inputNameColumn = new TableViewerColumn(itemViewer, SWT.FILL); inputNameColumn.getColumn().setText(Messages.input); inputNameColumn.setEditingSupport(new RadioGroupItemEditingSupport(itemViewer, widget)); inputNameColumn.setLabelProvider(new ColumnLabelProvider()); context.bindValue(ViewersObservables.observeInput(itemViewer), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.RADIO_GROUP__CHOICES)); final Composite buttonComposite = new Composite(itemComposite, SWT.NONE); buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create()); buttonComposite .setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 3).create()); final Button addButton = new Button(buttonComposite, SWT.FLAT); addButton.setText(Messages.Add); addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { String item = generateRadioChoice(widget); widget.getChoices().add(item); itemViewer.editElement(item, 0); } }); final Button upButton = new Button(buttonComposite, SWT.FLAT); upButton.setText(Messages.up); upButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); upButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { String selected = (String) ((IStructuredSelection) itemViewer.getSelection()).getFirstElement(); int i = widget.getChoices().indexOf(selected); if (i > 0) { widget.getChoices().move(i - 1, selected); itemViewer.refresh(); } } }); final Button downButton = new Button(buttonComposite, SWT.FLAT); downButton.setText(Messages.down); downButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); downButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { String selected = (String) ((IStructuredSelection) itemViewer.getSelection()).getFirstElement(); int i = widget.getChoices().indexOf(selected); if (i < widget.getChoices().size() - 1) { widget.getChoices().move(i + 1, selected); itemViewer.refresh(); } } }); final Button removeButton = new Button(buttonComposite, SWT.FLAT); removeButton.setText(Messages.remove); removeButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { widget.getChoices().removeAll(((IStructuredSelection) itemViewer.getSelection()).toList()); itemViewer.refresh(); } }); return mainComposite; }
From source file:org.bonitasoft.studio.connector.model.implementation.wizard.AbstractDefinitionSelectionImpementationWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { context = new EMFDataBindingContext(); Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create()); explorer = createTreeExplorer(mainComposite); final Label definitionVersionLabel = new Label(mainComposite, SWT.NONE); definitionVersionLabel.setText(Messages.definitionVersion); definitionVersionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); versionCombo = new ComboViewer(mainComposite, SWT.READ_ONLY | SWT.BORDER); versionCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().create()); versionCombo.setContentProvider(new ArrayContentProvider()); versionCombo.setLabelProvider(new LabelProvider()); versionCombo.getCombo().setEnabled(false); versionCombo.setSorter(new ViewerSorter()); final Group descriptionGroup = new Group(mainComposite, SWT.NONE); descriptionGroup.setText(Messages.description); descriptionGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).create()); descriptionGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); final Label descriptionLabel = new Label(descriptionGroup, SWT.WRAP); descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); explorer.getRightTableViewer().addSelectionChangedListener(new ISelectionChangedListener() { @Override// ww w . ja va 2s .c o m public void selectionChanged(SelectionChangedEvent event) { Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (sel instanceof ConnectorDefinition) { final String defId = ((ConnectorDefinition) sel).getId(); List<String> versions = new ArrayList<String>(); for (ConnectorDefinition def : definitions) { if (defId.equals(def.getId())) { versions.add(def.getVersion()); } } versionCombo.setInput(versions); String version = null; if (implementation != null) { version = implementation.getDefinitionVersion(); } if (version != null && versions.contains(version)) { versionCombo.setSelection(new StructuredSelection(version)); } else { versionCombo.setSelection(new StructuredSelection( versionCombo.getCombo().getItem(versionCombo.getCombo().getItemCount() - 1))); } versionCombo.getCombo().setEnabled(versions.size() > 1); if (versions.size() == 1) { for (ConnectorDefinition def : definitions) { if (defId.equals(def.getId())) { descriptionLabel.setText(messageProvider.getConnectorDefinitionDescription(def)); descriptionGroup.layout(true); break; } } } } else { versionCombo.setInput(Collections.emptyList()); descriptionLabel.setText(""); descriptionGroup.layout(true); } } }); versionCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Object sel = ((IStructuredSelection) explorer.getRightTableViewer().getSelection()) .getFirstElement(); if (sel instanceof ConnectorDefinition) { final String defId = ((ConnectorDefinition) sel).getId(); final String version = (String) ((IStructuredSelection) event.getSelection()).getFirstElement(); if (defId != null && version != null) { for (ConnectorDefinition def : definitions) { if (defId.equals(def.getId()) && version.equals(def.getVersion())) { descriptionLabel.setText(messageProvider.getConnectorDefinitionDescription(def)); descriptionGroup.layout(true); break; } } } } else { descriptionLabel.setText(""); descriptionGroup.layout(true); } } }); defIdStrategy = new UpdateValueStrategy(); defIdStrategy.setConverter(new Converter(ConnectorDefinition.class, String.class) { @Override public Object convert(Object from) { if (from instanceof ConnectorDefinition) { return ((ConnectorDefinition) from).getId(); } return null; } }); defIdStrategy.setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object value) { // if(value == null || value.toString().isEmpty()){ // return ValidationStatus.error(Messages.missingDefinition) ; // } return Status.OK_STATUS; } }); defModelStrategy = new UpdateValueStrategy(); defModelStrategy.setConverter(new Converter(String.class, ConnectorDefinition.class) { @Override public Object convert(Object from) { if (from instanceof String) { return getConnectorDefinitionFromId((String) from); } return null; } }); updateOnlyCustomCheckbox(); bindValue(); setControl(mainComposite); }
From source file:org.bonitasoft.studio.data.ui.wizard.DataWizardPage.java
License:Open Source License
protected void createTypeChooser(final Composite parent) { final Label typeLabel = new Label(parent, SWT.NONE); typeLabel.setText(Messages.datatypeLabel); typeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); typeCombo = new ComboViewer(parent, SWT.BORDER | SWT.READ_ONLY); typeCombo.setContentProvider(new ArrayContentProvider()); typeCombo.setLabelProvider(new DataTypeLabelProvider()); typeCombo.addFilter(typeViewerFilter); typeCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(10, 0).create()); typeDescriptionDecorator = new ControlDecoration(typeCombo.getCombo(), SWT.LEFT); typeDescriptionDecorator.setImage(Pics.getImage(PicsConstants.hint)); if (allowEnum) { final Button createOptionButton = new Button(parent, SWT.PUSH); createOptionButton.setText(Messages.listOfOptions); createOptionButton.addSelectionListener(new SelectionAdapter() { @Override//from ww w . java 2s. co m public void widgetSelected(final SelectionEvent e) { final EnumDataTypeDialog dialog = new EnumDataTypeDialog(Display.getDefault().getActiveShell(), ModelHelper.getMainProcess(container)); if (dialog.open() == Window.OK) { final EnumType type = dialog.getSelectedEnum(); updateDatabinding(); typeCombo.setSelection(new StructuredSelection(type)); } } }); } else { typeCombo.getCombo().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).span(2, 1).indent(10, 0).create()); } }
From source file:org.bonitasoft.studio.decision.ui.DecisionTableWizardPage.java
License:Open Source License
/** * @param gridPlaceholder // w w w .ja v a 2 s.c om * @param gridPlaceHolder * @return */ public Composite createGrid(final Composite gridPlaceholder) { gridPlaceholder.setBackgroundMode(SWT.INHERIT_FORCE); int nbColumns = 7; // Edit, delete, up, down, space (on the left) + arrow & Action (on the right); int nbMaxConditions = 0; for (DecisionTableLine line : decisionTable.getLines()) { nbMaxConditions = Math.max(line.getConditions().size(), nbMaxConditions); } if (nbMaxConditions > 0) { nbColumns += 2 * nbMaxConditions - 1; } final GridLayout layout = new GridLayout(nbColumns, false); gridPlaceholder.setLayout(layout); gridPlaceholder.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false)); { Composite filler = new Composite(gridPlaceholder, SWT.NONE); GridData fillerLayoutData = new GridData(0, 0); fillerLayoutData.horizontalSpan = 5; filler.setLayoutData(fillerLayoutData); // TITLE if (nbMaxConditions > 0) { Label conditionsLabel = new Label(gridPlaceholder, SWT.NONE); conditionsLabel.setText(Messages.conditions); conditionsLabel .setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, conditionsLabel)); conditionsLabel.setLayoutData( new GridData(SWT.CENTER, SWT.NONE, false, false, 2 * nbMaxConditions - 1, 1)); } new Composite(gridPlaceholder, SWT.NONE).setLayoutData(new GridData(0, 0)); Label decisionLabel = new Label(gridPlaceholder, SWT.NONE); decisionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.FILL) .grab(false, false).span(1, 1).create()); decisionLabel.setText(Messages.decision); decisionLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, decisionLabel)); } final GridData iconButtonLayoutData = new GridData(SWT.RIGHT, SWT.CENTER, false, false); iconButtonLayoutData.heightHint = DELETE_SIZE; iconButtonLayoutData.widthHint = DELETE_SIZE; final GridData oneCellFillerLayoutData = new GridData(0, 0); final GridData andLayoutData = new GridData(SWT.FILL, SWT.CENTER, false, false); for (int i = 0; i < decisionTable.getLines().size(); i++) { final int index = i; final DecisionTableLine line = decisionTable.getLines().get(i); if (line != toEditLine) { Composite editLineComposite = createImageButton(gridPlaceholder, Pics.getImage(PicsConstants.edit)); editLineComposite.setBackground( zebraGridPaintListener.getColorForControl(gridPlaceholder, editLineComposite)); editLineComposite.setLayoutData(iconButtonLayoutData); editLineComposite.setToolTipText(Messages.editRow); editLineComposite.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { toEditLine = line; lineWorkingCopy = EcoreUtil.copy(toEditLine); updateLineButton.setEnabled(true); zebraGridPaintListener.setSelectedRow(index); refresh(true, true); } }); } else { new Composite(gridPlaceholder, SWT.NONE).setLayoutData(new GridData(0, 0)); } Composite deleteLineComposite = createImageButton(gridPlaceholder, Pics.getImage(PicsConstants.remove)); deleteLineComposite .setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, deleteLineComposite)); deleteLineComposite.setLayoutData(iconButtonLayoutData); deleteLineComposite.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (MessageDialog.openConfirm(gridPlaceholder.getShell(), Messages.deleteLineTitle, Messages.deleteLineMessage)) { deleteLine(line); } } }); if (index != 0) { Composite lineUpComposite = createImageButton(gridPlaceholder, Pics.getImage(PicsConstants.arrowUp)); lineUpComposite .setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, lineUpComposite)); lineUpComposite.setLayoutData(iconButtonLayoutData); lineUpComposite.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { decisionTable.getLines().remove(index); decisionTable.getLines().add(index - 1, line); zebraGridPaintListener.setSelectedRow(decisionTable.getLines().indexOf(line)); refreshGrid(); } }); } else { new Composite(gridPlaceholder, SWT.NONE).setLayoutData(oneCellFillerLayoutData); } if (i != decisionTable.getLines().size() - 1) { Composite lineDownComposite = createImageButton(gridPlaceholder, Pics.getImage(PicsConstants.arrowDown)); lineDownComposite.setBackground( zebraGridPaintListener.getColorForControl(gridPlaceholder, lineDownComposite)); lineDownComposite.setLayoutData(iconButtonLayoutData); lineDownComposite.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { decisionTable.getLines().remove(index); decisionTable.getLines().add(index + 1, line); zebraGridPaintListener.setSelectedRow(decisionTable.getLines().indexOf(line)); refreshGrid(); } }); } else { new Composite(gridPlaceholder, SWT.NONE).setLayoutData(oneCellFillerLayoutData); } if (!line.getConditions().isEmpty()) { new Composite(gridPlaceholder, SWT.NONE).setLayoutData(new GridData(0, 20)); } Label andLabel = null; for (Expression cond : line.getConditions()) { Label condLabel = new Label(gridPlaceholder, SWT.NONE); condLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, condLabel)); String stringCondition = cond.getContent(); if (stringCondition.length() > 15) { condLabel.setToolTipText(stringCondition); stringCondition = stringCondition.substring(0, 12) + "..."; } condLabel.setText(stringCondition); andLabel = new Label(gridPlaceholder, SWT.NONE); andLabel.setText(Messages.and); andLabel.setForeground(GRAY); andLabel.setLayoutData(andLayoutData); andLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, andLabel)); } if (andLabel != null) { andLabel.dispose(); } if (line.getConditions().size() < nbMaxConditions) { Composite filler = new Composite(gridPlaceholder, SWT.NONE); int nbColumnsToFill = 0; if (line.getConditions().isEmpty()) { nbColumnsToFill = 2 * (nbMaxConditions - line.getConditions().size()) - 1; } else { nbColumnsToFill = 2 * (nbMaxConditions - line.getConditions().size()); } GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, nbColumnsToFill, 1); gd.widthHint = gd.heightHint = 0; filler.setLayoutData(gd); } if (line.getConditions().isEmpty()) { Label condLabel = new Label(gridPlaceholder, SWT.NONE); condLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, condLabel)); condLabel.setText(Messages.noConditionDefined); condLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); } Composite arrow = createImageButton(gridPlaceHolder, Pics.getImage(PicsConstants.arrowRight)); arrow.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, arrow)); final GridData arrowlayoutData = new GridData(16, 16); arrowlayoutData.horizontalAlignment = SWT.RIGHT; arrowlayoutData.grabExcessHorizontalSpace = true; arrow.setLayoutData(arrowlayoutData); final ComboViewer lineValueCombo = new ComboViewer(gridPlaceholder, SWT.READ_ONLY); lineValueCombo.setContentProvider(new ArrayContentProvider()); if (wizard.getActionsComparer() != null) { lineValueCombo.setComparer(wizard.getActionsComparer()); } lineValueCombo.setLabelProvider(wizard.getActionLabelProvider()); lineValueCombo.setInput(wizard.getPossibleLineActions()); lineValueCombo.setSelection(new StructuredSelection(line.getAction())); lineValueCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent arg0) { final DecisionTableAction action = EcoreUtil .copy((DecisionTableAction) ((IStructuredSelection) lineValueCombo.getSelection()) .getFirstElement()); line.setAction(action); } }); lineValueCombo.getControl().setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); } { // ADD LINE Link addRowLink = new Link(gridPlaceholder, SWT.TRANSPARENT); addRowLink.setText("<A>" + Messages.addRow + "</A>"); addRowLink.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, addRowLink)); addRowLink.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 5, 1)); // Edit, up, down, delete addRowLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DecisionTableLine newRow = DecisionFactory.eINSTANCE.createDecisionTableLine(); newRow.setAction(EcoreUtil.copy(wizard.getPossibleLineActions()[0])); decisionTable.getLines().add(newRow); toEditLine = newRow; lineWorkingCopy = EcoreUtil.copy(newRow); updateLineButton.setEnabled(true); zebraGridPaintListener.setSelectedRow(decisionTable.getLines().indexOf(newRow)); refresh(true, true); } }); Composite filler = new Composite(gridPlaceholder, SWT.NONE); final GridData layoutData = new GridData(SWT.FILL, SWT.NONE, false, false, 2 * nbMaxConditions + 1, 1); layoutData.heightHint = layoutData.heightHint = 0; filler.setLayoutData(layoutData); } { // DEFAULT Label defaultLabel = new Label(gridPlaceholder, SWT.NONE); defaultLabel.setText(Messages.defaultLine); defaultLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, defaultLabel)); defaultLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 5, 1)); // Edit, up, down, delete if (nbMaxConditions > 0) { Composite filler = new Composite(gridPlaceholder, SWT.NONE); final GridData layoutData = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2 * nbMaxConditions - 1, 1); layoutData.heightHint = layoutData.widthHint = 0; filler.setLayoutData(layoutData); } Composite arrow = createImageButton(gridPlaceHolder, Pics.getImage(PicsConstants.arrowRight)); arrow.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, arrow)); final GridData arrowlayoutData = new GridData(16, 16); arrowlayoutData.horizontalAlignment = SWT.END; arrowlayoutData.grabExcessHorizontalSpace = true; arrow.setLayoutData(arrowlayoutData); final ComboViewer defaultValueCombo = new ComboViewer(gridPlaceholder, SWT.READ_ONLY); defaultValueCombo.setContentProvider(new ArrayContentProvider()); if (wizard.getActionsComparer() != null) { defaultValueCombo.setComparer(wizard.getActionsComparer()); } defaultValueCombo.setLabelProvider(wizard.getActionLabelProvider()); defaultValueCombo.setInput(wizard.getPossibleDefaultTableActions()); if (decisionTable.getDefaultAction() != null) { defaultValueCombo.setSelection(new StructuredSelection(decisionTable.getDefaultAction())); } defaultValueCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent arg0) { final DecisionTableAction action = EcoreUtil.copy( (DecisionTableAction) ((IStructuredSelection) arg0.getSelection()).getFirstElement()); decisionTable.setDefaultAction(action); } }); defaultValueCombo.getControl().setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); } return gridPlaceholder; }
From source file:org.bonitasoft.studio.document.ui.control.FileContractInputSelectionComposite.java
License:Open Source License
public FileContractInputSelectionComposite(final Composite parent) { super(parent, SWT.NONE); setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).create()); setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final Label contractLabel = new Label(this, SWT.NONE); contractLabel.setLayoutData(GridDataFactory.swtDefaults().create()); contractLabel.setText(Messages.fileContractInput); contractInputComboViewer = new ComboViewer(this, SWT.BORDER | SWT.READ_ONLY); contractInputComboViewer.getControl().setLayoutData(GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER).grab(true, false).indent(10, 0).create()); contractInputComboViewer.setContentProvider(ArrayContentProvider.getInstance()); contractInputComboViewer.setLabelProvider(new ContractInputLabelProvider()); }
From source file:org.bonitasoft.studio.expression.editor.constant.ConstantExpressionEditor.java
License:Open Source License
@Override public Control createExpressionEditor(Composite parent, boolean isPassword) { Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(new GridLayout(2, false)); Label valueLabel = new Label(mainComposite, SWT.NONE); valueLabel.setText(Messages.value);/*ww w . j av a 2 s . c o m*/ if (isPassword) { valueText = new Text(mainComposite, SWT.BORDER | SWT.PASSWORD); } else { valueText = new Text(mainComposite, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); } valueText.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 80).create()); Label typeLabel = new Label(mainComposite, SWT.NONE); typeLabel.setText(Messages.returnType); typeCombo = new ComboViewer(mainComposite, SWT.BORDER | SWT.READ_ONLY); typeCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); typeCombo.setContentProvider(new IStructuredContentProvider() { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } @Override public void dispose() { } @Override public Object[] getElements(Object inputElement) { return new String[] { String.class.getName(), Boolean.class.getName(), Long.class.getName(), Float.class.getName(), Double.class.getName(), Integer.class.getName() }; } }); typeCombo.setLabelProvider(new ConstantTypeLabelProvider()); typeCombo.setInput(new Object()); return mainComposite; }