org.eclipse.jface.viewers.ComboViewer Java Examples

The following examples show how to use org.eclipse.jface.viewers.ComboViewer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected ComboViewer createComboViewer(final TabbedPropertySheetWidgetFactory widgetFactory,
        final Composite composite, final ObservableListContentProviderWithProposalListeners contentProvider) {
    final ComboViewer comboViewer = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY);

    comboViewer.setContentProvider(contentProvider);
    final IObservableSet knownElements = contentProvider.getKnownElements();
    final IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements,
            new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME,
                    ProcessPackage.Literals.DATA__DATA_TYPE, ProcessPackage.Literals.DATA__MULTIPLE });
    comboViewer.setLabelProvider(new DataLabelProvider(labelMaps));

    final ToolBar toolBar = new ToolBar(composite, SWT.FLAT);
    widgetFactory.adapt(toolBar);
    final ToolItem toolItem = new ToolItem(toolBar, SWT.FLAT);
    toolItem.setImage(Pics.getImage(PicsConstants.clear));
    toolItem.setToolTipText(Messages.clearSelection);
    toolItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            comboViewer.setSelection(new StructuredSelection());
        }
    });

    return comboViewer;
}
 
Example #2
Source File: ErrorsWarningsPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private void addProblemTypeRow(Composite categoryProblemsPanel, IGdtProblemType problemType) {
  GridData problemLabelLayout = new GridData(SWT.FILL, SWT.CENTER, true, false);

  Label problemLabel = new Label(categoryProblemsPanel, SWT.NONE);
  problemLabel.setLayoutData(problemLabelLayout);
  problemLabel.setText(problemType.getDescription());

  ComboViewer severityCombo = new ComboViewer(categoryProblemsPanel, SWT.READ_ONLY);
  GridData severityComboLayout = new GridData(SWT.FILL, SWT.CENTER, false, false);
  severityCombo.getCombo().setLayoutData(severityComboLayout);
  severityCombo.setContentProvider(new ArrayContentProvider());
  severityCombo.setLabelProvider(severityLabelProvider);
  severityCombo.setSorter(severityViewerSorter);
  severityCombo.setInput(GdtProblemSeverity.values());

  // Save the association between the problem type and this combo
  problemSeverityCombos.put(problemType, severityCombo);
}
 
Example #3
Source File: MapChoiceControl.java    From depan with Apache License 2.0 6 votes vote down vote up
public MapChoiceControl(Composite parent) {
  super(parent, SWT.NONE);
  setLayout(new FillLayout());

  viewer = new ComboViewer(this, SWT.READ_ONLY | SWT.FLAT);
  viewer.setContentProvider(new ControlContentProvider());
  viewer.setLabelProvider(CONTROL_LABEL_PROVIDER);
  viewer.setComparator(new AlphabeticSorter(new ViewerObjectToString() {

      @Override
      public String getString(Object object) {
        return CONTROL_LABEL_PROVIDER.getText(object);
      }
    }));

  listener = new ControlSelectionChangedListener();
  viewer.addSelectionChangedListener(listener);
}
 
Example #4
Source File: ComposeModeControl.java    From depan with Apache License 2.0 6 votes vote down vote up
public ComposeModeControl(Composite parent) {
  super(parent, SWT.NONE);
  setLayout(new FillLayout());

  viewer = new ComboViewer(this, SWT.READ_ONLY | SWT.FLAT);
  viewer.setContentProvider(new ArrayContentProvider());
  viewer.setLabelProvider(CONTROL_LABEL_PROVIDER);
  viewer.setComparator(new AlphabeticSorter(new ViewerObjectToString() {

      @Override
      public String getString(Object object) {
        return CONTROL_LABEL_PROVIDER.getText(object);
      }
    }));

  viewer.setInput(ComposeMode.values());

  listener = new ControlSelectionChangedListener();
  viewer.addSelectionChangedListener(listener);
}
 
Example #5
Source File: ContextValueControl.java    From depan with Apache License 2.0 6 votes vote down vote up
public ContextValueControl(Composite parent) {
  super(parent, SWT.NONE);
  setLayout(new FillLayout());

  viewer = new ComboViewer(this, SWT.READ_ONLY | SWT.FLAT);
  viewer.setContentProvider(new ArrayContentProvider());
  viewer.setLabelProvider(CONTROL_LABEL_PROVIDER);
  viewer.setComparator(new AlphabeticSorter(new ViewerObjectToString() {

      @Override
      public String getString(Object object) {
        return CONTROL_LABEL_PROVIDER.getText(object);
      }
    }));

  viewer.setInput(ContextKey.Base.values());

  listener = new ControlSelectionChangedListener();
  viewer.addSelectionChangedListener(listener);
}
 
Example #6
Source File: StatechartPropertySection.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void createDomainCombo(Composite leftColumn) {

		Label label = getToolkit().createLabel(leftColumn, "Statechart domain");
		GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(label);
		domainCombo = new ComboViewer(leftColumn);
		GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
		Label spacer = getToolkit().createLabel(leftColumn, "");
		GridDataFactory.fillDefaults().applyTo(spacer);
		domainCombo.setContentProvider(new ArrayContentProvider());
		domainCombo.setLabelProvider(new LabelProvider() {
			@Override
			public String getText(Object element) {
				return ((IDomain) element).getName();
			}
		});

		List<IDomain> domains = DomainRegistry.getDomains();
		for (IDomain domainDescriptor : domains) {
			domainCombo.add(domainDescriptor);
		}

		if (domains.size() <= 1) {
			domainCombo.getControl().setEnabled(false);
		}

	}
 
Example #7
Source File: AbstractActorsPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createActorComboViewer(final Composite mainComposite) {
    actorComboViewer = new ComboViewer(mainComposite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY) ;
    actorComboViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()) ;
    actorComboViewer.setContentProvider(new ArrayContentProvider()) ;
    actorComboViewer.setLabelProvider(new LabelProvider(){
        @Override
        public String getText(final Object element) {
            if(element instanceof Actor){
                String doc = ((Actor) element).getDocumentation() ;
                if(doc != null && !doc.isEmpty()){
                    doc = " -- "+ doc ;
                }else{
                    doc = "" ;
                }
                return ((Actor) element).getName() + doc ;
            }
            return super.getText(element);
        }
    });
}
 
Example #8
Source File: JDBCSelectionPageHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find specified driver name in driverChooserViewer ComboViewer
 * 
 * @param driverChooserViewer
 * @param driverName
 * @return
 */
private JDBCDriverInformation findJdbcDriverInfo(
		ComboViewer driverChooserViewer, String driverName )
{
	JDBCDriverInformation info = null;

	ArrayList infoList = (ArrayList) driverChooserViewer.getInput( );
	// The retrieved name is of the format DriverName (version)
	if ( infoList != null )
	{
		for ( int i = 0; i < infoList.size( ); i++ )
		{
			JDBCDriverInformation jdbcDriverInfo = (JDBCDriverInformation) infoList.get( i );
			if ( jdbcDriverInfo.getDriverClassName( ).equals( driverName ) )
			{
				info = jdbcDriverInfo;
				break;
			}
		}
	}

	return info;
}
 
Example #9
Source File: ExcelFileSelectionWizardPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create the top composite of the page
 * 
 * @param composite
 * @param label
 */
private void createTopComposite( Composite composite, Label label )
{
	FormData data = new FormData( );
	data.left = new FormAttachment( label, 5 );
	data.right = new FormAttachment( 40, -5 );
	worksheetsCombo = new ComboViewer( composite, SWT.BORDER
			| SWT.READ_ONLY );
	worksheetsCombo.getControl( ).setLayoutData( data );
	worksheetsCombo.setContentProvider( new ArrayContentProvider( ) );
	worksheetsCombo.addSelectionChangedListener( this );
	worksheetsCombo.setLabelProvider( new LabelProvider( ) {

		public String getText( Object element )
		{
			return getFileName( element );
		}
	} );
	data = new FormData( );
	data.left = new FormAttachment( worksheetsCombo.getControl( ), 5 );
	data.top = new FormAttachment( 0, 5 );
}
 
