Java Code Examples for org.eclipse.swt.SWT#Dispose

The following examples show how to use org.eclipse.swt.SWT#Dispose . 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
Source Project: birt   File: StyleCombo.java    License: Eclipse Public License 1.0 6 votes vote down vote up
void comboEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.Dispose :
			if ( popup != null && !popup.isDisposed( ) )
			{
				table.removeListener( SWT.Dispose, listener );
				popup.dispose( );
			}
			disposeImages( );
			popup = null;
			label = null;
			table = null;
			arrow = null;
			break;
		case SWT.Move :
			dropDown( false );
			break;
		case SWT.Resize :
			internalLayout( false );
			break;
	}
}
 
Example 2
Source Project: nebula   File: MultiChoice.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void addListeners() {

		final int[] multiChoiceEvent = { SWT.Dispose, SWT.Move, SWT.Resize };
		for (final int element : multiChoiceEvent) {
			addListener(element, this.listener);
		}

		if ((getStyle() & SWT.READ_ONLY) == 0) {
			final Listener validationListener = new Listener() {

				@Override
				public void handleEvent(final Event event) {
					if (!MultiChoice.this.popup.isDisposed() && !MultiChoice.this.popup.isVisible()) {
						validateEntry();
					}
				}
			};
			this.text.addListener(SWT.FocusOut, validationListener);
		}

		final int[] buttonEvents = { SWT.Selection, SWT.FocusIn };
		for (final int buttonEvent : buttonEvents) {
			this.arrow.addListener(buttonEvent, this.listener);
		}
	}
 
Example 3
Source Project: nebula   File: MultiChoice.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Handle a multichoice event
 *
 * @param event event to handle
 */
private void handleMultiChoiceEvents(final Event event) {
	switch (event.type) {
		case SWT.Dispose:
			if (this.popup != null && !this.popup.isDisposed()) {
				this.popup.dispose();
			}
			final Shell shell = getShell();
			shell.removeListener(SWT.Deactivate, this.listener);
			final Display display = getDisplay();
			display.removeFilter(SWT.FocusIn, this.filter);
			this.popup = null;
			this.arrow = null;
			break;
		case SWT.Move:
			changeVisibilityOfPopupWindow(false);
			break;
		case SWT.Resize:
			if (isDropped()) {
				changeVisibilityOfPopupWindow(false);
			}
			break;
	}

}
 
Example 4
Source Project: nebula   File: MultiChoice.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Handle a popup event
 *
 * @param event event to handle
 */
private void handlePopupEvent(final Event event) {
	switch (event.type) {
		case SWT.Close:
			event.doit = false;
			changeVisibilityOfPopupWindow(false);
			break;
		case SWT.Deactivate:
			changeVisibilityOfPopupWindow(false);
			break;
		case SWT.Dispose:
			if (this.checkboxes != null) {
				this.checkboxes.clear();
			}
			this.checkboxes = null;
			break;
	}
}
 
Example 5
Source Project: nebula   File: CalculatorCombo.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Handle a popup event
 *
 * @param event event to handle
 */
private void handlePopupEvent(final Event event) {
	switch (event.type) {
		case SWT.Paint:
			final Rectangle listRect = popup.getBounds();
			final Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
			event.gc.setForeground(black);
			event.gc.drawRectangle(0, 0, listRect.width - 1, listRect.height - 1);
			break;
		case SWT.Close:
			event.doit = false;
			hidePopupWindow(false);
			break;
		case SWT.Deactivate:
			hidePopupWindow(false);
			break;
		case SWT.Dispose:
			if (keyListener != null) {
				label.removeKeyListener(keyListener);
			}
			break;
	}
}
 
Example 6
Source Project: birt   File: CCombo.java    License: Eclipse Public License 1.0 6 votes vote down vote up
void createPopup(String[] items, int selectionIndex) {		
		// create shell and list
		popup = new Shell (getShell(), SWT.NO_TRIM | SWT.ON_TOP);
		int style = getStyle();
		int listStyle = SWT.SINGLE | SWT.V_SCROLL;
		if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
		if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
		if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
		list = new List (popup, listStyle);
		if (font != null) list.setFont(font);
		if (foreground != null) list.setForeground(foreground);
		if (background != null) list.setBackground(background);
		
		int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
		for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
		int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose};
		for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
		
		if (items != null) list.setItems(items);
		if (selectionIndex != -1) list.setSelection(selectionIndex);
}
 
Example 7
Source Project: nebula   File: CalculatorCombo.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void handleMultiChoiceEvent(final Event event) {
	switch (event.type) {
		case SWT.Dispose:
			if (popup != null && !popup.isDisposed()) {
				popup.dispose();
			}
			final Shell shell = getShell();
			shell.removeListener(SWT.Deactivate, listener);
			final Display display = getDisplay();
			display.removeFilter(SWT.FocusIn, filter);
			popup = null;
			arrow = null;
			break;
		case SWT.Move:
			hidePopupWindow(false);
			break;
		case SWT.Resize:
			if (isPopupVisible()) {
				hidePopupWindow(false);
			}
			break;
	}
}
 
Example 8
Source Project: nebula   File: CustomCombo.java    License: Eclipse Public License 2.0 5 votes vote down vote up
void createPopup(String[] items, int selectionIndex) {
	// create shell and list
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
	int style = getStyle();
	int listStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		listStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		listStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		listStyle |= SWT.LEFT_TO_RIGHT;
	list = new List(popup, listStyle);
	if (font != null)
		list.setFont(font);
	if (foreground != null)
		list.setForeground(foreground);
	if (background != null)
		list.setBackground(background);

	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
	for (int i = 0; i < popupEvents.length; i++)
		popup.addListener(popupEvents[i], listener);
	int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < listEvents.length; i++)
		list.addListener(listEvents[i], listener);

	if (items != null)
		list.setItems(items);
	if (selectionIndex != -1)
		list.setSelection(selectionIndex);
}
 
Example 9
Source Project: nebula   File: AbstractCombo.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Manages global combo events.
 * 
 * @param event event
 */
protected void comboEvent(Event event) {
	switch (event.type) {
		case SWT.Dispose: {
			removeListener(SWT.Dispose, listener);
			notifyListeners(SWT.Dispose, event);
			event.type = SWT.None;

			if (popup != null && !popup.isDisposed()) {
				popupContent.removeListener(SWT.Dispose, listener);
				popup.dispose();
			}
			getShell().removeListener(SWT.Deactivate, listener);
			getDisplay().removeFilter(SWT.FocusIn, filter);
			popup = null;
			text = null;
			popupContent = null;
			button = null;
			_shell = null;
			break;
		}
		case SWT.FocusIn: {
			Control focusControl = getDisplay().getFocusControl();
			if (focusControl == button || focusControl == popupContent)
				return;
			if (isDropped()) {
				popupContent.setFocus();
			} else {
				text.setFocus();
			}
			break;
		}
		case SWT.Move:
			dropDown(false);
			break;
	}
}
 
Example 10
Source Project: nebula   File: TableCombo.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * creates the popup shell.
 *
 * @param selectionIndex
 */
void createPopup(final int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null) {
		table.setFont(font);
	}
	if (foreground != null) {
		table.setForeground(foreground);
	}
	if (background != null) {
		table.setBackground(background);
	}

	// Add popup listeners
	final int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (final int popupEvent : popupEvents) {
		popup.addListener(popupEvent, listener);
	}

	// add table listeners
	final int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn,
			SWT.Dispose };
	for (final int tableEvent : tableEvents) {
		table.addListener(tableEvent, listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
Example 11
/**
 * Handle Combo events
 * @param event
 */
private void comboEvent(Event event) {
	switch (event.type) {
	case SWT.Dispose:
		removeListener(SWT.Dispose, listener);
		notifyListeners(SWT.Dispose, event);
		event.type = SWT.None;

		if (popup != null && !popup.isDisposed()) {
			table.removeListener(SWT.Dispose, listener);
			popup.dispose();
		}
		Shell shell = getShell();
		shell.removeListener(SWT.Deactivate, listener);
		Display display = getDisplay();
		display.removeFilter(SWT.FocusIn, focusFilter);
		popup = null;
		text = null;
		table = null;
		arrow = null;
		selectedImage = null;
		break;
	case SWT.FocusIn:
		Control focusControl = getDisplay().getFocusControl();
		if (focusControl == arrow || focusControl == table)
			return;
		if (isDropped()) {
			table.setFocus();
		} else {
			text.setFocus();
		}
		break;
	case SWT.Move:
		dropDown(false);
		break;
	case SWT.Resize:
		internalLayout(false);
		break;
	}
}
 
Example 12
Source Project: Pydev   File: TableCombo.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
    // create shell and table
    popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

    // create table
    table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

    if (font != null)
        table.setFont(font);
    if (foreground != null)
        table.setForeground(foreground);
    if (background != null)
        table.setBackground(background);

    // Add popup listeners
    int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
    for (int i = 0; i < popupEvents.length; i++) {
        popup.addListener(popupEvents[i], listener);
    }

    // add table listeners
    int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn,
            SWT.Dispose };
    for (int i = 0; i < tableEvents.length; i++) {
        table.addListener(tableEvents[i], listener);
    }

    // set the selection
    if (selectionIndex != -1) {
        table.setSelection(selectionIndex);
    }
}
 
