Java Code Examples for org.eclipse.swt.events.SelectionListener#widgetSelected()

The following examples show how to use org.eclipse.swt.events.SelectionListener#widgetSelected() . These examples are extracted from open source projects. 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
/**
 * Verify the entry and store the value in the field storedValue
 *
 * @param entry entry to check
 * @param keyCode code of the typed key
 * @return <code>true</code> if the entry if correct, <code>false</code>
 *         otherwise
 */
private boolean verifyEntryAndStoreValue(final String entry, final int keyCode) {
	final String work;
	if (keyCode == SWT.DEL) {
		work = StringUtil.removeCharAt(text.getText(), text.getCaretPosition());
	} else if (keyCode == SWT.BS && text.getCaretPosition() == 0) {
		work = StringUtil.removeCharAt(text.getText(), text.getCaretPosition() - 1);
	} else if (keyCode == 0) {
		work = entry;
	} else {
		work = StringUtil.insertString(text.getText(), entry, text.getCaretPosition());
	}

	try {
		final double d = Double.parseDouble(work.replace(decimalFormatSeparator, '.'));
		storedValue = (int) (d * Math.pow(10, getDigits()));
	} catch (final NumberFormatException nfe) {
		return false;
	}

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

	return true;
}
 
Example 2
/**
 * Fire the selection listeners
 *
 * @param selectionEvent mouse event
 * @return true if the selection could be changed, false otherwise
 */
private boolean fireSelectionListeners(final Event selectionEvent) {
	final Event event = new Event();

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

	final SelectionEvent selEvent = new SelectionEvent(event);

	for (final SelectionListener listener : selectionListeners) {
		listener.widgetSelected(selEvent);
		if (!selEvent.doit) {
			return false;
		}
	}
	return true;
}
 
Example 3
public void select() {
	selected = true;
	parent.setEvent(event);
	for(SelectionListener listener : parent.getSelectionListeners()){
		Event e = new Event() ;
		e.widget = parent ;
		SelectionEvent se = new SelectionEvent(e);
		se.data = event;
		listener.widgetSelected(se);
	}

	setForegroundColor(SELECTED) ;
	setBackgroundColor(SELECTED) ;
	if (getParent() != null) {
		// Unselect others
		for (Object item : getParent().getChildren()) {
			IFigure figure = (IFigure)item;
			if (figure instanceof EventCircle && figure != this) {
				((EventCircle)figure).unselect();
			}
		}
	}
}
 
Example 4
Source Project: nebula   File: SwitchButton.java    License: 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 5
Source Project: nebula   File: DualList.java    License: 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 6
void initializeFields() {

		Iterator<Button> iter= fCheckBoxes.keySet().iterator();
		while (iter.hasNext()) {
			Button b= iter.next();
			String key= fCheckBoxes.get(b);
			b.setSelection(fStore.getBoolean(key));
		}

        // Update slaves
        Iterator<SelectionListener> iter2= fMasterSlaveListeners.iterator();
        while (iter2.hasNext()) {
            SelectionListener listener= iter2.next();
            listener.widgetSelected(null);
        }

	}
 
Example 7
Source Project: nebula   File: ImageContainer.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void fireSelectionEvent() {
	final Event e = new Event();
	e.widget = carousel;
	e.display = getDisplay();
	e.index = carousel.selection;
	e.type = SWT.Selection;

	final SelectionEvent event = new SelectionEvent(e);
	for (final SelectionListener listener : carousel.selectionListeners) {
		listener.widgetSelected(event);
		if (!event.doit) {
			break;
		}
	}
}
 
Example 8
Source Project: nebula   File: NebulaSlider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void fireSelectionEvent() {
	final Event event = new Event();
	event.widget = this;
	event.display = getDisplay();
	event.type = SWT.Selection;
	for (final SelectionListener selectionListener : selectionListeners) {
		selectionListener.widgetSelected(new SelectionEvent(event));
	}
}
 
Example 9
Source Project: nebula   File: CheckBoxGroup.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Fire the selection listeners
 *
 * @param selectionEvent mouse event
 * @return true if the selection could be changed, false otherwise
 */
private boolean fireSelectionListeners(final SelectionEvent selectionEvent) {
	selectionEvent.widget = this;
	for (final SelectionListener listener : selectionListeners) {
		listener.widgetSelected(selectionEvent);
		if (!selectionEvent.doit) {
			return false;
		}
	}
	return true;
}
 
