org.eclipse.swt.widgets.Widget Java Examples
The following examples show how to use
org.eclipse.swt.widgets.Widget.
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: Popup2.java From gama with GNU General Public License v3.0 | 6 votes |
public Popup2(final IPopupProvider provider, final Widget... controls) { super(WorkbenchHelper.getShell(), PopupDialog.HOVER_SHELLSTYLE, false, false, false, false, false, null, null); this.provider = provider; final Shell parent = provider.getControllingShell(); parent.addListener(SWT.Move, hide); parent.addListener(SWT.Resize, hide); parent.addListener(SWT.Close, hide); parent.addListener(SWT.Deactivate, hide); parent.addListener(SWT.Hide, hide); parent.addListener(SWT.Dispose, event -> close()); for (final Widget c : controls) { if (c == null) { continue; } final TypedListener typedListener = new TypedListener(mtl); c.addListener(SWT.MouseEnter, typedListener); c.addListener(SWT.MouseExit, typedListener); c.addListener(SWT.MouseHover, typedListener); } }
Example #2
Source File: SubtaskSheetImpl.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Detaches the popup dialogue if the name is same with the widget. Called * when clicking buttons manually. * * @param widget * the button widget * @return detach result */ protected boolean detachPopup( Widget widget ) { if ( widget instanceof Button && popupShell != null && !popupShell.isDisposed( ) && !isButtonSelected( ) ) { getWizard( ).detachPopup( ); popupShell = null; // Clear selection if user unselected the button. setCurrentPopupSelection( null ); getParentTask( ).setPopupSelection( null ); return true; } return false; }
Example #3
Source File: SWTUtil.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * @param widget the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) { return ((Control) widget).getShell(); } if (widget instanceof Caret) { return ((Caret) widget).getParent().getShell(); } if (widget instanceof DragSource) { return ((DragSource) widget).getControl().getShell(); } if (widget instanceof DropTarget) { return ((DropTarget) widget).getControl().getShell(); } if (widget instanceof Menu) { return ((Menu) widget).getParent().getShell(); } if (widget instanceof ScrollBar) { return ((ScrollBar) widget).getParent().getShell(); } return null; }
Example #4
Source File: ValidPreferenceCheckedTreeViewer.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Update the parent and children nodes after a checkstate change (e.g. recalculation of the grayed state, automatic * checking/unchecking of children) * * @param element * the element that was checked/unchecked */ protected void doCheckStateChanged(final Object element) { final Widget item = findItem(element); if (item instanceof TreeItem) { final TreeItem treeItem = (TreeItem) item; updateChildrenItems(treeItem); final Item[] children = getChildren(item); if (children.length > 0) { boolean containsChecked = false; boolean containsUnchecked = false; for (final Item element2 : children) { final TreeItem curr = (TreeItem) element2; containsChecked |= curr.getChecked(); containsUnchecked |= (!curr.getChecked() || curr.getGrayed()); } treeItem.setChecked(containsChecked); treeItem.setGrayed(containsChecked && containsUnchecked); } updateParentItems(treeItem.getParentItem()); } }
Example #5
Source File: MenuItemProviders.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * Walk up the MenuItems (in case they are nested) and find the parent {@link Menu} * * @param selectionEvent * on the {@link MenuItem} * @return data associated with the parent {@link Menu} */ public static NatEventData getNatEventData(SelectionEvent selectionEvent) { Widget widget = selectionEvent.widget; if (widget == null || !(widget instanceof MenuItem)) { return null; } MenuItem menuItem = (MenuItem) widget; Menu parentMenu = menuItem.getParent(); Object data = null; while (parentMenu != null) { if (parentMenu.getData() == null) { parentMenu = parentMenu.getParentMenu(); } else { data = parentMenu.getData(); break; } } return data != null ? (NatEventData) data : null; }
Example #6
Source File: TableEditor.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Creates a selection listener. */ public void createSelectionListener() { selectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { Widget widget = event.widget; if (widget == addButton) { addPressed(); } else if (widget == removeButton) { removePressed(); } else if (widget == upButton) { upPressed(); } else if (widget == downButton) { downPressed(); } else if (widget == table) { selectionChanged(); } } }; }
Example #7
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 #8
Source File: EventVsFrp.java From gradle-and-eclipse-rcp with Apache License 2.0 | 6 votes |
@Test(expected = ClassCastException.class) public void frpBased() { Widget widget = (Widget) new Object(); Observable<Event> keyDownStream = SwtRx.addListener(widget, SWT.KeyDown); keyDownStream.subscribe(e -> { // this is our chance to react System.out.println("keyCode=" + e.keyCode); }); // this is how we do filtering keyDownStream.filter(e -> e.keyCode == 'q').subscribe(e -> { System.out.println("user wants to leave talk"); }); // this is how we do mapping keyDownStream.map(e -> e.keyCode | e.stateMask).subscribe(accel -> { System.out.println(Actions.getAcceleratorString(accel)); }); }
Example #9
Source File: LazyItemsSelectionListener.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override public void widgetSelected(SelectionEvent e) { // An item is selected Widget item = e.item; if (item.getData(LAST_ITEM_LOADED) != null) { // The selected item must load another page. PageableController controller = super.getController(e.widget); if (controller.hasNextPage()) { // There is next page, increment the current page of the // controller controller.setCurrentPage(controller.getCurrentPage() + 1); } // Set as null the LAST_ITEM_LOADED flag to avoid loading data when // the item is selected (data is already loaded). item.setData(LAST_ITEM_LOADED, null); } }
Example #10
Source File: SWTUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell, * <code>null</code> is returned. * * @param widget * the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; }
Example #11
Source File: ConversionProblemsDialog.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void handleMemberSelect(Widget item) { Object data = null; if (item != null) data = item.getData(); if (data instanceof ICompilationUnit) { this.currentCU = (ICompilationUnit) data; problemsPane.setImage(CompareUI.getImage(this.currentCU.getResource())); String pattern = "Problems in file {0}"; String title = MessageFormat.format(pattern, new Object[] { this.currentCU.getResource().getName() }); problemsPane.setText(title); if (problemsTable != null) { problemsTable.setRedraw(false); problemsTable.removeAll(); ConversionResult conversionResult = input.get(currentCU); for (String problem : conversionResult.getProblems()) { addProblemItem(problem); } problemsTable.setRedraw(true); } } else this.currentCU = null; }
Example #12
Source File: BonitaStudioWorkbenchWindowAdvisor.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Register to selection service to update button enablement * Register the Automatic Perspective switch part listener */ @Override public void postWindowOpen() { IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); configurer.addEditorAreaTransfer(FileTransfer.getInstance()); configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( configurer.getWindow())); final MWindow model = ((WorkbenchPage) window.getActivePage()).getWindowModel(); model.getContext().get(EPartService.class).addPartListener(new AutomaticSwitchPerspectivePartListener()); final Object widget = model.getWidget(); if (widget instanceof Shell) { ((Widget) widget).setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_MAIN_SHELL); } // Replace ObjectActionContributorManager with filtered actions CustomObjectActionContributorManager.getManager(); }
Example #13
Source File: ResourcesAndCpuViewTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Simple test to check the CPU Usage view after getting signals. */ @Test public void testSignals() { Widget widget = fResourcesViewBot.getWidget(); assertNotNull(widget); ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace(); assertNotNull(activeTrace); // clear everything TmfCpuSelectedSignal signal = new TmfCpuSelectedSignal(widget, -1, activeTrace); broadcast(signal); assertEquals("Before signal - CPU Usage Title", "CPU Usage", getChartTitle()); assertEquals("Before signal - Thread Table", 12, getTableCount()); fResourcesViewBot.setFocus(); // select cpu 1 signal = new TmfCpuSelectedSignal(widget, 1, activeTrace); broadcast(signal); assertEquals("After signal - CPU Usage Title", "CPU Usage 1", getChartTitle()); assertEquals("After signal - Thread Table", 4, getTableCount()); // select cpu 3 and 1 signal = new TmfCpuSelectedSignal(widget, 3, activeTrace); broadcast(signal); assertEquals("After signal 2 - CPU Usage Title", "CPU Usage 1, 3", getChartTitle()); assertEquals("After signal 2 - Thread Table", 8, getTableCount()); // reset signal = new TmfCpuSelectedSignal(widget, -1, activeTrace); broadcast(signal); assertEquals("After signal clear - CPU Usage Title", "CPU Usage", getChartTitle()); assertEquals("After signal clear - Thread Table", 12, getTableCount()); }
Example #14
Source File: JavaEditorBreadcrumb.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void mapElement(Object element, Widget item) { super.mapElement(element, item); if (item instanceof Item) { fResourceToItemsMapper.addToMap(element, (Item) item); } }
Example #15
Source File: GridTableViewer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected ViewerRow getViewerRowFromItem(Widget item) { if (cachedRow == null) { cachedRow = new GridViewerRow((GridItem) item); } else { cachedRow.setItem((GridItem) item); } return cachedRow; }
Example #16
Source File: FileCoverMsgDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void handleEvent(Event event) { Widget resource = event.widget; if (resource == cancelBtn) { cancelPressed(); }else if (resource == skipBtn) { setReturnCode(SKIP); ALWAYS = alwaysBtn.getSelection(); close(); }else if (resource == overBtn) { setReturnCode(OVER); ALWAYS = alwaysBtn.getSelection(); close(); } }
Example #17
Source File: WizardNewTypeScriptProjectCreationPage.java From typescript.java with MIT License | 5 votes |
@Override protected void updateComponents(Event event) { super.updateComponents(event); Widget item = event != null ? event.item : null; if (item == null || item == useEmbeddedTsRuntimeButton) updateTsRuntimeMode(); }
Example #18
Source File: ToolbarItem.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Parameterized constructor with all fields. * * @param parent Parent widget, should be NebulaToolbar * @param action Selection listener * @param text Text * @param tooltip Tooltip text * @param image Image * @param style Style of item */ public ToolbarItem(Widget parent, SelectionListener action, String text, String tooltip, Image image, int style) { this(parent, style); this.selectionListener = action; this.text = text; this.tooltip = tooltip; this.image = image; this.style = style; ((NebulaToolbar) parent).addItem(this); }
Example #19
Source File: CTableTreeViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @param element * @param index */ protected void createItem(Object parent, Object element, int index) { Class[] classes = (cellProvider != null) ? cellProvider.getCellClasses(element) : null; CTableTreeItem item = null; Widget parentItem = findItem(parent); if(parentItem != null && parentItem instanceof CTableTreeItem) { item = new CTableTreeItem((CTableTreeItem) parentItem, SWT.NONE, index, classes); } if(item == null) item = new CTableTreeItem(getCTableTree(), SWT.NONE, index, classes); updateItem(item, element); }
Example #20
Source File: GridViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
protected ViewerRow getViewerRowFromItem(Widget item) { ViewerRow part = (ViewerRow) item.getData(ViewerRow.ROWPART_KEY); if (part == null) { part = new GridViewerRow(((GridItem) item)); } return part; }
Example #21
Source File: PyContextActivatorViewCreatedObserver.java From Pydev with Eclipse Public License 1.0 | 5 votes |
protected void stop(Widget widget) { if (widget == currWidget) { if (!currWidget.isDisposed()) { currWidget.removeDisposeListener(this); } currWidget = null; changeState(false); } }
Example #22
Source File: GridTableViewer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
private void updateRowHeader(Widget widget) { if (rowHeaderLabelProvider != null) { ViewerCell cell = getViewerRowFromItem(widget).getCell( Integer.MAX_VALUE); rowHeaderLabelProvider.update(cell); } }
Example #23
Source File: StaticHTMLController.java From birt with Eclipse Public License 1.0 | 5 votes |
public Widget getPane( ) { if ( viewer != null ) { return pane; } return null; }
Example #24
Source File: ProblemTreeViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void unmapElement(Object element, Widget item) { if (item instanceof Item) { fResourceToItemsMapper.removeFromMap(element, (Item) item); } super.unmapElement(element, item); }
Example #25
Source File: ProblemTreeViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void mapElement(Object element, Widget item) { super.mapElement(element, item); if (item instanceof Item) { fResourceToItemsMapper.addToMap(element, (Item) item); } }
Example #26
Source File: GridTreeViewer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected ViewerRow getViewerRowFromItem(Widget item) { if (cachedRow == null) { cachedRow = new GridViewerRow((GridItem) item); } else { cachedRow.setItem((GridItem) item); } return cachedRow; }
Example #27
Source File: ProblemTreeViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void unmapElement(Object element, Widget item) { if (item instanceof Item) { fResourceToItemsMapper.removeFromMap(element, (Item) item); } super.unmapElement(element, item); }
Example #28
Source File: CTreeViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
protected Item newItem(Widget parent, int flags, int ix) { CTreeItem item; if (parent instanceof CTreeItem) { item = (CTreeItem) createNewRowPart(getViewerRowFromItem(parent), flags, ix).getItem(); } else { item = (CTreeItem) createNewRowPart(null, flags, ix).getItem(); } return item; }
Example #29
Source File: EnhancedCheckBoxTableViewer.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public boolean getChecked(Object element) { Widget widget = findItem(element); if (widget instanceof TableItem) { return ((TableItem) widget).getChecked(); } return false; }
Example #30
Source File: PackagesViewTreeViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void unmapElement(Object element, Widget item) { if (element instanceof LogicalPackage && item instanceof Item) { LogicalPackage cp= (LogicalPackage) element; IPackageFragment[] fragments= cp.getFragments(); for (int i= 0; i < fragments.length; i++) { IPackageFragment fragment= fragments[i]; fResourceToItemsMapper.removeFromMap((Object)fragment, (Item)item); } } super.unmapElement(element, item); }