org.eclipse.swt.events.SelectionListener Java Examples

The following examples show how to use org.eclipse.swt.events.SelectionListener. 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: DualList.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Call all selection listeners
 *
 * @param item selected item
 */
private void fireSelectionEvent(final DLItem item) {
	if (selectionListeners == null) {
		return;
	}

	final Event event = new Event();
	event.button = 1;
	event.display = getDisplay();
	event.item = null;
	event.widget = this;
	event.data = item;
	final SelectionEvent selectionEvent = new SelectionEvent(event);

	for (final SelectionListener listener : selectionListeners) {
		listener.widgetSelected(selectionEvent);
	}
}
 
Example #2
Source File: DebugPreferencePage.java    From corrosion with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected Control createContents(Composite parent) {
	parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	Composite container = new Composite(parent, SWT.NONE);
	container.setLayout(new GridLayout(4, false));
	container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));

	gdbInput = new InputComponent(container, Messages.DebugPreferencePage_defaultGDB, e -> isPageValid());
	gdbInput.createComponent();
	gdbInput.createFileSelection();
	gdbInput.setValue(store.getString(CorrosionPreferenceInitializer.DEFAULT_GDB_PREFERENCE));

	Link gdbLink = new Link(container, SWT.NONE);
	gdbLink.setText(Messages.DebugPreferencePage_seeGDBPage);
	gdbLink.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
		IPreferencePageContainer prefContainer = getContainer();
		if (prefContainer instanceof IWorkbenchPreferenceContainer) {
			((IWorkbenchPreferenceContainer) prefContainer).openPage("org.eclipse.cdt.dsf.gdb.ui.preferences", //$NON-NLS-1$
					null);
		}
	}));
	gdbLink.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
	return parent;
}
 
Example #3
Source File: HorizontalSpinner.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Sets the <em>selection</em>, which is the receiver's position, to the
 * argument. If the argument is not within the range specified by minimum
 * and maximum, it will be adjusted to fall within this range.
 *
 * @param value the new selection (must be zero or greater)
 *
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 */
public void setSelection(int selection) {
	checkWidget();
	if (selection < minimum) {
		selection = minimum;
	} else if (selection > maximum) {
		selection = maximum;
	}

	storedValue = selection;
	text.setText(convertSelectionToStringValue());

	for (final SelectionListener s : selectionListeners) {
		s.widgetSelected(null);
	}

}
 
Example #4
Source File: PyConfigureExceptionDialog.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param composite
 *
 *            Create a new text box and a button, which allows user to add
 *            custom exception. Attach a listener to the AddException Button
 */
private void createCustomExceptionUI(Composite composite) {
    addNewExceptionField = new Text(composite, SWT.BORDER);
    addNewExceptionField.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));

    Button buttonAdd = new Button(composite, SWT.PUSH);
    buttonAdd.setLayoutData(new GridData(GridData.END, GridData.END, true, false));
    buttonAdd.setText("Add Exception");

    SelectionListener listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            addCustomException();
        }
    };
    buttonAdd.addSelectionListener(listener);

}
 
Example #5
Source File: GamaToolbar2.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private ToolItem create(final String image, final String text, final String tip, final SelectionListener listener,
		final int style, final boolean forceText, final Control control,
		final int side /* SWT.LEFT or SWT.RIGHT */) {
	final GamaToolbarSimple tb = getToolbar(side);
	final ToolItem button = new ToolItem(tb, style);
	if (text != null && forceText) {
		button.setText(text);
	}
	if (tip != null) {
		button.setToolTipText(tip);
	}
	if (image != null) {
		final Image im = GamaIcons.create(image).image();
		button.setImage(im);
	}
	if (listener != null) {
		button.addSelectionListener(listener);
	}
	if (control != null) {
		button.setControl(control);
	}
	normalizeToolbars();

	return button;
}
 