Example #10
Source File: TSLintWizardPage.java    From typescript.java with MIT License 6 votes vote down vote up
private void createEmbeddedTslintField(Composite parent) {
	useEmbeddedTslintRuntimeButton = new Button(parent, SWT.RADIO);
	useEmbeddedTslintRuntimeButton.setText(TypeScriptUIMessages.TSLintWizardPage_useEmbeddedTslintRuntime_label);
	useEmbeddedTslintRuntimeButton.addListener(SWT.Selection, this);
	useEmbeddedTslintRuntimeButton.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			updateTslintRuntimeMode();
		}
	});

	embeddedTslintRuntime = new Combo(parent, SWT.READ_ONLY);
	embeddedTslintRuntime.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	ComboViewer viewer = new ComboViewer(embeddedTslintRuntime);
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new TypeScriptRepositoryLabelProvider(true, false));
	List<ITypeScriptRepository> repositories = Arrays
			.stream(TypeScriptCorePlugin.getTypeScriptRepositoryManager().getRepositories())
			.filter(r -> r.getTslintFile() != null).collect(Collectors.toList());
	viewer.setInput(repositories);
}
 
Example #11
Source File: WizardNewTypeScriptProjectCreationPage.java    From typescript.java with MIT License 6 votes vote down vote up
private void createEmbeddedTypeScriptField(Composite parent, ITypeScriptRepository[] repositories) {
	useEmbeddedTsRuntimeButton = new Button(parent, SWT.RADIO);
	useEmbeddedTsRuntimeButton
			.setText(TypeScriptUIMessages.WizardNewTypeScriptProjectCreationPage_useEmbeddedTsRuntime_label);
	useEmbeddedTsRuntimeButton.addListener(SWT.Selection, this);
	useEmbeddedTsRuntimeButton.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			updateTsRuntimeMode();
		}
	});

	embeddedTsRuntime = new Combo(parent, SWT.READ_ONLY);
	embeddedTsRuntime.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	ComboViewer viewer = new ComboViewer(embeddedTsRuntime);
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new TypeScriptRepositoryLabelProvider());

	viewer.setInput(repositories);
}
 
Example #12
Source File: XPathExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createReturnTypeComposite(final Composite parent) {
    final Composite typeComposite = new Composite(parent, SWT.NONE);
    typeComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    final GridLayout gl = new GridLayout(2, false);
    gl.marginWidth = 0;
    gl.marginHeight = 0;
    typeComposite.setLayout(gl);

    final Label typeLabel = new Label(typeComposite, SWT.NONE);
    typeLabel.setText(Messages.returnType);
    typeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).create());

    typeCombo = new ComboViewer(typeComposite, SWT.BORDER | SWT.READ_ONLY);
    typeCombo.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).create());
    typeCombo.setContentProvider(new ArrayContentProvider());
    typeCombo.setInput(XPathReturnType.getAvailableReturnTypes());
    typeCombo.setSelection(new StructuredSelection(XPathReturnType.XPATH_STRING));

}
 
Example #13
Source File: MiniSelector.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private void create(Composite parent) {
  displayExecutor = DisplayExecutor.create(parent.getDisplay());
  comboViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
  comboViewer.setComparator(new ViewerComparator());
  comboViewer.setLabelProvider(new LabelProvider() {
    @Override
    public String getText(Object element) {
      if (element instanceof GcpProject) {
        GcpProject project = (GcpProject) element;
        return project.getName() + " (" + project.getId() + ")";
      }
      return super.getText(element);
    }
  });
  comboViewer.setContentProvider(ArrayContentProvider.getInstance());
  comboViewer.setInput(EMPTY_PROJECTS);
  parent.addDisposeListener(new DisposeListener() {
    @Override
    public void widgetDisposed(DisposeEvent event) {
      cancelFetch();
    }
  });

  fetch();
}
 
Example #14
Source File: AppEngineStandardWizardPage.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
protected void createRuntimeField(Composite composite) {
  Label runtimeLabel = new Label(composite, SWT.LEAD);
  runtimeLabel.setText(Messages.getString("app.engine.standard.project.runtimetype")); //$NON-NLS-1$
  runtimeField = new ComboViewer(composite, SWT.READ_ONLY);
  runtimeField.setLabelProvider(new LabelProvider() {
    @Override
    public String getText(Object element) {
      return ((AppEngineRuntime) element).getLabel();
    }
  });
  runtimeField.setContentProvider(ArrayContentProvider.getInstance());
  runtimeField.setInput(AppEngineRuntime.STANDARD_RUNTIMES);
  runtimeField.setSelection(new StructuredSelection(DEFAULT_RUNTIME), true);
  runtimeField.addPostSelectionChangedListener(event -> revalidate());
}
 
