List of usage examples for org.eclipse.jface.viewers TableViewer getTable
public Table getTable()
From source file:org.bonitasoft.studio.configuration.ui.wizard.page.ImportConfigurationWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(20, 20).create()); databindingContext = new DataBindingContext(); final TableViewer viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new ActionLabelProvider()); viewer.setInput(getConfigurationImporterContributions()); UpdateValueStrategy startegy = new UpdateValueStrategy(); startegy.setBeforeSetValidator(new IValidator() { @Override/*from w ww. ja v a2 s .c o m*/ public IStatus validate(Object value) { if (value instanceof IAction) { return Status.OK_STATUS; } return ValidationStatus.error(Messages.mustSelectExportError); } }); WizardPageSupport.create(this, databindingContext); databindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), PojoObservables.observeValue(this, "action"), startegy, null); setControl(mainComposite); }
From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java
License:Open Source License
private Control createSelectComposite(final Select 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 itemsLabel = new Label(mainComposite, SWT.NONE); itemsLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); itemsLabel.setText(Messages.items);//from ww w. j a v a2 s . c o m 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 SelectItemEditingSupport(itemViewer, widget)); inputNameColumn.setLabelProvider(new ColumnLabelProvider()); context.bindValue(ViewersObservables.observeInput(itemViewer), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.SELECT__ITEMS)); 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 = generateItem(widget); widget.getItems().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.getItems().indexOf(selected); if (i > 0) { widget.getItems().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.getItems().indexOf(selected); if (i < widget.getItems().size() - 1) { widget.getItems().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.getItems().removeAll(((IStructuredSelection) itemViewer.getSelection()).toList()); itemViewer.refresh(); } }); return mainComposite; }
From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java
License:Open Source License
private Control createArrayComposite(final Array 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 nbColLabel = new Label(mainComposite, SWT.NONE); nbColLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); nbColLabel.setText(Messages.nbColumn); final Combo columnCombo = new Combo(mainComposite, SWT.BORDER | SWT.READ_ONLY); columnCombo.setLayoutData(GridDataFactory.fillDefaults().create()); for (int i = 1; i < 11; i++) { columnCombo.add(String.valueOf(i)); }/*w ww . ja va 2s . c o m*/ if (widget.getCols() == null) { widget.setCols(new BigInteger("1")); } UpdateValueStrategy targetToModel = new UpdateValueStrategy(); targetToModel.setConverter(new Converter(String.class, BigInteger.class) { @Override public Object convert(Object from) { return new BigInteger((String) from); } }); UpdateValueStrategy modelToTarget = new UpdateValueStrategy(); modelToTarget.setConverter(new Converter(BigInteger.class, String.class) { @Override public Object convert(Object from) { return String.valueOf(((BigInteger) from).intValue()); } }); context.bindValue(SWTObservables.observeText(columnCombo), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.ARRAY__COLS), targetToModel, modelToTarget); final Label fixedColLabel = new Label(mainComposite, SWT.NONE); fixedColLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); final Button fixedColButton = new Button(mainComposite, SWT.CHECK); fixedColButton.setLayoutData(GridDataFactory.fillDefaults().create()); fixedColButton.setText(Messages.fixedColumn); context.bindValue(SWTObservables.observeSelection(fixedColButton), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.ARRAY__FIXED_COLS)); final Label colHeadersLabel = new Label(mainComposite, SWT.NONE); colHeadersLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); colHeadersLabel.setText(Messages.columnHeaders); 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 CaptionEditingSupport(itemViewer, widget)); inputNameColumn.setLabelProvider(new ColumnLabelProvider()); context.bindValue(ViewersObservables.observeInput(itemViewer), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.ARRAY__COLS_CAPTION)); 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 = generateCaption(widget); widget.getColsCaption().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.getColsCaption().indexOf(selected); if (i > 0) { widget.getColsCaption().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.getColsCaption().indexOf(selected); if (i < widget.getColsCaption().size() - 1) { widget.getColsCaption().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.getColsCaption().removeAll(((IStructuredSelection) itemViewer.getSelection()).toList()); itemViewer.refresh(); } }); 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);// w ww . j a va2s. c om 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.definition.wizard.DefinitionInformationWizardPage.java
License:Open Source License
protected void createDependenciesViewer(Composite mainComposite) { Label dependencyLabel = new Label(mainComposite, SWT.NONE); dependencyLabel.setText(Messages.dependenciesLabel); dependencyLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); final TableViewer viewer = new TableViewer(mainComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); viewer.setContentProvider(new ArrayContentProvider()); viewer.addSelectionChangedListener(this); viewer.setLabelProvider(new LabelProvider() { @Override//from w w w . j a v a 2 s . co m public Image getImage(Object element) { return Pics.getImage("jar.gif"); } }); context.bindValue(ViewersObservables.observeInput(viewer), EMFObservables.observeValue(definition, ConnectorDefinitionPackage.Literals.CONNECTOR_DEFINITION__JAR_DEPENDENCY)); final Composite buttonComposite = new Composite(mainComposite, 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.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); addButton.setText(Messages.Add); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectJarsDialog dialog = new SelectJarsDialog(Display.getDefault().getActiveShell()); if (dialog.open() == Dialog.OK) { for (IRepositoryFileStore jarFile : dialog.getSelectedJars()) { String jar = jarFile.getName(); if (!definition.getJarDependency().contains(jar)) { definition.getJarDependency().add(jar); } } } } }); removeJarButton = new Button(buttonComposite, SWT.FLAT); removeJarButton.setLayoutData( GridDataFactory.fillDefaults().hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); removeJarButton.setText(Messages.remove); removeJarButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); for (Object selected : selection.toList()) { if (selected instanceof String) { definition.getJarDependency().remove(selected); } } viewer.refresh(); } }); new Label(mainComposite, SWT.NONE); //FILLER final Label dependenciesHintLabel = new Label(mainComposite, SWT.NONE); dependenciesHintLabel.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).create()); dependenciesHintLabel.setText(Messages.dependenciesInfo); }
From source file:org.bonitasoft.studio.connector.model.definition.wizard.InputsWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { context = new EMFDataBindingContext(); final Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 15).create()); final TableViewer inputsViewer = new TableViewer(mainComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); inputsViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); inputsViewer.getTable().setHeaderVisible(true); inputsViewer.getTable().setLinesVisible(true); inputsViewer.addSelectionChangedListener(this); inputsViewer.setContentProvider(new ArrayContentProvider()); TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(25)); layout.addColumnData(new ColumnWeightData(20)); layout.addColumnData(new ColumnWeightData(30)); layout.addColumnData(new ColumnWeightData(25)); inputsViewer.getTable().setLayout(layout); inputsViewer.getColumnViewerEditor() .addEditorActivationListener(new ColumnViewerEditorActivationListener() { @Override/*from w w w . jav a 2s . c om*/ public void beforeEditorDeactivated(ColumnViewerEditorDeactivationEvent event) { } @Override public void beforeEditorActivated(ColumnViewerEditorActivationEvent event) { } @Override public void afterEditorDeactivated(ColumnViewerEditorDeactivationEvent event) { inputsViewer.refresh(); } @Override public void afterEditorActivated(ColumnViewerEditorActivationEvent event) { } }); TableViewerColumn inputNameColumn = new TableViewerColumn(inputsViewer, SWT.FILL); inputNameColumn.getColumn().setText(Messages.name); inputNameColumn.setEditingSupport(new InputNameEditingSupport(inputsViewer, definition, context)); inputNameColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Input) element).getName(); } }); TableViewerColumn mandatoryColumn = new TableViewerColumn(inputsViewer, SWT.FILL); mandatoryColumn.getColumn().setText(Messages.mandatory); mandatoryColumn.setEditingSupport(new InputMandatoryEditingSupport(inputsViewer, context)); mandatoryColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { if (((Input) element).isMandatory()) { return Messages.mandatory; } else { return Messages.optional; } } }); TableViewerColumn inputTypeColumn = new TableViewerColumn(inputsViewer, SWT.FILL); inputTypeColumn.getColumn().setText(Messages.type); inputTypeColumn.setEditingSupport(new InputTypeEditingSupport(inputsViewer, context)); inputTypeColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Input) element).getType(); } }); TableViewerColumn defautltValueColumn = new TableViewerColumn(inputsViewer, SWT.FILL); defautltValueColumn.getColumn().setText(Messages.defaultValue); defautltValueColumn.setEditingSupport(new DefaultValueEditingSupport(inputsViewer, context)); defautltValueColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Input) element).getDefaultValue(); } }); context.bindValue(ViewersObservables.observeInput(inputsViewer), EMFObservables.observeValue(definition, ConnectorDefinitionPackage.Literals.CONNECTOR_DEFINITION__INPUT)); final Composite buttonComposite = new Composite(mainComposite, 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) .hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Input input = ConnectorDefinitionFactory.eINSTANCE.createInput(); input.setName(generateInputName()); input.setType(String.class.getName()); definition.getInput().add(input); inputsViewer.refresh(); inputsViewer.editElement(input, 0); } }); upButton = new Button(buttonComposite, SWT.FLAT); upButton.setText(Messages.up); upButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) .hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); upButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Input selectedInput = (Input) ((IStructuredSelection) inputsViewer.getSelection()) .getFirstElement(); int index = definition.getInput().indexOf(selectedInput); if (index > 0) { definition.getInput().move(index - 1, selectedInput); } inputsViewer.refresh(); } }); downButton = new Button(buttonComposite, SWT.FLAT); downButton.setText(Messages.down); downButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) .hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); downButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Input selectedInput = (Input) ((IStructuredSelection) inputsViewer.getSelection()) .getFirstElement(); int index = definition.getInput().indexOf(selectedInput); if (index < definition.getInput().size() - 1) { definition.getInput().move(index + 1, selectedInput); } } }); removeButton = new Button(buttonComposite, SWT.FLAT); removeButton.setText(Messages.remove); removeButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) .hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { definition.getInput().removeAll(((IStructuredSelection) inputsViewer.getSelection()).toList()); inputsViewer.refresh(); } }); updateButtons(new StructuredSelection()); pageSupport = WizardPageSupport.create(this, context); setControl(mainComposite); }
From source file:org.bonitasoft.studio.connector.model.definition.wizard.OutputsWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { context = new EMFDataBindingContext(); final Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 15).create()); final TableViewer outputsViewer = new TableViewer(mainComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); outputsViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); outputsViewer.getTable().setHeaderVisible(true); outputsViewer.getTable().setLinesVisible(true); outputsViewer.addSelectionChangedListener(this); outputsViewer.setContentProvider(new ArrayContentProvider()); TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(30)); layout.addColumnData(new ColumnWeightData(70)); outputsViewer.getTable().setLayout(layout); outputsViewer.getColumnViewerEditor() .addEditorActivationListener(new ColumnViewerEditorActivationListener() { @Override/*from ww w .j ava2 s .c o m*/ public void beforeEditorDeactivated(ColumnViewerEditorDeactivationEvent event) { } @Override public void beforeEditorActivated(ColumnViewerEditorActivationEvent event) { } @Override public void afterEditorDeactivated(ColumnViewerEditorDeactivationEvent event) { outputsViewer.refresh(); } @Override public void afterEditorActivated(ColumnViewerEditorActivationEvent event) { } }); TableViewerColumn outputNameColumn = new TableViewerColumn(outputsViewer, SWT.FILL); outputNameColumn.getColumn().setText(Messages.name); outputNameColumn.setEditingSupport(new OutputNameEditingSupport(outputsViewer, definition, context)); outputNameColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Output) element).getName(); } }); TableViewerColumn outputTypeColumn = new TableViewerColumn(outputsViewer, SWT.FILL); outputTypeColumn.getColumn().setText(Messages.type); outputTypeColumn.setEditingSupport(new OutputTypeEditingSupport(outputsViewer, context)); outputTypeColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((Output) element).getType(); } }); context.bindValue(ViewersObservables.observeInput(outputsViewer), EMFObservables.observeValue(definition, ConnectorDefinitionPackage.Literals.CONNECTOR_DEFINITION__OUTPUT)); final Composite buttonComposite = new Composite(mainComposite, 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) .hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Output input = ConnectorDefinitionFactory.eINSTANCE.createOutput(); input.setName(generateOutputName()); input.setType(String.class.getName()); definition.getOutput().add(input); outputsViewer.refresh(); outputsViewer.editElement(input, 0); } }); upButton = new Button(buttonComposite, SWT.FLAT); upButton.setText(Messages.up); upButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) .hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); upButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Output selectedInput = (Output) ((IStructuredSelection) outputsViewer.getSelection()) .getFirstElement(); int index = definition.getOutput().indexOf(selectedInput); if (index > 0) { definition.getOutput().move(index - 1, selectedInput); } outputsViewer.refresh(); } }); downButton = new Button(buttonComposite, SWT.FLAT); downButton.setText(Messages.down); downButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) .hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); downButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Output selectedInput = (Output) ((IStructuredSelection) outputsViewer.getSelection()) .getFirstElement(); int index = definition.getOutput().indexOf(selectedInput); if (index < definition.getOutput().size() - 1) { definition.getOutput().move(index + 1, selectedInput); } } }); removeButton = new Button(buttonComposite, SWT.FLAT); removeButton.setText(Messages.remove); removeButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false) .hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { definition.getOutput().removeAll(((IStructuredSelection) outputsViewer.getSelection()).toList()); outputsViewer.refresh(); } }); updateButtons(new StructuredSelection()); pageSupport = WizardPageSupport.create(this, context); setControl(mainComposite); }
From source file:org.bonitasoft.studio.connector.model.implementation.wizard.AbstractImplementationWizardPage.java
License:Open Source License
protected void createDependenciesViewer(Composite mainComposite) { Label dependencyLabel = new Label(mainComposite, SWT.NONE); dependencyLabel.setText(Messages.dependenciesLabel); dependencyLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); final TableViewer viewer = new TableViewer(mainComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); viewer.getTable() .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 75).create()); viewer.setContentProvider(new ArrayContentProvider()); viewer.addSelectionChangedListener(this); viewer.setLabelProvider(new LabelProvider() { @Override/*from www . j a v a2 s. com*/ public Image getImage(Object element) { return Pics.getImage("jar.gif"); } }); context.bindValue(ViewersObservables.observeInput(viewer), EMFObservables.observeValue(implementation.getJarDependencies(), ConnectorImplementationPackage.Literals.JAR_DEPENDENCIES__JAR_DEPENDENCY)); final Composite buttonComposite = new Composite(mainComposite, SWT.NONE); buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create()); buttonComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create()); final Button addButton = new Button(buttonComposite, SWT.FLAT); addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); addButton.setText(Messages.Add); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectJarsDialog dialog = new SelectJarsDialog(Display.getDefault().getActiveShell()); if (dialog.open() == Dialog.OK) { for (IRepositoryFileStore jarFile : dialog.getSelectedJars()) { String jar = jarFile.getName(); if (!implementation.getJarDependencies().getJarDependency().contains(jar)) { implementation.getJarDependencies().getJarDependency().add(jar); } } } } }); removeButton = new Button(buttonComposite, SWT.FLAT); removeButton.setLayoutData( GridDataFactory.fillDefaults().hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); removeButton.setText(Messages.remove); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); for (Object selected : selection.toList()) { if (selected instanceof String) { implementation.getJarDependencies().getJarDependency().remove(selected); } } viewer.refresh(); } }); }
From source file:org.bonitasoft.studio.contract.ui.wizard.SelectBusinessDataWizardPage.java
License:Open Source License
public void createTableViewer(final Composite parent) { final DataBindingContext dbc = new DataBindingContext(); final TableViewer businessDataTableViewer = new TableViewer(parent, SWT.BORDER | SWT.SINGLE | SWT.NO_FOCUS | SWT.H_SCROLL | SWT.V_SCROLL); businessDataTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create()); businessDataTableViewer.getTable()//from w w w . ja v a 2 s . c o m .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create()); final ObservableListContentProvider contentProvider = new ObservableListContentProvider(); businessDataTableViewer.setContentProvider(contentProvider); final IObservableSet knownElements = contentProvider.getKnownElements(); final IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements, new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME, ProcessPackage.Literals.DATA__MULTIPLE, ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME }); businessDataTableViewer .setLabelProvider(new BusinessObjectDataStyledLabelProvider(businessObjectStore, labelMaps)); businessDataTableViewer .setInput(new WritableList(availableBusinessData, ProcessPackage.Literals.BUSINESS_OBJECT_DATA)); final IViewerObservableValue observeSingleSelection = ViewersObservables .observeSingleSelection(businessDataTableViewer); dbc.bindValue(observeSingleSelection, selectedDataObservable); final MultiValidator multiValidator = new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, businessObjectStore); dbc.addValidationStatusProvider(multiValidator); WizardPageSupport.create(this, dbc); }
From source file:org.bonitasoft.studio.validators.ui.wizard.ValidatorWizardPage.java
License:Open Source License
protected void createDependenciesViewer(Composite mainComposite) { Label dependencyLabel = new Label(mainComposite, SWT.NONE); dependencyLabel.setText(Messages.dependencies); dependencyLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); final TableViewer viewer = new TableViewer(mainComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); viewer.setContentProvider(new ArrayContentProvider()); viewer.addSelectionChangedListener(this); viewer.setLabelProvider(new LabelProvider() { @Override/*from w ww .ja v a2s.co m*/ public Image getImage(Object element) { return Pics.getImage("jar.gif", ValidatorPlugin.getDefault()); } }); context.bindValue(ViewersObservables.observeInput(viewer), EMFObservables.observeValue(validator, ValidatorPackage.Literals.VALIDATOR_DESCRIPTOR__DEPENDENCIES)); final Composite buttonComposite = new Composite(mainComposite, SWT.NONE); buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create()); buttonComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create()); final Button addButton = new Button(buttonComposite, SWT.FLAT); addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); addButton.setText(Messages.Add); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectJarsDialog dialog = new SelectJarsDialog(Display.getDefault().getActiveShell()); if (dialog.open() == Dialog.OK) { for (IRepositoryFileStore jarFile : dialog.getSelectedJars()) { String jar = jarFile.getName(); if (!validator.getDependencies().contains(jar)) { validator.getDependencies().add(jar); } } } } }); removeButton = new Button(buttonComposite, SWT.FLAT); removeButton.setLayoutData( GridDataFactory.fillDefaults().hint(DEFAULT_BUTTON_WIDTH_HINT, SWT.DEFAULT).create()); removeButton.setText(Messages.Remove); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); for (Object selected : selection.toList()) { if (selected instanceof String) { validator.getDependencies().remove(selected); } } viewer.refresh(); } }); }