Java Code Examples for org.eclipse.swt.SWT#MouseUp
The following examples show how to use
org.eclipse.swt.SWT#MouseUp .
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: CTree.java From nebula with Eclipse Public License 2.0 | 6 votes |
public void handleEvent(Event event) { switch (event.type) { case SWT.FocusIn: case SWT.FocusOut: handleFocus(event.type); break; case SWT.MouseDoubleClick: case SWT.MouseDown: case SWT.MouseMove: case SWT.MouseUp: handleMouseEvents(event); break; case SWT.Traverse: handleTraverse(event); break; } }
Example 2
Source File: CCombo.java From birt with Eclipse Public License 1.0 | 6 votes |
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 3
Source File: InformationPresenterControlManager.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public void handleEvent(Event event) { switch (event.type) { case SWT.Activate: case SWT.MouseVerticalWheel: case SWT.MouseUp: case SWT.MouseDown: case SWT.FocusOut: IInformationControl iControl = fInformationControl; if (iControl != null && !iControl.isFocusControl()) { hideInformationControl(); } break; case SWT.MouseMove: case SWT.MouseEnter: case SWT.MouseExit: handleMouseMove(event); break; case SWT.KeyDown: if (event.keyCode == SWT.ESC) { hideInformationControl(); } else if (fActivateEditorBinding != null && KeyBindingHelper.matchesKeybinding(event.keyCode, event.stateMask, fActivateEditorBinding)) { hideInformationControl(true, true); } break; } }
Example 4
Source File: SWTOpenGLDisplaySurface.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void dispatchMouseEvent(final int swtMouseEvent) { final GamaPoint p = renderer.getCameraHelper().getMousePosition(); final int x = (int) p.x; final int y = (int) p.y; for (final IEventLayerListener gl : listeners) { switch (swtMouseEvent) { case SWT.MouseDown: gl.mouseDown(x, y, 1); break; case SWT.MouseUp: gl.mouseUp(x, y, 1); break; case SWT.MouseMove: gl.mouseMove(x, y); break; case SWT.MouseEnter: gl.mouseEnter(x, y); break; case SWT.MouseExit: gl.mouseExit(x, y); break; case SWT.MenuDetect: gl.mouseMenu(x, y); break; } } }
Example 5
Source File: StyleCombo.java From birt with Eclipse Public License 1.0 | 5 votes |
void createPopup( Object[] items, int selectionIndex ) { // create shell and list popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP ); table = new Table( popup, SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION ); new TableColumn( table, SWT.LEFT ); if ( font != null ) table.setFont( font ); if ( foreground != null ) table.setForeground( foreground ); if ( background != null ) table.setBackground( background ); label.setBackground( table.getBackground( ) ); label.setForeground( table.getForeground( ) ); label.setFont( table.getFont( ) ); int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for ( int i = 0; i < popupEvents.length; i++ ) popup.addListener( popupEvents[i], listener ); int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose }; for ( int i = 0; i < tableEvents.length; i++ ) table.addListener( tableEvents[i], listener ); }
Example 6
Source File: Java2DDisplaySurface.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void dispatchMouseEvent(final int swtMouseEvent) { final int x = mousePosition.x; final int y = mousePosition.y; for (final IEventLayerListener gl : listeners) { switch (swtMouseEvent) { case SWT.MouseDown: gl.mouseDown(x, y, 1); break; case SWT.MouseUp: gl.mouseUp(x, y, 1); break; case SWT.MouseMove: gl.mouseMove(x, y); break; case SWT.MouseEnter: gl.mouseEnter(x, y); break; case SWT.MouseExit: gl.mouseExit(x, y); break; case SWT.MenuDetect: gl.mouseMenu(x, y); break; } } }
Example 7
Source File: SwtBotWorkbenchActions.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private static void openPreferencesDialogViaEvents(SWTBot bot) { Display display = bot.getDisplay(); Event event = new Event(); // Move to the "Apple" menu item (it catches 0, 0) event.type = SWT.MouseMove; event.x = 0; event.y = 0; display.post(event); bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS); // Click event.type = SWT.MouseDown; event.button = 1; display.post(event); bot.sleep(SwtBotTestingUtilities.EVENT_DOWN_UP_DELAY_MS); event.type = SWT.MouseUp; display.post(event); bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS); // Right to the "Eclipse" menu item SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_RIGHT, '\0'); bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS); // Down two to the "Preferences..." menu item SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0'); bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS); SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0'); bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS); // Press enter SwtBotTestingUtilities.sendKeyDownAndUp(bot, 0, '\r'); bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS); }
Example 8
Source File: TableCombo.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * 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 9
Source File: XViewerEditAdapter.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override public void mouseUp(MouseEvent e) { // not supported yet! if (swtStyle == SWT.MouseUp) { klickedColumn = xv.getColumnUnderMouseClick(new Point(e.x, e.y)); klickedCell = xv.getCell(new Point(e.x, e.y)); } }
Example 10
Source File: TableCombo.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * 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
Source File: AnalogTimePicker.java From nebula with Eclipse Public License 2.0 | 4 votes |
protected void createContents() { setLayout(new BaseLayout()); dialPanel = new VPanel(this, SWT.NONE); dialPanel.setLayout(new DialLayout()); timeAmPm = new VButton(dialPanel, SWT.NO_FOCUS); timeAmPm.setText("PM"); //$NON-NLS-1$ timeAmPm.setForeground( getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE)); timeAmPm.setMargins(4, 4); timeAmPm.setEnabled(!dialPanel.hasStyle(CDT.READ_ONLY)); tapl = event -> { if (event.widget == null) { Calendar tmpcal = cdt.getCalendarInstance(); tmpcal.set(Calendar.AM_PM, tmpcal.get(Calendar.AM_PM) == 0 ? 1 : 0); setSelection(tmpcal.getTime()); cdt.fireSelectionChanged(Calendar.AM_PM); } }; timeAmPm.addListener(SWT.Selection, tapl); timeAmPm.addListener(SWT.MouseWheel, tapl); Listener listener = event -> { if (cdt.getEditable()) { switch (event.type) { case SWT.Deactivate: if (VTracker.isMouseDown()) { handleMouseUp(); overHour = overMin = overSec = false; redraw(); } break; case SWT.MouseDown: handleMouseDown(); break; case SWT.MouseMove: handleMouseMove(event.x, event.y); break; case SWT.MouseUp: handleMouseUp(); break; case SWT.MouseWheel: handleMouseWheel(event.count); break; } } }; dialPanel.addListener(SWT.Deactivate, listener); dialPanel.addListener(SWT.MouseDown, listener); dialPanel.addListener(SWT.MouseMove, listener); dialPanel.addListener(SWT.MouseUp, listener); dialPanel.addListener(SWT.MouseWheel, listener); dialPanel.setPainter(new AnalogClockPainter(cdt, this)); }
Example 12
Source File: CCombo.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. * <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 widget to construct * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * </ul> * * @see SWT#BORDER * @see SWT#READ_ONLY * @see SWT#FLAT * @see Widget#getStyle() */ public CCombo (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 () { public void handleEvent (Event event) { if (popup == event.widget) { popupEvent (event); return; } if (text == event.widget) { textEvent (event); return; } if (list == event.widget) { listEvent (event); return; } if (arrow == event.widget) { arrowEvent (event); return; } if (CCombo.this == event.widget) { comboEvent (event); return; } } }; int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize}; for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener); int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut}; for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener); int [] arrowEvents = {SWT.Selection, SWT.FocusIn, SWT.FocusOut}; for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener); createPopup(null, -1); initAccessible(); }
Example 13
Source File: CTreeCombo.java From nebula with Eclipse Public License 2.0 | 4 votes |
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 14
Source File: DeviceTemplateChooser.java From BiglyBT with GNU General Public License v2.0 | 4 votes |
private void createDeviceTemplateList2(SWTSkinObjectContainer soList) { DeviceTemplate[] devices = mf.getDeviceTemplates(); if (devices.length == 0) { noDevices(); return; } Arrays.sort(devices, new Comparator<DeviceTemplate>() { @Override public int compare(DeviceTemplate o1, DeviceTemplate o2) { return o1.getName().compareToIgnoreCase(o2.getName()); } }); Composite parent = soList.getComposite(); if (parent.getChildren().length > 0) { Utils.disposeComposite(parent, false); } SWTSkin skin = skinnedDialog.getSkin(); RowLayout layout = new RowLayout(SWT.HORIZONTAL); layout.spacing = 0; layout.marginLeft = layout.marginRight = 0; layout.wrap = true; layout.justify = true; layout.fill = true; parent.setLayout(layout); Listener clickListener = new Listener() { boolean down = false; @Override public void handleEvent(Event event) { if (event.type == SWT.MouseDown) { down = true; } else if (event.type == SWT.MouseUp && down) { Widget widget = (event.widget instanceof Label) ? ((Label) event.widget).getParent() : event.widget; selectedDeviceTemplate = (DeviceTemplate) widget.getData("obj"); if (selectedDeviceTemplate == null) { Debug.out("selectedDeviceTemplate is null!"); } skinnedDialog.close(); down = false; } } }; for (DeviceTemplate deviceTemplate : devices) { if (deviceTemplate.isAuto()) { continue; } String iconURL = null; // deviceTemplate.getIconURL(); TranscodeChooser.addImageBox(parent, clickListener, null, deviceTemplate, iconURL, deviceTemplate.getName()); } SWTSkinObjectText soTitle = (SWTSkinObjectText) skin.getSkinObject("title"); if (soTitle != null) { soTitle.setTextID("devices.choose.device.title"); } SWTSkinObjectText soSubTitle = (SWTSkinObjectText) skin.getSkinObject("subtitle"); if (soSubTitle != null) { soSubTitle.setTextID("label.clickone"); } Shell shell = skinnedDialog.getShell(); Point computeSize = shell.computeSize(shell.getSize().x, SWT.DEFAULT, true); shell.setSize(computeSize); UIFunctionsSWT uiFunctionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT(); if (uiFunctionsSWT != null) { Shell mainShell = uiFunctionsSWT.getMainShell(); Utils.centerWindowRelativeTo(shell, mainShell); } }
Example 15
Source File: CTreeCombo.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * 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 16
Source File: TableCombo.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 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 17
Source File: CTree.java From nebula with Eclipse Public License 2.0 | 4 votes |
protected void handleMouseEvents(Event event) { CTreeItem item = null; if (event.widget == body) { item = getItem(event.x, event.y); } else if (event.item instanceof CTreeItem) { item = (CTreeItem) event.item; } switch (event.type) { case SWT.MouseDoubleClick: if(item != null && (selectOnToggle || !item.isToggle(event.x, event.y))) { fireSelectionEvent(true); } break; case SWT.MouseDown: if(!hasFocus) setFocus(); if(item == null) { if(event.widget == body) { item = getItem(event.x, event.y); } else if(event.item instanceof CTreeItem) { item = (CTreeItem) event.item; } } switch(event.button) { // TODO - popup menu: not just for mouse down events! case 3: Menu menu = getMenu(); if ((menu != null) && ((menu.getStyle() & SWT.POP_UP) != 0)) { menu.setVisible(true); } case 1: if(selectOnToggle || !item.isToggle(event.x, event.y)) { if(selectOnTreeToggle || !item.isTreeToggle(event.x,event.y)) { if((event.stateMask & SWT.SHIFT) != 0) { if(shiftSel == null) { if(selection.isEmpty()) selection.add(item); shiftSel = (CTreeItem) selection.get(selection.size() - 1); } setSelection(shiftSel, item); } else if((event.stateMask & SWT.CONTROL) != 0) { toggleSelection(item); shiftSel = null; } else { setSelection(item); shiftSel = null; } } } break; } break; case SWT.MouseMove: // TODO: make toggles more dynamic break; case SWT.MouseUp: if(item.isToggle(event.x,event.y)) { boolean open = item.isOpen(event.x,event.y); if(item.isTreeToggle(event.x,event.y)) { // visibleItems = null; item.setExpanded(!open); fireTreeEvent(item, !open); } else { item.getCell(event.x, event.y).setOpen(!open); } } break; } }
Example 18
Source File: DataItemCombo.java From birt with Eclipse Public License 1.0 | 4 votes |
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 19
Source File: TableCombo.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * 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 20
Source File: DragButtonMouseEvents.java From codeexamples-eclipse with Eclipse Public License 1.0 | 4 votes |
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); final Composite composite = new Composite(shell, SWT.NONE); composite.setEnabled(false); composite.setLayout(new FillLayout()); Button button = new Button(composite, SWT.PUSH); button.setText("Button"); composite.pack(); composite.setLocation(10, 10); final Point[] offset = new Point[1]; Listener listener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.MouseDown: Rectangle rect = composite.getBounds(); if (rect.contains(event.x, event.y)) { Point pt1 = composite.toDisplay(0, 0); Point pt2 = shell.toDisplay(event.x, event.y); offset[0] = new Point(pt2.x - pt1.x, pt2.y - pt1.y); } break; case SWT.MouseMove: if (offset[0] != null) { Point pt = offset[0]; composite.setLocation(event.x - pt.x, event.y - pt.y); } break; case SWT.MouseUp: offset[0] = null; break; } } }; shell.addListener(SWT.MouseDown, listener); shell.addListener(SWT.MouseUp, listener); shell.addListener(SWT.MouseMove, listener); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }