org.eclipse.swt.widgets.Event Java Examples
The following examples show how to use
org.eclipse.swt.widgets.Event.
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: JavaCamelJobScriptsExportWSWizardPage.java From tesb-studio-se with Apache License 2.0 | 6 votes |
@Override public void handleEvent(Event e) { super.handleEvent(e); Widget source = e.widget; if (source == destinationBrowseButton) { handleDestinationBrowseButtonPressed(); } if (source instanceof Combo) { String destination = ((Combo) source).getText(); if (getDialogSettings() != null) { IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE); if (section == null) { section = getDialogSettings().addNewSection(DESTINATION_FILE); } section.put(DESTINATION_FILE, destination); } } }
Example #2
Source File: ResourceDependencySection.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override public void handleEvent(Event event) { if (event.widget == addButton) { handleAdd(); } else if (event.widget == removeButton || (event.type == SWT.KeyUp && event.character == SWT.DEL)) { handleRemove(); } else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) { handleEdit(); } // else if (event.type == SWT.MouseDown && event.button == 3) { // handleTableContextMenuRequest(event); // } else if (event.type == SWT.MouseHover) { handleTableHoverHelp(event); } else if (event.type == SWT.Selection) { editor.getResourcesPage().getResourceBindingsSection().enable(); } enable(); }
Example #3
Source File: VButton.java From nebula with Eclipse Public License 2.0 | 6 votes |
private Event createEvent(Event event) { Event e = new Event(); e.type = SWT.Selection; e.data = VButton.this; e.button = event.button; e.detail = event.detail; e.display = event.display; e.gc = event.gc; e.height = event.height; e.stateMask = event.stateMask; e.time = event.time; e.width = event.width; e.x = event.x; e.y = event.y; return e; }
Example #4
Source File: OpenUIDesignerCoolBarItemTest.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Test public void call_open_ui_designer_command_on_selection() throws Exception { final OpenUIDesignerCoolBarItem openUIDesignerCoolBarItem = spy(new OpenUIDesignerCoolBarItem()); doReturn(openDesignerHandler).when(openUIDesignerCoolBarItem).getHandler(); doReturn(prefStore).when(openUIDesignerCoolBarItem).getPreferenceStore(); doReturn(eclipsePref).when(openUIDesignerCoolBarItem).getEclipsePreferences(); doReturn(true).when(eclipsePref).getBoolean(eq(OpenUIDesignerCoolBarItem.HIDE_UIDESIGNER_INFO_DIALOG), anyBoolean()); final Shell shell = realmWithDisplay.getShell(); doReturn(shell).when(openUIDesignerCoolBarItem).getShell(); final ToolBar toolbar = new ToolBar(realmWithDisplay.createComposite(), SWT.NONE); openUIDesignerCoolBarItem.fill(toolbar, 0, -1); final ToolItem toolItem = toolbar.getItem(0); toolItem.notifyListeners(SWT.Selection, new Event()); verify(openDesignerHandler).execute(); }
Example #5
Source File: VButtonImageBak.java From nebula with Eclipse Public License 2.0 | 6 votes |
public void handleEvent(Event e) { GC gc = new GC(b); Image image = new Image(b.getDisplay(), e.width, e.height); gc.copyArea(image, 0, 0); ImageData data = image.getImageData(); gc.dispose(); image.dispose(); images.put(key, data); keys.put(data, key); if(requests.containsKey(key)) { for(Iterator<VButton> iter = requests.get(key).iterator(); iter.hasNext();) { iter.next().redraw(); iter.remove(); } requests.remove(key); } Display.getDefault().asyncExec(new Runnable() { public void run() { if(!b.isDisposed() && b == b.getDisplay().getFocusControl()) { b.getParent().forceFocus(); } b.dispose(); } }); }
Example #6
Source File: MoveScrollBarEffect.java From nebula with Eclipse Public License 2.0 | 6 votes |
public void applyEffect(final long currentTime) { current = (int) (start + step * easingFunction.getValue((int) currentTime)); if (!scrollBar.isDisposed()) { scrollBar.setSelection(current); Event event = new Event(); event.detail = step < 0 ? SWT.PAGE_UP : SWT.PAGE_DOWN; event.data = this; event.display = scrollBar.getDisplay(); event.widget = scrollBar; event.doit = true; scrollBar.notifyListeners(SWT.Selection, event); } }
Example #7
Source File: ExportToDDLAction.java From ermaster-b with Apache License 2.0 | 6 votes |
@Override public void execute(Event event) { ERDiagram diagram = this.getDiagram(); ExportToDDLDialog dialog = new ExportToDDLDialog(PlatformUI .getWorkbench().getActiveWorkbenchWindow().getShell(), diagram, this.getEditorPart(), this.getGraphicalViewer()); dialog.open(); this.refreshProject(); if (dialog.getExportSetting() != null && !diagram.getDiagramContents().getSettings() .getExportSetting().equals(dialog.getExportSetting())) { Settings newSettings = (Settings) diagram.getDiagramContents() .getSettings().clone(); newSettings.setExportSetting(dialog.getExportSetting()); ChangeSettingsCommand command = new ChangeSettingsCommand(diagram, newSettings); this.execute(command); } }
Example #8
Source File: PGroupToolItem.java From nebula with Eclipse Public License 2.0 | 6 votes |
void onMouseDown(Event e) { if ((getStyle() & SWT.DROP_DOWN) == 0) { setSelection(!getSelection()); notifyListeners(SWT.Selection, new Event()); } else { if ( ((getStyle() & SWT.PUSH) == SWT.PUSH) && ( dropdownArea == null || !dropdownArea.contains(e.x, e.y))) { notifyListeners(SWT.Selection, new Event()); } else { Event event = new Event(); event.detail = SWT.ARROW; event.x = bounds.x; event.y = bounds.y + bounds.height; notifyListeners(SWT.Selection, event); } } }
Example #9
Source File: SpeedGraphic.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
@Override public void initialize(Canvas canvas) { super.initialize(canvas); drawCanvas.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { if (bufferImage != null && !bufferImage.isDisposed()) { Rectangle bounds = bufferImage.getBounds(); if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) { e.gc.drawImage(bufferImage, e.x, e.y, e.width, e.height, e.x, e.y, e.width, e.height); } } } }); drawCanvas.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(Event event) { drawChart(true); } }); }
Example #10
Source File: FindReplaceDialog.java From pmTrans with GNU Lesser General Public License v3.0 | 6 votes |
private void renderTransparency(final Shell shell) { Group group = new Group(shell, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 6, 1)); group.setLayout(new GridLayout(1, false)); group.setText("Transparency"); final Scale transparencySlider = new Scale(group, SWT.HORIZONTAL); transparencySlider.setMinimum(20); transparencySlider.setMaximum(100); transparencySlider.setPageIncrement(90); transparencySlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); transparencySlider.setSelection(100); transparencySlider.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { shell.setAlpha(255 * transparencySlider.getSelection() / 100); } }); }
Example #11
Source File: StyledTextActionHandler.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public void handleEvent(Event event) { switch (event.type) { case SWT.Activate : styledText = (StyledText) event.widget; updateActionsEnableState(); break; case SWT.Deactivate : styledText = null; updateActionsEnableState(); break; default : break; } }
Example #12
Source File: ContextMenuHelper.java From saros with GNU General Public License v2.0 | 6 votes |
private static void click(final MenuItem menuItem) { final Event event = new Event(); event.time = (int) System.currentTimeMillis(); event.widget = menuItem; event.display = menuItem.getDisplay(); event.type = SWT.Selection; UIThreadRunnable.asyncExec( menuItem.getDisplay(), new VoidResult() { @Override public void run() { menuItem.notifyListeners(SWT.Selection, event); } }); }
Example #13
Source File: KeyBindingHelper.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public static void handleEvent(Event e) { IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); Listener keyDownFilter = ((BindingService) bindingService).getKeyboard().getKeyDownFilter(); boolean enabled = bindingService.isKeyFilterEnabled(); Control focusControl = e.display.getFocusControl(); try { bindingService.setKeyFilterEnabled(true); keyDownFilter.handleEvent(e); } finally { if (focusControl == e.display.getFocusControl()) // $codepro.audit.disable useEquals { bindingService.setKeyFilterEnabled(enabled); } } }
Example #14
Source File: Breadcrumb.java From SWET with MIT License | 6 votes |
private void addMouseDownListener() { addListener(SWT.MouseDown, new Listener() { @Override public void handleEvent(final Event event) { for (final BreadcrumbItem item : Breadcrumb.this.items) { if (item.getBounds().contains(event.x, event.y)) { final boolean isToggle = (item.getStyle() & SWT.TOGGLE) != 0; final boolean isPush = (item.getStyle() & SWT.PUSH) != 0; if (isToggle || isPush) { item.setSelection(!item.getSelection()); redraw(); update(); } item.setData(IS_BUTTON_PRESSED, "*"); return; } } } }); }
Example #15
Source File: ToolItemMenuListener.java From ice with Eclipse Public License 1.0 | 6 votes |
/** * This function should only make the Menu visible if necessary. Nothing * inside the Menu will be changed. */ @Override public void handleEvent(Event event) { // We want to align the menu with the bottom-left corner of the ToolItem // arrow. // event.detail == SWT.ARROW means the arrow has been clicked. // event.detail == SWT.NONE means the button has been clicked. if (event.detail == SWT.ARROW || event.detail == SWT.NONE) { Rectangle r = toolItem.getBounds(); Point p = new Point(r.x, r.y + r.height); p = toolItem.getParent().toDisplay(p.x, p.y); menu.setLocation(p.x, p.y); menu.setVisible(true); } return; }
Example #16
Source File: StyledTextCellEditor.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 添加标记样式改变监听 ; */ private void addTagStyleChangeListener() { final TagStyleManager tagStyleManager = xliffEditor.getTagStyleManager(); final Listener tagStyleChangeListener = new Listener() { public void handleEvent(Event event) { if (event.data != null && event.data instanceof TagStyle) { viewer.setTagStyle((TagStyle) event.data); } } }; tagStyleManager.addTagStyleChangeListener(tagStyleChangeListener); viewer.getTextWidget().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { tagStyleManager.removeTagStyleChangeListener(tagStyleChangeListener); } }); }
Example #17
Source File: ScriptValuesModDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void treeDblClick( Event event ) { StyledTextComp wScript = getStyledTextComp(); Point point = new Point( event.x, event.y ); TreeItem item = wTree.getItem( point ); // Qualifikation where the Click comes from if ( item != null && item.getParentItem() != null ) { if ( item.getParentItem().equals( wTreeScriptsItem ) ) { setActiveCtab( item.getText() ); } else if ( !item.getData().equals( "Function" ) ) { int iStart = wScript.getCaretOffset(); int selCount = wScript.getSelectionCount(); // this selection will be replaced by wScript.insert iStart = iStart - selCount; // when a selection is already there we need to subtract the position if ( iStart < 0 ) { iStart = 0; // just safety } String strInsert = (String) item.getData(); if ( strInsert.equals( "jsFunction" ) ) { strInsert = item.getText(); } wScript.insert( strInsert ); wScript.setSelection( iStart, iStart + strInsert.length() ); } } /* * if (item != null && item.getParentItem()!=null && !item.getData().equals("Function")) { int iStart = * wScript.getCaretOffset(); String strInsert =(String)item.getData(); if(strInsert.equals("jsFunction")) strInsert * = (String)item.getText(); wScript.insert(strInsert); wScript.setSelection(iStart,iStart+strInsert.length()); } */ }
Example #18
Source File: KeybindingsManager.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void consumeEvent(Event event) { switch (event.type) { case SWT.KeyDown: event.doit = false; break; case SWT.Traverse: event.detail = SWT.TRAVERSE_NONE; event.doit = true; break; default: } event.type = SWT.NONE; }
Example #19
Source File: PGroup.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void onKeyDown(Event e) { if (e.character == ' ' || e.character == '\r') { setExpanded(!getExpanded()); if (expanded) { notifyListeners(SWT.Expand, new Event()); } else { notifyListeners(SWT.Collapse, new Event()); } } }
Example #20
Source File: KbdMacroExecuteHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
@Override protected Object transformWithCount(ITextEditor editor, IDocument document, ITextSelection selection, ExecutionEvent event) { Event e = null; if (event != null && (e = (Event)event.getTrigger()) != null) { // disallow macro execution with modifier key if (e.stateMask != 0) { beep(); asyncShowMessage(editor, KBD_BINDING_WARNING, true); return null; } } MacroCount keepCount = null; if (hasKbdMacro()) { int count = Math.abs(getUniversalCount()); if (incrementExecutionCount() == 0) { // only add first time (not on iterative/nested invocations) addBeeper(); keepCount = new MacroCount(); if (count == 0) { count = Integer.MAX_VALUE; // essentially forever } } // synchronize key listeners for this invocation (may be nested) KbdLock kbdLock = new KbdLock(); pushExecution(editor,kbdLock); runMacro(editor, document, selection, kbdLock, count, event.getCommand().getId(),keepCount); } else { beep(); asyncShowMessage(editor, NO_MACRO_ERROR, true); } return null; }
Example #21
Source File: PatternImageEditorDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
private void doToggleDropDown( ) { Event event = new Event( ); event.type = DropDownControl.ToggleDropDown; event.widget = this; notifyListeners( DropDownControl.ToggleDropDown, event ); }
Example #22
Source File: KbdMacroExecuteHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
private Event upEvent(VerifyEvent event) { Event e = new Event(); e.keyCode = event.keyCode; e.character = event.character; e.stateMask = event.stateMask; e.type = SWT.KeyUp; e.doit = true; return e; }
Example #23
Source File: PingGraphic.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
@Override protected void addMenuItems( Menu menu ) { new MenuItem( menu, SWT.SEPARATOR ); MenuItem mi_reset = new MenuItem( menu, SWT.PUSH ); mi_reset.setText( MessageText.getString( "label.clear.history" )); mi_reset.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { try{ this_mon.enter(); nbValues = 0; currentPosition = 0; for ( int i=0;i<all_values.length;i++ ){ all_values[i] = new int[all_values[i].length]; } }finally{ this_mon.exit(); } refresh( true ); } }); }
Example #24
Source File: Find_Replace.java From AndroidRobot with Apache License 2.0 | 5 votes |
/** * Open the window. */ public void open() { if (isOpen == true) return; isOpen = true; display = Display.getDefault(); shell = new Shell(parent);// shell.setLayout(new GridLayout()); shell.open(); shell.setSize(273, 400); shell.setText("查找/替换"); createForm(); shell.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.Close: isOpen = false; break; } } }); shell.layout(); while (shell != null && !shell.isDisposed()) { if (display != null && !display.readAndDispatch()) { display.sleep(); } } }
Example #25
Source File: ChangeOutlineViewOrderByPhysicalNameAction.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void execute(final Event event) { final ERDiagram diagram = getDiagram(); final ChangeOutlineViewOrderByCommand command = new ChangeOutlineViewOrderByCommand(diagram, Settings.VIEW_MODE_PHYSICAL); this.execute(command); }
Example #26
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 #27
Source File: AbstractBaseSelectionAction.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public final void runWithEvent(final Event event) { try { execute(event); } catch (final Exception e) { ERDiagramActivator.showExceptionDialog(e); } }
Example #28
Source File: DefaultColumnGroupHeaderRenderer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public boolean notify(int event, Point point, Object value) { GridColumnGroup group = (GridColumnGroup)value; if ((group.getStyle() & SWT.TOGGLE) != 0) { if (event == IInternalWidget.LeftMouseButtonDown) { if (getToggleBounds().contains(point)) { group.setExpanded(!group.getExpanded()); if (group.getExpanded()) { group.notifyListeners(SWT.Expand,new Event()); } else { group.notifyListeners(SWT.Collapse,new Event()); } return true; } } else { if (getToggleBounds().contains(point)) { setHoverDetail("toggle"); return true; } } } return false; }
Example #29
Source File: ContextActionUiTestUtil.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Returns the context menu item identified by the given labels. * When a context menu 'Compile' exists with the sub context menu 'All Invalids', * then the context menu 'All Invalids' is returned when giving the labels 'Compile' and 'All Invalids'. * * @param bot * the {@link AbstractSWTBot} on which to infer the context menu * @param labels * the labels on the context menus * @return the context menu item, {@code null} if the context menu item could not be found */ private static MenuItem getContextMenuItem(final AbstractSWTBot<? extends Control> bot, final String... labels) { return UIThreadRunnable.syncExec(new WidgetResult<MenuItem>() { @Override public MenuItem run() { MenuItem menuItem = null; Control control = bot.widget; // MenuDetectEvent Event event = new Event(); control.notifyListeners(SWT.MenuDetect, event); if (event.doit) { Menu menu = control.getMenu(); for (String text : labels) { Matcher<?> matcher = allOf(instanceOf(MenuItem.class), withMnemonic(text)); menuItem = show(menu, matcher); if (menuItem != null) { menu = menuItem.getMenu(); } else { hide(menu); break; } } return menuItem; } else { return null; } } }); }
Example #30
Source File: SquareButtonGroupIntegTest.java From swt-bling with MIT License | 5 votes |
@Test public void testBasicToggle() { toggleTwo.notifyListeners(SWT.MouseUp, new Event()); Assert.assertFalse(toggleOne.isToggled()); Assert.assertTrue(toggleTwo.isToggled()); Assert.assertFalse(toggleThree.isToggled()); Assert.assertFalse(nonToggled.isToggled()); }