Example #6
Source File: ListDialogField.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected Button createButton(Composite parent, String label,
		SelectionListener listener) {
	Button button = new Button(parent, SWT.PUSH);
	button.setFont(parent.getFont());
	button.setText(label);
	button.addSelectionListener(listener);
	GridData gd = new GridData();
	gd.horizontalAlignment = GridData.FILL;
	gd.grabExcessHorizontalSpace = true;
	gd.verticalAlignment = GridData.BEGINNING;
	gd.widthHint = SWTUtil.getButtonWidthHint(button);

	button.setLayoutData(gd);

	return button;
}
 
Example #7
Source File: SwitchButton.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Fire the selection listeners
 *
 * @param e mouse event
 * @return true if the selection could be changed, false otherwise
 */
private boolean fireSelectionListeners(final Event e) {
	for (final SelectionListener listener : listOfSelectionListeners) {
		final Event event = new Event();

		event.button = e.button;
		event.display = getDisplay();
		event.item = null;
		event.widget = this;
		event.data = null;
		event.time = e.time;
		event.x = e.x;
		event.y = e.y;

		final SelectionEvent selEvent = new SelectionEvent(event);
		listener.widgetSelected(selEvent);
		if (!selEvent.doit) {
			return false;
		}
	}
	return true;
}
 
Example #8
Source File: SelectableControlList.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public void clear() {
  for (C item : items) {
    for (SelectionListener listener : item.getSelectionListeners()) {
      item.removeSelectionListener(listener);
    }
  }
  for (Control child : scrolledCanvas.getChildren()) {
    child.dispose();
  }
  items.clear();
  doUpdateContentSize();
}
 
Example #9
Source File: AgentsMenu.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private static MenuItem actionAgentMenuItem(final Menu parent, final IAgent agent, final SelectionListener listener,
		final Image image, final String prefix) {
	final MenuItem result = new MenuItem(parent, SWT.PUSH);
	result.setText(prefix /* + " " + agent.getName() */);
	result.addSelectionListener(listener);
	result.setImage(image);
	result.setData("agent", agent);
	return result;
}
 
Example #10
Source File: ComboAndButtonSection.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * if use this method , you couldn't use the onClickButton method.
 */
public void addButtonSelectionListener( SelectionListener listener )
{
	if ( !buttonSelectList.contains( listener ) )
	{
		if ( !buttonSelectList.isEmpty( ) )
			removeButtonSelectionListener( (SelectionListener) buttonSelectList.get( 0 ) );
		buttonSelectList.add( listener );
		if ( button != null )
			button.addSelectionListener( listener );
	}
}
 
