Java Code Examples for org.eclipse.swt.SWT#error()

The following examples show how to use org.eclipse.swt.SWT#error() . 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: nebula   File: BlurredPanel.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Show the blurred panel
 */
public void show() {
	if (parent.isDisposed()) {
		SWT.error(SWT.ERROR_WIDGET_DISPOSED);
	}

	panel = new Shell(parent, SWT.APPLICATION_MODAL | SWT.NO_TRIM);
	panel.setLayout(new FillLayout());

	panel.addListener(SWT.KeyUp, event -> {
		event.doit = false;
	});

	canvas = new Canvas(panel, SWT.NO_BACKGROUND | SWT.DOUBLE_BUFFERED);
	canvas.addPaintListener(event -> {
		paintCanvas(event);
	});

	panel.setBounds(panel.getDisplay().map(parent, null, parent.getClientArea()));
	panel.open();

}
 
Example 2
Source Project: nebula   File: BadgedLabel.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void checkColor(Color color) {
	if (color == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}
	if (color.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
}
 
Example 3
/**
 * 添加关闭单元格关闭时的监听器
 * @param closeListener
 *            关闭监听器 ;
 */
public void addClosingListener(Listener closeListener) {
	if (closeListener == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}
	closingListeners.add(closeListener);
}
 
Example 4
Source Project: nebula   File: Gallery.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the index of a GalleryItem when it is not a root Item
 * 
 * @param parentItem
 * @param item
 * @return
 */
protected int _indexOf(GalleryItem parentItem, GalleryItem item) {
	int itemCount = parentItem.getItemCount();
	if (item == null)
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	if (1 <= parentItem.lastIndexOf
			&& parentItem.lastIndexOf < itemCount - 1) {
		if (parentItem.items[parentItem.lastIndexOf] == item)
			return parentItem.lastIndexOf;
		if (parentItem.items[parentItem.lastIndexOf + 1] == item)
			return ++parentItem.lastIndexOf;
		if (parentItem.items[parentItem.lastIndexOf - 1] == item)
			return --parentItem.lastIndexOf;
	}
	if (parentItem.lastIndexOf < itemCount / 2) {
		for (int i = 0; i < itemCount; i++) {
			if (parentItem.items[i] == item)
				return parentItem.lastIndexOf = i;
		}
	} else {
		for (int i = itemCount - 1; i >= 0; --i) {
			if (parentItem.items[i] == item)
				return parentItem.lastIndexOf = i;
		}
	}
	return -1;
}
 
Example 5
/**
 * Adds the listener to the collection of listeners who will be notified when the receiver's text is verified, by
 * sending it one of the messages defined in the <code>VerifyListener</code> interface.
 * @param listener
 *            the listener which should be notified
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
 *                </ul>
 * @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>
 * @see VerifyListener
 * @see #removeVerifyListener
 * @since 3.3
 */
public void addVerifyListener(VerifyListener listener) {
	checkWidget();
	if (listener == null)
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	TypedListener typedListener = new TypedListener(listener);
	addListener(SWT.Verify, typedListener);
}
 
Example 6
/**
 * Adds the listener to the collection of listeners who will be notified when the user presses keys in the text
 * field. interface.
 * @param listener
 *            the listener which should be notified when the user presses keys in the text control.
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
 *                </ul>
 * @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 addTextControlKeyListener(KeyListener listener) {
	checkWidget();
	if (listener == null)
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	text.addKeyListener(listener);
}
 
Example 7
/**
 * Removes the listener from the collection of listeners who will be notified when the user presses keys in the text
 * control.
 * @param listener
 *            the listener which should no longer be notified
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
 *                </ul>
 * @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 removeTextControlKeyListener(KeyListener listener) {
	checkWidget();
	if (listener == null)
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	text.removeKeyListener(listener);
}
 
Example 8
/**
 * Sets the header renderer.
 *
 * @param headerRenderer The headerRenderer to set.
 * @throws IllegalArgumentException
 * <ul>
 * <li>ERROR_NULL_ARGUMENT - if the renderer is null</li>
 * </ul>
 * @throws org.eclipse.swt.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 setHeaderRenderer(GridHeaderRenderer headerRenderer)
{
    if (headerRenderer == null)
        SWT.error(SWT.ERROR_NULL_ARGUMENT);
    this.headerRenderer = headerRenderer;
    headerRenderer.setDisplay(getDisplay());
}
 
Example 9
Source Project: nebula   File: StarRating.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Removes the listener from the collection of listeners who will be notified when the 
 * control is selected by the user.
 * 
 * @param listener the listener which should no longer be notified
 * 
 * @exception IllegalArgumentException <ul>
 *     <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
 * </ul>
 * @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>
 * 
 * @see SelectionListener
 * @see #addSelectionListener
 */
public void removeSelectionListener(final SelectionListener listener) {
	checkWidget();
	if (listener == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}
	this.selectionListeners.remove(listener);
}
 
Example 10
Source Project: nebula   File: RadioItem.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Sets the receiver's background color to the color specified
 * by the argument, or to the default system color for the control
 * if the argument is null.
 * <p>
 * Note: This operation is a hint and may be overridden by the platform.
 * </p>
 * 
 * @param color the new color (or null)
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
 *                </ul>
 * @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 setBackground(Color background) {
	checkWidget();
	if (background == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}
	button.setBackground(background);
}
 
Example 11
Source Project: nebula   File: CTreeCombo.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Adds the listener to the collection of listeners who will be notified when
 * the user changes the receiver's selection, by sending it one of the messages
 * defined in the <code>SelectionListener</code> interface.
 * <p>
 * <code>widgetSelected</code> is called when the combo's list selection
 * changes. <code>widgetDefaultSelected</code> is typically called when ENTER is
 * pressed the combo's text area.
 * </p>
 *
 * @param listener
 *            the listener which should be notified when the user changes the
 *            receiver's selection
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
 *                </ul>
 * @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>
 *
 * @see SelectionListener
 * @see #removeSelectionListener
 * @see SelectionEvent
 */
public void addSelectionListener(final SelectionListener listener) {
	checkWidget();
	if (listener == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}

	final TypedListener typedListener = new TypedListener(listener);
	addListener(SWT.Selection, typedListener);
	addListener(SWT.DefaultSelection, typedListener);
}
 
Example 12
Source Project: nebula   File: ProgressCircle.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Sets the minimum value that the receiver will allow.
 *
 * @param value the new minimum
 *
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_INVALID_ARGUMENT - If minimum is greater than the maximum value</li>
 *                <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 setMinimum(int minimum) {
	checkWidget();
	if (minimum > maximum) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT, null, String.format("The value %d is greater than the maximum (%d)", minimum, maximum));
	}
	this.minimum = minimum;
	redraw();
	update();
}
 