Example 13
Source Project: nebula   File: RadioItem.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constructs a new instance of this class given its parent
 * and a style value describing its behavior and appearance,
 * and the index at which to place it in the items maintained
 * by its parent.
 * <p>
 * The style value is either one of the style constants defined in
 * class <code>SWT</code> which is applicable to instances of this
 * class, or must be built by <em>bitwise OR</em>'ing together
 * (that is, using the <code>int</code> "|" operator) two or more
 * of those <code>SWT</code> style constants. The class description
 * lists the style constants that are applicable to the class.
 * Style bits are also inherited from superclasses.
 * </p>
 *
 * @param parent a widget which will be the parent of the new instance (cannot be null)
 * @param style the style of item to construct
 * @param index the zero-relative index at which to store the receiver in its parent
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 *                <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
 *                </ul>
 *
 * @see SWT
 * @see Widget#getStyle
 */
public RadioItem(final RadioGroup parent, int style, int index) {
	super(parent, checkStyle(style), checkIndex(parent, index));
	this.parent = parent;
	button = parent.createButton(getStyle(), index);

	final Listener listener = event -> {
		if (event.type == SWT.Selection) {
			handleSelection(event);
		} else if (event.type == SWT.Dispose) {
			handleDispose(event);
		}
	};
	button.addListener(SWT.Selection, listener);
	addListener(SWT.Dispose, listener);

	parent.addItem(this, index);
}
 