Example #15
Source File: DbImportPage.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createExistingSection(Composite body) {
	Button existingCheck = new Button(body, SWT.RADIO);
	existingCheck.setText("Existing database");
	existingCheck.setSelection(true);
	Controls.onSelect(existingCheck, (e) -> {
		setSelection(config.EXISTING_MODE);
	});
	Composite composite = new Composite(body, SWT.NONE);
	UI.gridLayout(composite, 1);
	UI.gridData(composite, true, false);
	existingViewer = new ComboViewer(composite);
	UI.gridData(existingViewer.getControl(), true, false);
	existingViewer.setLabelProvider(new DbLabel());
	existingViewer.setContentProvider(ArrayContentProvider.getInstance());
	existingViewer.addSelectionChangedListener(e -> selectDatabase());
	fillExistingViewer();
}
 
Example #16
Source File: SelectPipelineTypeWizardPage.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createControl ( final Composite parent )
{
    final Composite wrapper = new Composite ( parent, SWT.NONE );

    wrapper.setLayout ( new GridLayout ( 2, false ) );

    final Label label = new Label ( wrapper, SWT.NONE );
    label.setText ( "Initial content type:" );

    this.viewer = new ComboViewer ( wrapper );
    this.viewer.setContentProvider ( new ArrayContentProvider () );
    this.viewer.setInput ( Type.values () );
    this.viewer.setSelection ( new StructuredSelection ( Type.DEFAULT ) );

    setControl ( wrapper );
}
 
Example #17
Source File: PageSizeComboRenderer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void createUI(Composite parent) {
	GridLayout layout = new GridLayout(2, false);
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	this.setLayout(layout);

	itemsPerPageLabel = new Label(parent, SWT.NONE);
	itemsPerPageLabel.setText(Resources.getText(
			Resources.PaginationRenderer_itemsPerPage, getLocale()));
	itemsPerPageLabel.setLayoutData(new GridData());

	comboViewer = new ComboViewer(parent, SWT.READ_ONLY);
	comboViewer.setContentProvider(ArrayContentProvider.getInstance());
	comboViewer.setLabelProvider(InternalLabelProvider.getInstance());
	comboViewer.getCombo().setLayoutData(
			new GridData(GridData.FILL_HORIZONTAL));
	comboViewer.getCombo().addSelectionListener(this);

}
 
Example #18
Source File: TaskPriorityPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory,
    ExtensibleGridPropertySection extensibleGridPropertySection) {
combo = new ComboViewer(composite);
combo.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
combo.setContentProvider(new ArrayContentProvider());
combo.setLabelProvider(new PriorityLabelProvider());
Object[] input = new Object[TaskPriority.values().length];
for (int i = 0; i < TaskPriority.values().length; i++) {
    input[i] = i;
}
combo.setInput(input);
combo.setSelection(new StructuredSelection(task.getPriority()));

combo.addPostSelectionChangedListener(new ISelectionChangedListener() {
    public void selectionChanged(SelectionChangedEvent event) {
	IStructuredSelection selection = (IStructuredSelection) event.getSelection();
	if (!selection.isEmpty()) {
	    Command setCommand = new SetCommand(editDomain, task, ProcessPackage.Literals.TASK__PRIORITY,
		    selection.getFirstElement());
	    editDomain.getCommandStack().execute(setCommand);
	}
    }
});
   }
 
