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

The following examples show how to use org.eclipse.swt.SWT#Help . 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: TableCombo.java    From nebula with 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 2
Source File: TableCombo.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Handles Popup Events
 *
 * @param event
 */
private void popupEvent(final Event event) {
	switch (event.type) {
	case SWT.Paint:
		// draw rectangle around table
		final Rectangle tableRect = table.getBounds();
		event.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
		event.gc.drawRectangle(0, 0, tableRect.width + 1, tableRect.height + 1);
		break;
	case SWT.Close:
		event.doit = false;
		dropDown(false);
		break;
	case SWT.Deactivate:
		/*
		 * Bug in GTK. When the arrow button is pressed the popup control receives a
		 * deactivate event and then the arrow button receives a selection event. If we
		 * hide the popup in the deactivate event, the selection event will show it
		 * again. To prevent the popup from showing again, we will let the selection
		 * event of the arrow button hide the popup. In Windows, hiding the popup during
		 * the deactivate causes the deactivate to be called twice and the selection
		 * event to be disappear.
		 */
		if (!"carbon".equals(SWT.getPlatform())) {
			final Point point = arrow.toControl(getDisplay().getCursorLocation());
			final Point size = arrow.getSize();
			final Rectangle rect = new Rectangle(0, 0, size.x, size.y);
			if (!rect.contains(point)) {
				dropDown(false);
			}
		} else {
			dropDown(false);
		}
		break;

	case SWT.Help:
		if (isDropped()) {
			dropDown(false);
		}
		Composite comp = TableCombo.this;
		do {
			if (comp.getListeners(event.type) != null && comp.getListeners(event.type).length > 0) {
				comp.notifyListeners(event.type, event);
				break;
			}
			comp = comp.getParent();
		} while (null != comp);
		break;
	}
}
 
Example 3
Source File: TableCombo.java    From translationstudio8 with GNU General Public License v2.0 4 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);

	// 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 4
Source File: TableCombo.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles Popup Events
 * @param event
 */
private void popupEvent(Event event) {
	switch (event.type) {
	case SWT.Paint:
		// draw rectangle around table
		Rectangle tableRect = table.getBounds();
		event.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
		event.gc.drawRectangle(0, 0, tableRect.width + 1, tableRect.height + 1);
		break;
	case SWT.Close:
		event.doit = false;
		dropDown(false);
		break;
	case SWT.Deactivate:
		/*
		 * Bug in GTK. When the arrow button is pressed the popup control receives a deactivate event and then the
		 * arrow button receives a selection event. If we hide the popup in the deactivate event, the selection
		 * event will show it again. To prevent the popup from showing again, we will let the selection event of the
		 * arrow button hide the popup. In Windows, hiding the popup during the deactivate causes the deactivate to
		 * be called twice and the selection event to be disappear.
		 */
		if (!"carbon".equals(SWT.getPlatform())) {
			Point point = arrow.toControl(getDisplay().getCursorLocation());
			Point size = arrow.getSize();
			Rectangle rect = new Rectangle(0, 0, size.x, size.y);
			if (!rect.contains(point))
				dropDown(false);
		} else {
			dropDown(false);
		}
		break;

	case SWT.Help:
		if (isDropped()) {
			dropDown(false);
		}
		Composite comp = TableCombo.this;
		do {
			if (comp.getListeners(event.type) != null && comp.getListeners(event.type).length > 0) {
				comp.notifyListeners(event.type, event);
				break;
			}
			comp = comp.getParent();
		} while (null != comp);
		break;
	}
}
 
Example 5
Source File: TableCombo.java    From tmxeditor8 with GNU General Public License v2.0 4 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);

	// 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 6
Source File: TableCombo.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles Popup Events
 * @param event
 */
private void popupEvent(Event event) {
	switch (event.type) {
	case SWT.Paint:
		// draw rectangle around table
		Rectangle tableRect = table.getBounds();
		event.gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
		event.gc.drawRectangle(0, 0, tableRect.width + 1, tableRect.height + 1);
		break;
	case SWT.Close:
		event.doit = false;
		dropDown(false);
		break;
	case SWT.Deactivate:
		/*
		 * Bug in GTK. When the arrow button is pressed the popup control receives a deactivate event and then the
		 * arrow button receives a selection event. If we hide the popup in the deactivate event, the selection
		 * event will show it again. To prevent the popup from showing again, we will let the selection event of the
		 * arrow button hide the popup. In Windows, hiding the popup during the deactivate causes the deactivate to
		 * be called twice and the selection event to be disappear.
		 */
		if (!"carbon".equals(SWT.getPlatform())) {
			Point point = arrow.toControl(getDisplay().getCursorLocation());
			Point size = arrow.getSize();
			Rectangle rect = new Rectangle(0, 0, size.x, size.y);
			if (!rect.contains(point))
				dropDown(false);
		} else {
			dropDown(false);
		}
		break;

	case SWT.Help:
		if (isDropped()) {
			dropDown(false);
		}
		Composite comp = TableCombo.this;
		do {
			if (comp.getListeners(event.type) != null && comp.getListeners(event.type).length > 0) {
				comp.notifyListeners(event.type, event);
				break;
			}
			comp = comp.getParent();
		} while (null != comp);
		break;
	}
}