Example 13
Source Project: nebula   File: ColumnItem.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * @return the widget that holds this item
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                </ul>
 */
public ColumnBrowserWidget getParent() {
	if (widget == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}

	if (widget.isDisposed()) {
		SWT.error(SWT.ERROR_WIDGET_DISPOSED);
	}
	return widget;
}
 
Example 14
Source Project: nebula   File: TableCombo.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Removes the listener from the collection of listeners who will be notified
 * when the control is verified.
 *
 * @param listener
 *            the listener which should no longer be notified
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
 *                </ul>
 * @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>
 *
 * @see VerifyListener
 * @see #addVerifyListener
 *
 * @since 3.3
 */
public void removeVerifyListener(final VerifyListener listener) {
	checkWidget();
	if (listener == null) {
		SWT.error(SWT.ERROR_NULL_ARGUMENT);
	}
	removeListener(SWT.Verify, listener);
}
 
Example 15
Source Project: nebula   File: ProgressCircle.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Set the selection value of this widget
 *
 * @param value the new percentage value
 *
 * @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 > maximum) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT, null, String.format("Value %d is out of range [%d - %d]", selection, minimum, maximum));
	}
	final int previousValue = value;
	value = selection;
	if (firstDisplay || previousValue == selection) {
		return;
	}
	startAnimation(previousValue);
}
 
Example 16
Source Project: birt   File: DataItemCombo.java    License: Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Adds the argument to the receiver's list at the given zero-relative
 * index.
 * <p>
 * Note: To add an item at the end of the list, use the result of calling
 * <code>getItemCount()</code> as the index or use <code>add(String)</code>.
 * </p>
 * 
 * @param string
 *            the new item
 * @param index
 *            the index for the item
 * 
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the string is null</li>
 *                <li>ERROR_INVALID_RANGE - if the index is not between 0
 *                and the number of elements in the list (inclusive)</li>
 *                </ul>
 * @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>
 * 
 * @see #add(String)
 */
public void add( String string, int index )
{
	checkWidget( );
	if ( string == null )
		SWT.error( SWT.ERROR_NULL_ARGUMENT );
	list.add( string, index );
}
 
Example 17
Source Project: birt   File: DataItemCombo.java    License: Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Sets the selection in the receiver's text field to the range specified by
 * the argument whose x coordinate is the start of the selection and whose y
 * coordinate is the end of the selection.
 * 
 * @param selection
 *            a point representing the new selection start and end
 * 
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the point is null</li>
 *                </ul>
 * @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( Point selection )
{
	checkWidget( );
	if ( selection == null )
		SWT.error( SWT.ERROR_NULL_ARGUMENT );
	text.setSelection( selection.x, selection.y );
}
 
Example 18
/**
 * Sets the receiver's foreground color to the color specified by the
 * argument, or to the default system color for the item if the argument is
 * null.
 *
 * @param foreground
 *            the new color (or null)
 * @throws IllegalArgumentException
 *             <ul>
 *             <li>ERROR_INVALID_ARGUMENT - if the argument has been
 *             disposed</li>
 *             </ul>
 * @throws 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 setForeground(Color foreground) {
	checkWidget();
	if (foreground != null && foreground.isDisposed()) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	defaultForeground = foreground;
	parent.redraw();
}
 
Example 19
Source Project: nebula   File: DualList.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Removes the items from the receiver which are between the given zero-relative
 * start and end indices (inclusive).
 *
 * @param start the start of the range
 * @param end the end of the range
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_INVALID_RANGE - if either the start or end are not
 *                between 0 and the number of elements in the list minus 1
 *                (inclusive) or if start>end</li>
 *                </ul>
 * @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 remove(final int start, final int end) {
	checkWidget();
	if (start > end) {
		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
	}
	for (int index = start; index < end; index++) {
		if (index < 0 || index >= items.size()) {
			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
		}
		items.remove(index);
	}
	redrawTables();
}
 
Example 20
Source Project: nebula   File: PaperClips.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Triggers an unspecified exception with the passed in detail.
 * 
 * @param detail
 *            more information about error.
 */
public static void error(String detail) {
	SWT.error(SWT.ERROR_UNSPECIFIED, null, detail);
}