Example #19
Source File: BusinessObjectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createBusinessObjectTypeControl(final Composite mainComposite,
        final EMFDataBindingContext ctx) {
    final Label businessObjectLabel = new Label(mainComposite, SWT.NONE);
    businessObjectLabel.setLayoutData(fillDefaults().align(SWT.END, SWT.CENTER).create());
    businessObjectLabel.setText(Messages.businessObject + " *");

    final Composite comboComposite = new Composite(mainComposite, SWT.NONE);
    comboComposite.setLayout(GridLayoutFactory.fillDefaults().margins(0, 0).create());
    comboComposite.setLayoutData(fillDefaults().grab(true, false).create());

    final ComboViewer businessObjectComboViewer = new ComboViewer(comboComposite, SWT.READ_ONLY | SWT.BORDER);
    businessObjectComboViewer.getControl().setLayoutData(fillDefaults().grab(true, false).create());
    businessObjectComboViewer.setContentProvider(new ObservableListContentProvider());
    businessObjectComboViewer.setLabelProvider(businessObjectLabelProvider());

    final IObservableList<BusinessObject> businessObjectsObservableList = new WritableList(getAllBusinessObjects(),
            BusinessObject.class);

    final IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(businessObjectComboViewer);
    businessObjectComboViewer.setInput(businessObjectsObservableList);

    classNameObservable = EMFObservables.observeValue(businessObjectData,
            ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME);
    ctx.bindValue(observeSingleSelection,
            classNameObservable,
            updateValueStrategy().withConverter(businessObjectToFQN())
                    .withValidator(mandatoryValidator(Messages.businessObject))
                    .create(),
            updateValueStrategy().withConverter(fqnToBusinessObject())
                    .create());

    defaultValueReturnTypeObservable = EMFObservables.observeValue(businessObjectData.getDefaultValue(),
            ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE);

    final String className = businessObjectData.getClassName();
    if ((className == null || className.isEmpty()) && !businessObjectsObservableList.isEmpty()) {
        observeSingleSelection.setValue(businessObjectsObservableList.get(0));
    }
}
 
Example #20
Source File: ComparisonExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createReturnTypeComposite(final Composite parent) {
    final Composite returnTypeComposite = new Composite(parent, SWT.NONE);
    returnTypeComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    returnTypeComposite
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.BOTTOM).create());

    final 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());
}
 
Example #21
Source File: RelationFieldDetailsControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createRelationKindCombo() {
    ComboViewer relationComboViewer = new ComboViewer(this, SWT.BORDER | SWT.READ_ONLY);
    relationComboViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().hint(400, SWT.DEFAULT).indent(0, -5).create());
    relationComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    relationComboViewer.setLabelProvider(new LabelProviderBuilder<RelationType>()
            .withTextProvider(type -> Objects.equals(type, RelationType.AGGREGATION)
                    ? Messages.aggregation
                    : Messages.composition)
            .createLabelProvider());
    relationComboViewer.setInput(RelationType.values());

    IObservableValue<RelationType> selection = ViewersObservables.observeSingleSelection(relationComboViewer);
    IObservableValue<RelationType> relationTypeObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
            selectedFieldObservable, BusinessDataModelPackage.Literals.RELATION_FIELD__TYPE);

    relationTypeObservable.addValueChangeListener(e -> {
        if (selectedFieldObservable.getValue() != null && e.diff.getOldValue() != null && e.diff.getNewValue() != null) {
            RelationField oldValue = (RelationField) EcoreUtil.copy(selectedFieldObservable.getValue());
            oldValue.setType(e.diff.getOldValue());
            DiffElement diffElement = new DiffElement(Event.UPDATE_ATTRIBUTE_TYPE, oldValue,
                    selectedFieldObservable.getValue());
            diffElement.addProperty(AttributeEditionControl.PARENT_QUALIFIED_NAME,
                    formPage.observeBusinessObjectSelected().getValue().getQualifiedName());
            formPage.refactorAccessControl(diffElement);
        }
    });
    ctx.bindValue(selection, relationTypeObservable);
}
 
Example #22
Source File: QueryExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createBusinessObjectComboViewer(final Composite composite, final IObservableList observeBoList) {
    final Composite boComposite = new Composite(composite, SWT.NONE);
    boComposite.setLayoutData(GridDataFactory.fillDefaults().create());
    boComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 2).create());

    final Label boLabel = new Label(boComposite, SWT.NONE);
    boLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create());
    boLabel.setText(Messages.businessObject);

    final ComboViewer boCombo = new ComboViewer(boComposite, SWT.READ_ONLY | SWT.BORDER);
    boCombo.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, false).minSize(100, SWT.DEFAULT).create());
    boCombo.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof BusinessObjectExpressionQuery) {
                return ((BusinessObjectExpressionQuery) element).getQualifiedName();
            }
            return super.getText(element);
        }
    });
    boCombo.setContentProvider(new ObservableListContentProvider());

    boCombo.setInput(observeBoList);

    observeBOSingleSelection = ViewersObservables.observeSingleSelection(boCombo);
}
 
Example #23
Source File: JointDataSetPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * create right composite for page
 * 
 * @param composite
 */