Example #11
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static Combo createEditCombo(Composite parent, int span, SelectionListener listener) {
    Combo combo = new Combo(parent, SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = span;
    combo.setLayoutData(gd);
    combo.setVisibleItemCount(10);
    if (listener != null) {
        combo.addSelectionListener(listener);            
    }        
    return combo;
}
 
Example #12
Source File: MenuButton.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void removeSelectionListener( SelectionListener listener )
{
	if ( listeners != null )
	{
		listeners.remove( listener );
		if ( listeners.size( ) == 0 )
			listeners = null;
	}
}
 
Example #13
Source File: CComboPropertyDescriptor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void addComboSelectionListener( SelectionListener listener )
{
	if ( !comboSelectList.contains( listener ) )
	{
		if ( !comboSelectList.isEmpty( ) )
			removeComboSelectionListener( (SelectionListener) comboSelectList.get( 0 ) );
		comboSelectList.add( listener );
		if ( combo != null )
			combo.addSelectionListener( listener );
	}
}
 
Example #14
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static Button createButton(Composite parent, String text, SelectionListener listener, int layout) {
    Button btn = new Button(parent, SWT.NONE);
    GridData gd = new GridData(layout);
    btn.setLayoutData(gd);
    btn.setText(text);
    if (listener != null) {
        btn.addSelectionListener(listener);            
    }
    return btn;
}
 
Example #15
Source File: ComboAndButtonSection.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void addComboSelectionListener( SelectionListener listener )
{
	if ( !comboSelectList.contains( listener ) )
	{
		if ( !comboSelectList.isEmpty( ) )
			removeComboSelectionListener( (SelectionListener) comboSelectList.get( 0 ) );
		comboSelectList.add( listener );
		if ( combo != null )
			combo.addComboSelectionListener( listener );
	}
}
 
Example #16
Source File: BuilderChooser.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Forward the event forward.
 * @param event event
 */
private void fireSelectionEvent(SelectionEvent event) {
    for (int i = 0; i < selectionListeners.size(); i++) {
        SelectionListener lis = (SelectionListener) selectionListeners.get(i);
        lis.widgetSelected(event);
    }
}
 
Example #17
Source File: MenuManager.java    From pmTrans with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MenuItem addMenuItem(Menu menu, String text,
		SelectionListener listener) {
	MenuItem item = new MenuItem(menu, SWT.NONE);
	item.setText(text);
	item.addSelectionListener(listener);
	return item;
}
 
Example #18
Source File: TimeGraphControl.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Default selection callback
 */
public void fireDefaultSelection() {
    if (null != fSelectionListeners) {
        Iterator<SelectionListener> it = fSelectionListeners.iterator();
        while (it.hasNext()) {
            SelectionListener listener = it.next();
            listener.widgetDefaultSelected(null);
        }
    }
}
 
Example #19
Source File: CTree.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * An item may be considered visible, and will be returned with
 * {@link CTree#getVisibleItems()}, even though it will not be
 * painted on the screen. Paint status, on the other hand, refers to whether
 * or not an item will actually be painted when the
 * {@link CTree#paintBody(Event)} method is called.
 * 
 * @return an array of items that will be painted to the screen during paint
 *         events
 * @see #getVisibleItems()
 */
// public CTreeItem[] getPaintedItems() {
// return (CTreeItem[]) paintedItems.toArray(new
// CTreeItem[paintedItems.size()]);
// }
public void addSelectionListener(SelectionListener listener) {
	checkWidget();
	if (listener != null) {
		TypedListener typedListener = new TypedListener(listener);
		addListener(SWT.Selection, typedListener);
		addListener(SWT.DefaultSelection, typedListener);
	}
}
 
Example #20
Source File: OptionsConfigurationBlock.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void addSelectionListener( SelectionListener selectionListener )
{
	IniRadioButtons( );
	if ( radioBtns.size( ) <= 0 )
		return;
	for ( int i = 0; i < radioBtns.size( ); i++ )
	{
		radioBtns.get( i ).addSelectionListener( selectionListener );
	}

}
 
Example #21
Source File: ComponentTable.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Fires a new event.
 */
private void fireSelectionEvent(){
    Event event = new Event();
    event.display = table.getDisplay();
    event.item = table;
    event.widget = table;
    SelectionEvent sEvent = new SelectionEvent(event);
    for (SelectionListener listener : selectionListeners) {
        listener.widgetSelected(sEvent);
    }
}
 
Example #22
Source File: SelectionButtonDialogFieldGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
	Button button= new Button(group, fButtonsStyle | SWT.LEFT);
	button.setFont(group.getFont());
	button.setText(fButtonNames[index]);
	button.setEnabled(isEnabled() && fButtonsEnabled[index]);
	button.setSelection(fButtonsSelected[index]);
	button.addSelectionListener(listener);
	button.setLayoutData(new GridData());
	return button;
}
 
Example #23
Source File: AbstractInterpreterEditor.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Helper method to create a push button.
 *
 * @param parent the parent control
 * @param key the resource name used to supply the button's label text
 * @param listenerToAdd
 * @return Button
 */
/*default*/public static Button createBt(Composite parent, String key, SelectionListener listenerToAdd) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(JFaceResources.getString(key));
    button.setFont(parent.getFont());
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    //        data.heightHint = convertVerticalDLUsToPixels(button, IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixelsStatic(button, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    button.addSelectionListener(listenerToAdd);
    return button;
}
 
Example #24
Source File: RunFirefoxDebugTab.java    From wildwebdeveloper with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	super.createControl(parent);
	reloadOnChange = new Button(resComposite, SWT.CHECK);
	reloadOnChange.setText(Messages.RunFirefoxDebugTab_ReloadOnChange); 
	reloadOnChange.addSelectionListener(SelectionListener.widgetSelectedAdapter((e) -> {
		setDirty(true);
		updateLaunchConfigurationDialog();
	}));
}
 
