Java Code Examples for org.eclipse.jface.viewers.ComboViewer#addPostSelectionChangedListener()

The following examples show how to use org.eclipse.jface.viewers.ComboViewer#addPostSelectionChangedListener() . 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: 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 2
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 3
Source File: CompilerBlock.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public CompilerBlock(Composite root, int style) {
  super(root, style);

  setLayout(new FillLayout(SWT.HORIZONTAL));

  Composite parent = new Composite(this, SWT.NONE);
  parent.setLayout(new GridLayout(1, false));

  groupDevMode = SWTFactory.createGroup(parent, GROUP_COMPILER_TITLE, 2, 1, GridData.FILL_HORIZONTAL);

  // Log level
  Label label = SWTFactory.createLabel(groupDevMode, "Log level:", 1);
  GridData gd_label = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
  gd_label.widthHint = 101;
  label.setLayoutData(gd_label);
  logLevelComboViewer = new ComboViewer(groupDevMode, SWT.READ_ONLY);
  new Label(groupDevMode, SWT.NONE);
  logLevelComboViewer.setContentProvider(new ArrayContentProvider());
  logLevelComboViewer.setLabelProvider(new DefaultComboLabelProvider());
  logLevelComboViewer.setInput(LogLevelArgumentProcessor.LOG_LEVELS);
  logLevelComboViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
    @Override
    public void selectionChanged(SelectionChangedEvent event) {
      updateLaunchConfigHandler.updateLaunchConfig();
    }
  });
}
 
Example 4
Source File: ChromeExecutableTab.java    From wildwebdeveloper with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite res = new Composite(parent, SWT.NONE);
	res.setLayout(new GridLayout(2, false));

	new Label(res, SWT.NONE).setText(Messages.ChromeAttachTab_runWith);
	browserToUse = new ComboViewer(res, SWT.VERTICAL | SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
	browserToUse.setContentProvider(new ArrayContentProvider());
	browserToUse.setLabelProvider(new BrowserLabelProvider());
	proposals = new LinkedList<>();
	proposals.add(""); //$NON-NLS-1$
	proposals.addAll(BrowserManager.getInstance().getWebBrowsers().stream().filter(ChromeExecutableTab::isChrome).collect(Collectors.toList()));
	browserToUse.setInput(proposals);
	browserToUse.addPostSelectionChangedListener(e -> {
		setDirty(true);
		updateLaunchConfigurationDialog();
	});

	Link link = new Link(res, SWT.NONE);
	link.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
	link.setText(Messages.ChromeAttachTab_browserPreferences);
	link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
		Dialog dialog = PreferencesUtil.createPreferenceDialogOn(link.getShell(), "org.eclipse.ui.browser.preferencePage", null, null); //$NON-NLS-1$
		dialog.open();
		List<IBrowserDescriptor> previous = proposals.stream().filter(IBrowserDescriptor.class::isInstance).map(IBrowserDescriptor.class::cast).collect(Collectors.toList());
		List<IBrowserDescriptor> next = BrowserManager.getInstance().getWebBrowsers();
		List<IBrowserDescriptor> toRemove = new LinkedList<>(previous);
		toRemove.removeAll(next);
		proposals.removeAll(toRemove);
		List<IBrowserDescriptor> toAdd = new LinkedList<>(next);
		toAdd.removeAll(previous);
		toAdd.removeIf(browser -> !isChrome(browser));
		proposals.addAll(toAdd);
		if (!(toAdd.isEmpty() && toRemove.isEmpty())) {
			browserToUse.refresh();
			if (browserToUse.getSelection().isEmpty()) {
				browserToUse.setSelection(new StructuredSelection("")); //$NON-NLS-1$
			}
		}
	}));
	
	setControl(res);
}
 
Example 5
Source File: N4JSNewProjectWizardCreationPage.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void createControl(final Composite parent) {
	super.createControl(parent); // We need to create the UI controls from the parent class.

	final Composite control = (Composite) getControl();
	control.setLayout(GridLayoutFactory.fillDefaults().create());
	control.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).create());

	final DataBindingContext dbc = new DataBindingContext();
	control.addDisposeListener(e -> dbc.dispose());

	createVendorIdControls(dbc, control);

	ComboViewer projectTypeCombo = new ComboViewer(control, READ_ONLY);
	projectTypeCombo.setLabelProvider(new ProjectTypeLabelProvider());
	projectTypeCombo.setContentProvider(ArrayContentProvider.getInstance());
	projectTypeCombo.getControl().setLayoutData(fillDefaults().grab(true, false).create());
	projectTypeCombo.setInput(ProjectType.values());

	Composite projectTypePropertyControls = new Composite(control, NONE);
	StackLayout changingStackLayout = new StackLayout();
	projectTypePropertyControls.setLayout(changingStackLayout);
	projectTypePropertyControls.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).create());

	Composite defaultOptions = initDefaultOptionsUI(dbc, projectTypePropertyControls);
	Composite libraryProjectOptionsGroup = initLibraryOptionsUI(dbc, projectTypePropertyControls);
	Composite testProjectOptionsGroup = initTestProjectUI(dbc, projectTypePropertyControls);

	initProjectTypeBinding(dbc, projectTypeCombo);

	// Configure stack layout to show advanced options
	projectTypeCombo.addPostSelectionChangedListener(e -> {
		switch (projectInfo.getProjectType()) {
		case LIBRARY:
			changingStackLayout.topControl = libraryProjectOptionsGroup;
			break;
		case TEST:
			changingStackLayout.topControl = testProjectOptionsGroup;
			break;
		default:
			changingStackLayout.topControl = defaultOptions;
		}
		projectTypePropertyControls.layout(true);
		setPageComplete(validatePage());
	});

	// IDs from: org.eclipse.jdt.internal.ui.workingsets.IWorkingSetIDs.class
	createWorkingSetGroup(
			(Composite) getControl(),
			null,
			new String[] { "org.eclipse.ui.resourceWorkingSetPage",
					"org.eclipse.jdt.ui.JavaWorkingSetPage",
					"org.eclipse.jdt.internal.ui.OthersWorkingSet"
			}); // $NON-NLS-1$
	Dialog.applyDialogFont(getControl());

	dbc.updateTargets();

	setControl(control);
}