private void createRightGroup( Composite composite )
{
	rightGroup = new Group( composite, SWT.NONE );
	rightGroup.setLayout( new FormLayout( ) );
	rightGroup.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	FormData data = new FormData( );

	data.top = new FormAttachment( 0, 5 );
	data.left = new FormAttachment( 0, 5 );
	data.right = new FormAttachment( 100, -5 );
	data.bottom = new FormAttachment( 10, -5 );
	rightDataSetChooser = new ComboViewer( rightGroup, SWT.DROP_DOWN
			| SWT.READ_ONLY );
	rightDataSetChooser.getControl( ).setLayoutData( data );
	DataSetComboProvider provider = new DataSetComboProvider( );
	rightDataSetChooser.setContentProvider( provider );
	rightDataSetChooser.setLabelProvider( provider );
	rightDataSetChooser.setInput( dataSetList );
	rightDataSetChooser.addSelectionChangedListener( this );

	data = new FormData( );
	data.top = new FormAttachment( rightDataSetChooser.getControl( ), 10 );
	data.left = new FormAttachment( 0, 5 );
	data.right = new FormAttachment( 100, -5 );
	data.bottom = new FormAttachment( 100, -5 );
	rightColumnList = new ListViewer( rightGroup, SWT.V_SCROLL
			| SWT.H_SCROLL
			| SWT.BORDER );
	rightColumnList.getControl( ).setLayoutData( data );
	ColumnProvider colProvider = new ColumnProvider( );
	rightColumnList.setContentProvider( colProvider );
	rightColumnList.setLabelProvider( colProvider );
	rightColumnList.addSelectionChangedListener( this );
}
 
Example #24
Source File: ConverterUtil.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 对下拉列表和转换器列表进行绑定
 * @param context
 * @param comboViewer
 * @param model
 *            ;
 */
public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) {
	// ViewerSupport.bind(comboViewer, BeansObservables.observeList(
	// model, "supportTypes", String.class),
	// Properties.selfValue(String.class));
	//		
	//
	// context.bindValue(ViewersObservables
	// .observeSingleSelection(comboViewer), BeansObservables
	// .observeValue(model,
	// "selectedType"));

	// ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
	comboViewer.setContentProvider(new ArrayContentProvider());
	comboViewer.setComparator(new ViewerComparator());
	// IObservableMap[] attributeMaps = BeansObservables.observeMaps(
	// viewerContentProvider.getKnownElements(),
	// ConverterBean.class, new String[] { "description" });
	// comboViewer.setLabelProvider(new ObservableMapLabelProvider(
	// attributeMaps));
	// comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));

	comboViewer.setInput(model.getSupportTypes());
	IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer);
	IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null);
	context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE));
}
 
Example #25
Source File: ConverterUtil.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public static void bindValue(DataBindingContext context,ComboViewer comboViewer,
			ConverterViewModel model) {
//		ViewerSupport.bind(comboViewer, BeansObservables.observeList(
//				model, "supportTypes", String.class),
//				Properties.selfValue(String.class));
//		
//
//		context.bindValue(ViewersObservables
//				.observeSingleSelection(comboViewer), BeansObservables
//				.observeValue(model,
//						"selectedType"));
		
//		ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
		comboViewer.setContentProvider(new ArrayContentProvider());
		comboViewer.setComparator(new ViewerComparator());
//		IObservableMap[] attributeMaps = BeansObservables.observeMaps(
//				viewerContentProvider.getKnownElements(),
//				ConverterBean.class, new String[] { "description" });
//		comboViewer.setLabelProvider(new ObservableMapLabelProvider(
//		attributeMaps));
//		comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));
		
		comboViewer.setInput(model.getSupportTypes());
		IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer);
		IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class);
		context.bindValue(observableValue, BeansObservables
				.observeValue(model,
						"selectedType"));
	}
 
Example #26
Source File: ConfigConversionDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件类型列表
 * @param title
 * @param composite
 * @return ;
 */