Example #25
Source File: SWTScaleKnob.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
private SelectionListener createItemSelectionListener(){
	return new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			showHideShell();
		}
	};
}
 
Example #26
Source File: RoundedToolItem.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
void fireSelectionEvent() {
	final Event event = new Event();
	event.widget = parentToolbar;
	event.display = getDisplay();
	event.item = this;
	event.type = SWT.Selection;
	for (final SelectionListener selectionListener : selectionListeners) {
		selectionListener.widgetSelected(new SelectionEvent(event));
	}
}
 
Example #27
Source File: NewDataflowProjectWizardLandingPage.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private SelectionListener templateListener() {
  return new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent event) {
      targetCreator.setTemplate(DataflowProjectArchetype.values()[templateDropdown.getSelectionIndex()]);
      updateAvailableVersions();
    }
  };
}
 
Example #28
Source File: TextVarButton.java    From hop with Apache License 2.0 4 votes vote down vote up
protected void initialize( IVariables variables, Composite composite, int flags, String toolTipText,
                           IGetCaretPosition getCaretPositionInterface, IInsertText insertTextInterface,
                           SelectionListener selectionListener ) {
  this.toolTipText = toolTipText;
  this.getCaretPositionInterface = getCaretPositionInterface;
  this.insertTextInterface = insertTextInterface;
  this.variables = variables;

  PropsUi.getInstance().setLook( this );

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;
  this.setLayout( formLayout );

  Button button = new Button( this, SWT.PUSH );
  PropsUi.getInstance().setLook( button );
  button.setText( "..." );
  FormData fdButton = new FormData();
  fdButton.top = new FormAttachment( 0, 0 );
  fdButton.right = new FormAttachment( 100, 0 );
  fdButton.bottom = new FormAttachment( 100 );
  fdButton.width = 30;
  button.setLayoutData( fdButton );
  if ( selectionListener != null ) {
    button.addSelectionListener( selectionListener );
  }

  // Add the variable $ image on the top right of the control
  //
  Label wlImage = new Label( this, SWT.NONE );
  wlImage.setImage( GuiResource.getInstance().getImageVariable() );
  wlImage.setToolTipText( BaseMessages.getString( PKG, "TextVar.tooltip.InsertVariable" ) );
  FormData fdlImage = new FormData();
  fdlImage.top = new FormAttachment( 0, 0 );
  fdlImage.right = new FormAttachment( button, 0 );
  wlImage.setLayoutData( fdlImage );

  // add a text field on it...
  wText = new Text( this, flags );
  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( 0, 0 );
  fdText.right = new FormAttachment( wlImage, 0 );
  fdText.bottom = new FormAttachment( 100, 0 );
  wText.setLayoutData( fdText );

  modifyListenerTooltipText = getModifyListenerTooltipText( wText );
  wText.addModifyListener( modifyListenerTooltipText );

  controlSpaceKeyAdapter =
    new ControlSpaceKeyAdapter( variables, wText, getCaretPositionInterface, insertTextInterface );
  wText.addKeyListener( controlSpaceKeyAdapter );

}
 
Example #29
Source File: NewProjectNameAndLocationWizardPage.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates the project location specification controls.
 *
 * @param parent the parent composite
 */