Example 10
Source Project: nebula   File: RoundedToolItem.java    License: 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 11
Source Project: arx   File: ComponentTable.java    License: 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 12
Source Project: nebula   File: RangeSlider.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Fire all selection listeners
 *
 * @param event selection event
 * @return <code>true</code> if no listener cancels the selection,
 *         <code>false</code> otherwise
 */
private boolean fireSelectionListeners(final Event event) {
	for (final SelectionListener selectionListener : listeners) {
		final SelectionEvent selectionEvent = new SelectionEvent(event);
		selectionListener.widgetSelected(selectionEvent);
		if (!selectionEvent.doit) {
			return false;
		}
	}
	return true;
}
 
Example 13
Source Project: nebula   File: BreadcrumbItem.java    License: Eclipse Public License 2.0 5 votes vote down vote up
void fireSelectionEvent() {
	final Event event = new Event();
	event.widget = parentBreadcrumb;
	event.display = getDisplay();
	event.item = this;
	event.type = SWT.Selection;
	for (final SelectionListener selectionListener : selectionListeners) {
		selectionListener.widgetSelected(new SelectionEvent(event));
	}
}
 
Example 14
Source Project: nebula   File: StarRating.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void fireSelectionEvent() {
	final Event event = new Event();
	event.widget = this;
	event.display = getDisplay();
	event.item = this;
	event.type = SWT.Selection;
	for (final SelectionListener selectionListener : selectionListeners) {
		selectionListener.widgetSelected(new SelectionEvent(event));
	}
}
 
Example 15
Source Project: SWET   File: BreadcrumbItem.java    License: MIT License 5 votes vote down vote up
void fireSelectionEvent() {
	final Event event = new Event();
	event.widget = this.parentBreadcrumb;
	event.display = getDisplay();
	event.item = this;
	event.type = SWT.Selection;
	for (final SelectionListener selectionListener : this.selectionListeners) {
		selectionListener.widgetSelected(new SelectionEvent(event));
	}
}
 
Example 16
Source Project: texlipse   File: BuilderChooser.java    License: 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 Project: gef   File: TagCloud.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void fireSelectionChanged() {
	Event e = new Event();
	e.widget = this;
	final SelectionEvent event = new SelectionEvent(e);
	event.data = getSelection();
	event.widget = this;
	event.display = Display.getCurrent();
	for (SelectionListener listener : selectionListeners) {
		listener.widgetSelected(event);
	}
}
 
Example 18
protected void fireSelectionEvent(MouseEvent me) {
  Event e = new Event();
  e.widget = this;
  SelectionEvent event = new SelectionEvent(e);
  event.stateMask = me.stateMask;
  event.widget = this;

  for (SelectionListener listener : selectionListeners) {
    listener.widgetSelected(event);
  }
}
 
Example 19
private void notifyCreateAccountSelected(SelectionEvent e) {
  for (SelectionListener selectionListener : createAccountSelectionListeners) {
    selectionListener.widgetSelected(e);
  }
}
 
Example 20
Source Project: nebula   File: NebulaToolbar.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Handles mouse up event.
 * 
 * @param e MouseEvent
 */
private void handleMouseUp(MouseEvent e)
{
	if (!buttonPushed)
	{
		return;
	}

	buttonPushed = false;

	if (selectedItemIndex == -1)
	{
		return;
	}

	if (selectedItemIndex != itemUnderCursor)
	{
		items[selectedItemIndex].setHovered(false);
	}

	items[selectedItemIndex].setSelected(true);

	if (e.x < 0 || e.y < 0 || e.x > getClientArea().width || e.y > getClientArea().height || itemUnderCursor == -1)
	{
		if (selectedItemIndex != itemUnderCursor)
		{
			redraw();
		}

		return;
	}

	items[selectedItemIndex].setPushedDown(false);
	items[itemUnderCursor].setHovered(true);

	redraw();

	int selectedItemIndexFromUp = getItemIndexUnderCursor(e.x, e.y);
	if (selectedItemIndexFromUp != selectedItemIndex)
	{
		return;
	}

	SelectionListener selectionListener = items[selectedItemIndex].getSelectionListener();

	if (selectionListener == null)
	{
		return;
	}

	Event event = new Event();
	event.widget = this;

	selectionListener.widgetSelected(new SelectionEvent(event));

	MouseEvent newEvent = generateFalseMouseEvent();
	if (newEvent != null && getItemIndexUnderCursor(newEvent.x, newEvent.y) != selectedItemIndexFromUp)
	{
		items[selectedItemIndex].setHovered(false);
		redraw();
	}
}