Example 14
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// set style
	int style = getStyle();
	int tableStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		tableStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		tableStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		tableStyle |= SWT.LEFT_TO_RIGHT;

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null)
		table.setFont(font);
	if (foreground != null)
		table.setForeground(foreground);
	if (background != null)
		table.setBackground(background);

	// Add popup listeners
	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (int i = 0; i < popupEvents.length; i++) {
		popup.addListener(popupEvents[i], listener);
	}

	// add table listeners
	int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp,
			SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < tableEvents.length; i++) {
		table.addListener(tableEvents[i], listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
Example 15
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// set style
	int style = getStyle();
	int tableStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		tableStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		tableStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		tableStyle |= SWT.LEFT_TO_RIGHT;

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null)
		table.setFont(font);
	if (foreground != null)
		table.setForeground(foreground);
	if (background != null)
		table.setBackground(background);

	// Add popup listeners
	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (int i = 0; i < popupEvents.length; i++) {
		popup.addListener(popupEvents[i], listener);
	}

	// add table listeners
	int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp,
			SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < tableEvents.length; i++) {
		table.addListener(tableEvents[i], listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
Example 16
Source Project: nebula   File: CTreeCombo.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The CTreeCombo class represents a selectable user interface object
 * that combines a text field and a tree and issues notification
 * when an item is selected from the tree.
 * <p>
 * Note that although this class is a subclass of <code>Composite</code>,
 * it does not make sense to add children to it, or set a layout on it.
 * </p>
 * <dl>
 * <dt><b>Styles:</b>
 * <dd>BORDER, READ_ONLY, FLAT</dd>
 * <dt><b>Events:</b>
 * <dd>DefaultSelection, Modify, Selection, Verify</dd>
 * </dl>
 */
public CTreeCombo(Composite parent, int style) {
	super(parent, style = checkStyle(style));

	int textStyle = SWT.SINGLE;
	if ((style & SWT.READ_ONLY) != 0) {
		textStyle |= SWT.READ_ONLY;
	}
	if ((style & SWT.FLAT) != 0) {
		textStyle |= SWT.FLAT;
	}
	text = new Text(this, textStyle);
	int arrowStyle = SWT.ARROW | SWT.DOWN;
	if ((style & SWT.FLAT) != 0) {
		arrowStyle |= SWT.FLAT;
	}
	arrow = new Button(this, arrowStyle);

	listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			if (popup == event.widget) {
				popupEvent(event);
				return;
			}
			if (text == event.widget) {
				textEvent(event);
				return;
			}
			if (tree == event.widget) {
				treeEvent(event);
				return;
			}
			if (arrow == event.widget) {
				arrowEvent(event);
				return;
			}
			if (CTreeCombo.this == event.widget) {
				comboEvent(event);
				return;
			}
			if (getShell() == event.widget) {
				getDisplay().asyncExec(new Runnable() {
					@Override
					public void run() {
						if (isDisposed()) {
							return;
						}
						handleFocus(SWT.FocusOut);
					}
				});
			}
		}
	};
	filter = (event) -> {
		final Shell shell = ((Control) event.widget).getShell();
		if (shell == CTreeCombo.this.getShell()) {
			handleFocus(SWT.FocusOut);
		}
	};

	final int[] comboEvents = { SWT.Dispose, SWT.FocusIn, SWT.Move, SWT.Resize };
	for (int i = 0; i < comboEvents.length; i++) {
		addListener(comboEvents[i], listener);
	}

	final int[] textEvents = { SWT.DefaultSelection, SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.MouseDoubleClick, SWT.MouseWheel, SWT.Traverse, SWT.FocusIn, SWT.Verify };
	for (int i = 0; i < textEvents.length; i++) {
		text.addListener(textEvents[i], listener);
	}

	final int[] arrowEvents = { SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.FocusIn };
	for (int i = 0; i < arrowEvents.length; i++) {
		arrow.addListener(arrowEvents[i], listener);
	}

	createPopup(null, null);
	initAccessible();
}
 
Example 17
Source Project: nebula   File: CTreeCombo.java    License: Eclipse Public License 2.0 4 votes vote down vote up
void createPopup(Collection<CTreeComboItem> items, CTreeComboItem selectedItem) {
	// create shell and list
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
	final int style = getStyle();
	int listStyle = SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE;
	if ((style & SWT.FLAT) != 0) {
		listStyle |= SWT.FLAT;
	}
	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
		listStyle |= SWT.RIGHT_TO_LEFT;
	}
	if ((style & SWT.LEFT_TO_RIGHT) != 0) {
		listStyle |= SWT.LEFT_TO_RIGHT;
	}
	tree = new Tree(popup, listStyle);
	tree.addTreeListener(hookListener);
	if (font != null) {
		tree.setFont(font);
	}
	if (foreground != null) {
		tree.setForeground(foreground);
	}
	if (background != null) {
		tree.setBackground(background);
	}

	final int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
	for (int i = 0; i < popupEvents.length; i++) {
		popup.addListener(popupEvents[i], listener);
	}
	final int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose, SWT.Collapse, SWT.Expand };
	for (int i = 0; i < listEvents.length; i++) {
		tree.addListener(listEvents[i], listener);
	}

	for (final CTreeComboColumn c : columns) {
		final TreeColumn col = new TreeColumn(tree, SWT.NONE);
		c.setRealTreeColumn(col);
	}

	if (items != null) {
		createTreeItems(items.toArray(new CTreeComboItem[0]));
	}

	if (selectedItem != null) {
		tree.setSelection(selectedItem.getRealTreeItem());
	}
}
 
Example 18
Source Project: nebula   File: MultiChoice.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Create the popup that contains all checkboxes
 */