private final void createProjectLocationGroup(Composite parent) {
    Font font = parent.getFont();
    // project specification group
    Composite projectGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    projectGroup.setLayout(layout);
    projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    projectGroup.setFont(font);

    // new project label
    Label projectContentsLabel = new Label(projectGroup, SWT.NONE);
    projectContentsLabel.setFont(font);

    projectContentsLabel.setText("Project contents:");

    GridData labelData = new GridData();
    labelData.horizontalSpan = 3;
    projectContentsLabel.setLayoutData(labelData);

    final Button useDefaultsButton = new Button(projectGroup, SWT.CHECK | SWT.RIGHT);
    useDefaultsButton.setText("Use &default");
    useDefaultsButton.setSelection(useDefaults);
    useDefaultsButton.setFont(font);

    GridData buttonData = new GridData();
    buttonData.horizontalSpan = 3;
    useDefaultsButton.setLayoutData(buttonData);

    createUserSpecifiedProjectLocationGroup(projectGroup, !useDefaults);

    SelectionListener listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            useDefaults = useDefaultsButton.getSelection();
            browseButton.setEnabled(!useDefaults);
            locationPathField.setEnabled(!useDefaults);
            locationLabel.setEnabled(!useDefaults);
            if (useDefaults) {
                customLocationFieldValue = locationPathField.getText();
                setLocationForSelection();
            } else {
                locationPathField.setText(customLocationFieldValue);
            }
        }
    };
    useDefaultsButton.addSelectionListener(listener);
}
 
Example #30
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Initializes states of the controls from the preference store.
 */
private void initializeValues() {
	final IPreferenceStore store = getPreferenceStore();
	final Preferences corePreferences =  SVNProviderPlugin.getPlugin().getPluginPreferences();
	
	fileTextFormat.setText(store.getString(ISVNUIConstants.PREF_FILETEXT_DECORATION));
	folderTextFormat.setText(store.getString(ISVNUIConstants.PREF_FOLDERTEXT_DECORATION));
	projectTextFormat.setText(store.getString(ISVNUIConstants.PREF_PROJECTTEXT_DECORATION));
	
	String dateFormatPattern = store.getString(ISVNUIConstants.PREF_DATEFORMAT_DECORATION);
	if (dateFormatPattern != null) {
		dateFormatText.setText(dateFormatPattern);
	}
	
	addedFlag.setText(store.getString(ISVNUIConstants.PREF_ADDED_FLAG));
	dirtyFlag.setText(store.getString(ISVNUIConstants.PREF_DIRTY_FLAG));
       externalFlag.setText(store.getString(ISVNUIConstants.PREF_EXTERNAL_FLAG));
	
	imageShowDirty.setSelection(store.getBoolean(ISVNUIConstants.PREF_SHOW_DIRTY_DECORATION));
	imageShowAdded.setSelection(store.getBoolean(ISVNUIConstants.PREF_SHOW_ADDED_DECORATION));
	imageShowHasRemote.setSelection(store.getBoolean(ISVNUIConstants.PREF_SHOW_HASREMOTE_DECORATION));
	imageShowNewResource.setSelection(store.getBoolean(ISVNUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION));
	imageShowExternal.setSelection(store.getBoolean(ISVNUIConstants.PREF_SHOW_EXTERNAL_DECORATION));
	imageShowReadOnly.setSelection(corePreferences.getBoolean(ISVNCoreConstants.PREF_SHOW_READ_ONLY));

	showDirty.setSelection(store.getBoolean(ISVNUIConstants.PREF_CALCULATE_DIRTY));
	enableFontDecorators.setSelection(store.getBoolean(ISVNUIConstants.PREF_USE_FONT_DECORATORS));
	
	SelectionListener selectionListener = new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			fPreview.refresh();
		}			
	};
	enableFontDecorators.addSelectionListener(selectionListener);
	imageShowDirty.addSelectionListener(selectionListener);
	imageShowAdded.addSelectionListener(selectionListener);
	imageShowHasRemote.addSelectionListener(selectionListener);
	imageShowNewResource.addSelectionListener(selectionListener);
	imageShowExternal.addSelectionListener(selectionListener);
	imageShowReadOnly.addSelectionListener(selectionListener);
	
	setValid(true);
}