本文整理汇总了Java中org.eclipse.jface.viewers.ComboViewer.setSelection方法的典型用法代码示例。如果您正苦于以下问题:Java ComboViewer.setSelection方法的具体用法?Java ComboViewer.setSelection怎么用?Java ComboViewer.setSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.viewers.ComboViewer
的用法示例。
在下文中一共展示了ComboViewer.setSelection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRuntimeField
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
@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(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
revalidate();
}
});
}
示例2: setConfigComboViewer
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
/**
* @param subtypeCMB_Main_viewer2
* @param string
*/
private void setConfigComboViewer(ComboViewer viewer, String inputString) {
Object input = viewer.getInput();
if (input instanceof BTSConfigItem) {
for (BTSConfig i : ((BTSConfig) input).getChildren()) {
if (i instanceof BTSConfigItem
&& inputString
.equals(((BTSConfigItem) i).getValue())) {
viewer.setSelection(new StructuredSelection(i));
return;
}
}
BTSConfigItem cci = BtsmodelFactory.eINSTANCE
.createBTSConfigItem();
cci.setLabel(BtsmodelFactory.eINSTANCE.createBTSTranslations());
cci.getLabel().setTranslation(inputString, "en");
cci.setValue(inputString);
((BTSConfig) input).getChildren().add(cci);
viewer.setSelection(new StructuredSelection( cci));
return;
}
}
示例3: setClass
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
void setClass(final IType type,
final Button classButton,
final ComboViewer methodComboViewer) {
try {
classButton.setText(type.getFullyQualifiedName());
final List<IMethod> methods = new ArrayList<>(Arrays.asList(type.getMethods()));
for (final Iterator<IMethod> iter = methods.iterator(); iter.hasNext();) {
if (!valid(iter.next())) {
iter.remove();
}
}
methodComboViewer.setInput(methods.toArray());
if (!methods.isEmpty()) {
methodComboViewer.setSelection(new StructuredSelection(methods.get(0)));
}
this.type = type;
getButton(IDialogConstants.OK_ID).setEnabled(true);
} catch (final JavaModelException e) {
Activator.error(e);
}
}
示例4: bindUniverseDefinition
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
private void bindUniverseDefinition(ComboViewer universeDefinitionCombo) {
universeDefinitionCombo.setContentProvider(new ArrayContentProvider());
universeDefinitionCombo.setLabelProvider(new ProjectUniverseLabelProvider());
universeDefinitionCombo.setComparator(new ViewerComparator());
Set<ProjectUniverse> projectUniverses = getProjectUniverses();
universeDefinitionCombo.setInput(projectUniverses);
IObservableValue selectedUniverseDefinition = ViewerProperties.singleSelection().observe(universeDefinitionCombo);
IObservableValue universeDefinition = BeansObservables.observeValue(editVersionModel, EditVersionModel.PN_PROJECT_UNIVERSE);
dbc.bindValue(selectedUniverseDefinition, universeDefinition);
ProjectUniverse projectUniverse = findUniverse(projectUniverses, getUniverseId());
if (projectUniverse == null) {
projectUniverse = findUniverse(projectUniverses, UniverseDefinitions.ALL_WORKSPACE_PROJECTS_UNIVERSE_ID);
}
/* We simply use the first element in the list as the initial selection. */
if (0 < universeDefinitionCombo.getCombo().getItemCount()) {
universeDefinitionCombo.setSelection(new StructuredSelection(projectUniverse));
}
}
示例5: createComponentViewer
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
private void createComponentViewer(Composite composite) {
UI.formLabel(composite, toolkit, M.Component);
componentViewer = new ComboViewer(composite);
UI.gridData(componentViewer.getControl(), false, false).widthHint = 250;
componentViewer.setContentProvider(ArrayContentProvider
.getInstance());
componentViewer.setLabelProvider(new ComponentLabel());
componentViewer.setInput(ReportComponent.values());
componentViewer.addSelectionChangedListener((evt) -> {
ReportComponent c = Viewers.getFirst(evt.getSelection());
if (c == null || c == ReportComponent.NONE)
model.componentId = null;
else
model.componentId = c.getId();
editor.setDirty(true);
});
if (model.componentId != null)
componentViewer.setSelection(new StructuredSelection(
ReportComponent.getForId(model.componentId)));
}
示例6: updateComboSelection
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
private void updateComboSelection(String value, ComboViewer comboViewer)
{
if (comboViewer != null)
{
LabelValuePair[] pairs = (LabelValuePair[]) comboViewer.getInput();
if (pairs != null)
{
for (LabelValuePair pair : pairs)
{
if (pair.getValue().equals(value))
{
comboViewer.setSelection(new StructuredSelection(pair));
}
}
}
}
}
示例7: setupAncestor
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
private void setupAncestor(ComboViewer comboViewer) {
comboViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
List<IFile> files = (List<IFile>) inputElement;
Object[] ret = new Object[files.size()];
int index = 0;
for (IFile file : files) {
ret[index++] = JavaCore.create(file);
}
return ret;
}
});
comboViewer.setLabelProvider(new JavaElementLabelProvider(
JavaElementLabelProvider.SHOW_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT));
comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() > 0) {
ancestor = (ICompilationUnit) selection.getFirstElement();
}
}
});
comboViewer.getCombo().setData(GW4E_CONVERSION_WIDGET_ID, GW4E_CONVERSION_COMBO_ANCESTOR_EXTEND_TEST);
comboViewer.setInput(ancestors);
if (hasItems()) {
comboViewer.setSelection(new StructuredSelection(JavaCore.create(ancestors.get(0))));
}
}
示例8: createGrammarsControls
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
/**
* Creates the grammars controls.
*
* @param composite
* the composite
*/
private void createGrammarsControls(final Composite composite) {
Label generatorConfigLabel = new Label(composite, SWT.NONE);
generatorConfigLabel.setText(Messages.GRAMMAR_FIELD_NAME_LABEL);
Combo generatorConfigurationField = new Combo(composite, SWT.READ_ONLY);
GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
data.widthHint = PAGE_WIDTH_HINT; // prevents shrinking of combo view
generatorConfigurationField.setLayoutData(data);
generatorConfigurationField.setFont(composite.getFont());
ComboViewer grammars = new ComboViewer(generatorConfigurationField);
grammars.setContentProvider(new ArrayContentProvider());
grammars.setLabelProvider(new LabelProvider() {
@Override
public String getText(final Object object) {
if (object instanceof Grammar) {
return new GrammarHelper((Grammar) object).getLabelName();
}
return super.getText(object);
}
});
grammars.setInput(resourceUtil.getGrammars());
// React to the selection of the viewer
// Note that the viewer return the real object and not just a string
// representation
grammars.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
if (event.getSelection() instanceof StructuredSelection) {
grammar = (Grammar) ((StructuredSelection) event.getSelection()).getFirstElement();
grammarStatus = validateGrammarAccess();
handleFieldChanged(GRAMMAR);
}
}
});
grammars.setSelection(null); // no pre-defined grammar to be used, forces the user to make a decision about which language to target
}
示例9: populateSeverityCombosFromWorkingCopy
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
private void populateSeverityCombosFromWorkingCopy() {
for (IGdtProblemType problemType : problemSeverityCombos.keySet()) {
ComboViewer combo = problemSeverityCombos.get(problemType);
GdtProblemSeverity severity = problemSeveritiesWorkingCopy.getSeverity(problemType);
combo.setSelection(new StructuredSelection(severity));
}
}
示例10: setDriverSelection
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
/**
* Set selected driver in driverChooserViewer combo box
*
* @param driverChooserViewer
* @param driverList
*/
private void setDriverSelection( String originalDriverClassName,
ComboViewer driverChooserViewer, List driverList )
{
// there may exist logic error
if ( driverList == null || driverList.size( ) == 0 )
{
return;
}
StructuredSelection selection = null;
JDBCDriverInformation jdbcDriverInfo = findJdbcDriverInfo( driverChooserViewer,
originalDriverClassName );
if ( jdbcDriverInfo != null )
{
selection = new StructuredSelection( jdbcDriverInfo );
}
else if ( originalDriverClassName.trim( ).length( ) == 0 )
{
return;
}
else
{
JDBCDriverInformation driverInfo = JDBCDriverInformation.newInstance( originalDriverClassName );
driverList.add( 0, driverInfo );
driverChooserViewer.setInput( driverList );
selection = new StructuredSelection( driverInfo );
}
driverChooserViewer.setSelection( selection );
}
示例11: selectComboValue
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
public static void selectComboValue(ComboViewer viewer, String key, IPreferenceStore store)
{
String[] input = (String[]) viewer.getInput();
try
{
viewer.setSelection(new StructuredSelection(input[store.getInt(key)]));
}
catch (Exception ex)
{
viewer.setSelection(new StructuredSelection(input[0]));
}
}
示例12: createCombo
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
private static ComboViewer createCombo(final Composite container, List<?> values) {
ComboViewer combo = new ComboViewer(container);
combo.setContentProvider(new ArrayContentProvider());
combo.setLabelProvider(new LabelProvider());
combo.setInput(values);
combo.setSelection(new StructuredSelection(values.get(0)));
GridDataFactory.fillDefaults().grab(true, false).applyTo(combo.getControl());
return combo;
}
示例13: setCurrencyContent
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
private void setCurrencyContent(ComboViewer combo) {
combo.setContentProvider(ArrayContentProvider.getInstance());
CurrencyDao dao = new CurrencyDao(Database.get());
List<Currency> all = dao.getAll();
Collections.sort(all,
(c1, c2) -> Strings.compare(c1.getName(), c2.getName()));
combo.setInput(all);
currency = exchange.currency;
if (currency == null)
currency = dao.getReferenceCurrency();
if (currency != null) {
combo.setSelection(new StructuredSelection(currency));
exchange.currency = currency;
}
}
示例14: createComboButton
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
private ComboViewer createComboButton(String label, Object[] options, Group group, IBaseLabelProvider labelProvider) {
Label effectiveCommandLabel = new Label(group, SWT.NONE);
effectiveCommandLabel.setText(label);
ComboViewer comboViewer = new ComboViewer(group, SWT.READ_ONLY);
comboViewer.setContentProvider(new ArrayContentProvider());
comboViewer.setInput(options);
comboViewer.setLabelProvider(labelProvider);
comboViewer.setSelection(new StructuredSelection(options[0]));
comboViewer.addSelectionChangedListener(updateEffectiveComandListener);
return comboViewer;
}
开发者ID:mulesoft,项目名称:mule-tooling-incubator,代码行数:12,代码来源:MavenRunCommandLineConfigurationComponent.java
示例15: createBody
import org.eclipse.jface.viewers.ComboViewer; //导入方法依赖的package包/类
@Override
protected void createBody(Composite ancestor) {
Composite parent = new Composite(ancestor, SWT.NONE);
parent.setFont(parent.getFont());
parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
parent.setLayout(new GridLayout(4, false));
// TextMate theme
Label label = new Label(parent, SWT.NONE);
label.setText(TMUIMessages.CreateThemeAssociationWizardPage_theme_text);
themeViewer = new ComboViewer(parent);
themeViewer.setLabelProvider(new ThemeLabelProvider());
themeViewer.setContentProvider(new ThemeContentProvider());
themeViewer.setInput(TMUIPlugin.getThemeManager());
themeViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
themeViewer.getControl().addListener(SWT.Selection, this);
label = new Label(parent, SWT.NONE);
label.setText(TMUIMessages.CreateThemeAssociationWizardPage_grammar_text);
grammarViewer = new ComboViewer(parent);
grammarViewer.setLabelProvider(new GrammarDefinitionLabelProvider());
grammarViewer.setContentProvider(new GrammarDefinitionContentProvider());
grammarViewer.setInput(TMEclipseRegistryPlugin.getGrammarRegistryManager());
grammarViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
grammarViewer.getControl().addListener(SWT.Selection, this);
if (initialDefinition != null) {
grammarViewer.setSelection(new StructuredSelection(initialDefinition));
}
whenDarkButton = new Button(parent, SWT.CHECK);
whenDarkButton.setText(TMUIMessages.CreateThemeAssociationWizardPage_whenDark_text);
GridData data = new GridData();
data.horizontalSpan = 4;
whenDarkButton.setLayoutData(data);
if (initialAssociation != null) {
ITheme selectedTheme = TMUIPlugin.getThemeManager().getThemeById(initialAssociation.getThemeId());
if (selectedTheme != null) {
themeViewer.setSelection(new StructuredSelection(selectedTheme));
}
whenDarkButton.setSelection(initialAssociation.isWhenDark());
}
}