private void createPopup() {
	this.popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
	this.popup.setLayout(new FillLayout());

	final int[] popupEvents = { SWT.Close, SWT.Deactivate, SWT.Dispose };
	for (final int popupEvent : popupEvents) {
		this.popup.addListener(popupEvent, this.listener);
	}

	if (this.elements == null) {
		return;
	}

	this.scrolledComposite = new ScrolledComposite(this.popup, SWT.BORDER | SWT.V_SCROLL);
	final Composite content = new Composite(this.scrolledComposite, SWT.NONE);
	content.setLayout(new GridLayout(this.numberOfColumns, true));

	this.checkboxes = new ArrayList<>(this.elements.size());
	for (final T o : this.elements) {
		final Button checkBoxButton = new Button(content, SWT.CHECK);

		if (this.font != null) {
			checkBoxButton.setFont(this.font);
		}
		if (this.foreground != null) {
			checkBoxButton.setForeground(this.foreground);
		}
		if (this.background != null) {
			checkBoxButton.setBackground(this.background);
		}
		checkBoxButton.setEnabled(text.getEditable());

		checkBoxButton.setData(o);
		checkBoxButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
		checkBoxButton.setText(this.labelProvider.getText(o));
		checkBoxButton.addListener(SWT.Selection, e -> {
			if (checkBoxButton.getSelection()) {
				MultiChoice.this.selection.add(o);
			} else {
				MultiChoice.this.selection.remove(o);
			}
			MultiChoice.this.lastModified = o;
			setLabel();
		});

		if (this.selectionListener != null) {
			checkBoxButton.addSelectionListener(this.selectionListener);
		}

		checkBoxButton.setSelection(this.selection.contains(o));
		this.checkboxes.add(checkBoxButton);
	}

	this.scrolledComposite.setContent(content);
	this.scrolledComposite.setExpandHorizontal(false);
	this.scrolledComposite.setExpandVertical(true);
	content.pack();
	this.preferredHeightOfPopup = content.getSize().y;
}
 
Example 19
Source Project: birt   File: DataItemCombo.java    License: Eclipse Public License 1.0 4 votes vote down vote up
void comboEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.Dispose :
			removeListener( SWT.Dispose, listener );
			notifyListeners( SWT.Dispose, event );
			event.type = SWT.None;

			if ( popup != null && !popup.isDisposed( ) )
			{
				list.removeListener( SWT.Dispose, listener );
				popup.dispose( );
			}
			Shell shell = getShell( );
			shell.removeListener( SWT.Deactivate, listener );
			Display display = getDisplay( );
			display.removeFilter( SWT.FocusIn, filter );
			popup = null;
			text = null;
			list = null;
			arrow = null;
			_shell = null;
			break;
		case SWT.FocusIn :
			Control focusControl = getDisplay( ).getFocusControl( );
			if ( focusControl == arrow || focusControl == list )
				return;
			if ( isDropped( ) )
			{
				list.setFocus( );
			}
			else
			{
				text.setFocus( );
			}
			break;
		case SWT.Move :
			dropDown( false );
			break;
		case SWT.Resize :
			internalLayout( false );
			break;
	}
}
 
Example 20
Source Project: birt   File: DataItemCombo.java    License: Eclipse Public License 1.0 4 votes vote down vote up
void createPopup( String[] items, int selectionIndex )
{
	// create shell and list
	popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP );
	int style = getStyle( );
	int listStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ( ( style & SWT.FLAT ) != 0 )
		listStyle |= SWT.FLAT;
	if ( ( style & SWT.RIGHT_TO_LEFT ) != 0 )
		listStyle |= SWT.RIGHT_TO_LEFT;
	if ( ( style & SWT.LEFT_TO_RIGHT ) != 0 )
		listStyle |= SWT.LEFT_TO_RIGHT;
	list = new List( popup, listStyle );
	if ( font != null )
		list.setFont( font );
	if ( foreground != null )
		list.setForeground( foreground );
	if ( background != null )
		list.setBackground( background );

	int[] popupEvents = {
			SWT.Close, SWT.Paint, SWT.Deactivate
	};
	for ( int i = 0; i < popupEvents.length; i++ )
		popup.addListener( popupEvents[i], listener );
	int[] listEvents = {
			SWT.MouseUp,
			SWT.Selection,
			SWT.Traverse,
			SWT.KeyDown,
			SWT.KeyUp,
			SWT.FocusIn,
			SWT.Dispose
	};
	for ( int i = 0; i < listEvents.length; i++ )
		list.addListener( listEvents[i], listener );

	if ( items != null )
		list.setItems( items );
	if ( selectionIndex != -1 )
		list.setSelection( selectionIndex );
}