private ComboViewer createConvertControl(String title, Composite composite) {
	Label positiveConvertLabel = new Label(composite, SWT.NONE);
	GridData positiveConvertLabelData = new GridData();
	positiveConvertLabelData.horizontalSpan = 2;
	positiveConvertLabelData.horizontalAlignment = SWT.CENTER;
	positiveConvertLabelData.grabExcessHorizontalSpace = true;
	positiveConvertLabel.setLayoutData(positiveConvertLabelData);
	positiveConvertLabel.setText(title);

	Label suportFormat = new Label(composite, SWT.NONE);
	suportFormat.setText(Messages.getString("dialog.ConfigConversionDialog.suportFormat"));

	ComboViewer supportList = new ComboViewer(composite, SWT.READ_ONLY);
	GridData gridData = new GridData();
	gridData.horizontalAlignment = SWT.FILL;
	gridData.grabExcessHorizontalSpace = true;
	supportList.getCombo().setLayoutData(gridData);
	supportList.addSelectionChangedListener(new ISelectionChangedListener() {

		public void selectionChanged(SelectionChangedEvent event) {
			ISelection selection = event.getSelection();
			if (selection.isEmpty()) {
				okButton.setEnabled(false);
			} else {
				okButton.setEnabled(true);
			}
		}
	});

	return supportList;
}
 
Example #27
Source File: DataSetBasePage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create the data set type viewer
 * 
 * @param composite
 */
private void createDataSetTypeViewer( Composite composite )
{
	// create the data set type chooser combo
	new Label( composite, SWT.RIGHT ).setText( Messages.getString( "dataset.wizard.label.datasetType" ) );//$NON-NLS-1$
	dataSetTypeChooser = new ComboViewer( composite, SWT.DROP_DOWN
			| SWT.READ_ONLY );
	dataSetTypeChooser.getControl( )
			.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	DataSetTypesProvider dataSetTypes = new DataSetTypesProvider( );
	dataSetTypeChooser.setContentProvider( dataSetTypes );
	dataSetTypeChooser.setLabelProvider( dataSetTypes );
	dataSetTypeChooser.getCombo( ).setEnabled( false );
}
 
Example #28
Source File: DataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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.setSorter(new ViewerSorter());
    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
            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());
    }
}
 
Example #29
Source File: ConfigConversionDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件类型列表
 * @param title
 * @param composite
 * @return ;
 */
private ComboViewer createConvertControl(String title, Composite composite) {
	Label positiveConvertLabel = new Label(composite, SWT.NONE);
	GridData positiveConvertLabelData = new GridData();
	positiveConvertLabelData.horizontalSpan = 2;
	positiveConvertLabelData.horizontalAlignment = SWT.CENTER;
	positiveConvertLabelData.grabExcessHorizontalSpace = true;
	positiveConvertLabel.setLayoutData(positiveConvertLabelData);
	positiveConvertLabel.setText(title);

	Label suportFormat = new Label(composite, SWT.NONE);
	suportFormat.setText("Suport Format");

	ComboViewer supportList = new ComboViewer(composite, SWT.READ_ONLY);
	GridData gridData = new GridData();
	gridData.horizontalAlignment = SWT.FILL;
	gridData.grabExcessHorizontalSpace = true;
	supportList.getCombo().setLayoutData(gridData);
	supportList.addSelectionChangedListener(new ISelectionChangedListener() {

		public void selectionChanged(SelectionChangedEvent event) {
			ISelection selection = event.getSelection();
			if (selection.isEmpty()) {
				okButton.setEnabled(false);
			} else {
				okButton.setEnabled(true);
			}
		}
	});

	return supportList;
}
 
Example #30
Source File: ConverterUtil.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public static void bindValue(DataBindingContext context,ComboViewer comboViewer,
			ConverterViewModel model) {
//		ViewerSupport.bind(comboViewer, BeansObservables.observeList(
//				model, "supportTypes", String.class),
//				Properties.selfValue(String.class));
//		
//
//		context.bindValue(ViewersObservables
//				.observeSingleSelection(comboViewer), BeansObservables
//				.observeValue(model,
//						"selectedType"));
		
//		ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
		comboViewer.setContentProvider(new ArrayContentProvider());
		comboViewer.setComparator(new ViewerComparator());
//		IObservableMap[] attributeMaps = BeansObservables.observeMaps(
//				viewerContentProvider.getKnownElements(),
//				ConverterBean.class, new String[] { "description" });
//		comboViewer.setLabelProvider(new ObservableMapLabelProvider(
//		attributeMaps));
//		comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));
		
		comboViewer.setInput(model.getSupportTypes());
		IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer);
		IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class);
		context.bindValue(observableValue, BeansObservables
				.observeValue(model,
						"selectedType"));
	}