org.eclipse.swt.widgets.Item Java Examples
The following examples show how to use
org.eclipse.swt.widgets.Item.
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: ReportItemParametersDialog.java From birt with Eclipse Public License 1.0 | 6 votes |
public void modify( Object element, String property, Object value ) { Object model = element; if ( element instanceof Item ) { model = ( (Item) element ).getData( ); } int index = resultList.indexOf( model ); // remove the ParamBindingHandle if ( index != -1 ) { Object[] pair = (Object[]) model; // DataSetParameterHandle dataHandle = // (DataSetParameterHandle)pair[0]; ParamBindingHandle bindingHandle = (ParamBindingHandle) pair[1]; setValue( bindingHandle, value, (TableItem) element ); } }
Example #2
Source File: ResourceToItemsMapper.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void removeFromMap(Object element, Item item) { IResource resource = getCorrespondingResource(element); if (resource != null) { Object existingMapping = _resourceToItem.get(resource); if (existingMapping == null) { return; } else if (existingMapping instanceof Item) { _resourceToItem.remove(resource); } else { // List List list = (List) existingMapping; list.remove(item); if (list.isEmpty()) { _resourceToItem.remove(list); releaseList(list); } } } }
Example #3
Source File: ResourceToItemsMapper.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public void removeFromMap(Object element, Item item) { IResource resource = getCorrespondingResource(element); if (resource != null) { Object existingMapping = _resourceToItem.get(resource); if (existingMapping == null) { return; } else if (existingMapping instanceof Item) { _resourceToItem.remove(resource); } else { // List List list = (List) existingMapping; list.remove(item); if (list.isEmpty()) { _resourceToItem.remove(list); releaseList(list); } } } }
Example #4
Source File: ResourceToItemsMapper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Removes an element from the map. * @param element The data element * @param item The table or tree item */ public void removeFromMap(Object element, Item item) { IResource resource= getCorrespondingResource(element); if (resource != null) { Object existingMapping= fResourceToItem.get(resource); if (existingMapping == null) { return; } else if (existingMapping instanceof Item) { fResourceToItem.remove(resource); } else { // List @SuppressWarnings("unchecked") List<Item> list= (List<Item>) existingMapping; list.remove(item); if (list.isEmpty()) { fResourceToItem.remove(list); releaseList(list); } } } }
Example #5
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Update the widget at index. * * @param widget * @param index */ private void virtualLazyUpdateWidget(Widget widget, int index) { boolean oldBusy = isBusy(); setBusy(false); try { if (contentProviderIsTreeBased) { TreePath treePath; if (widget instanceof Item) { if (widget.getData() == null) { return; } treePath = getTreePathFromItem((Item) widget); } else { treePath = TreePath.EMPTY; } ((ILazyTreePathContentProvider) getContentProvider()).updateElement(treePath, index); } else { ((ILazyTreeContentProvider) getContentProvider()).updateElement(widget.getData(), index); } } finally { setBusy(oldBusy); } }
Example #6
Source File: GalleryTreeViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @see org.eclipse.jface.viewers.AbstractTreeViewer#getSelection(org.eclipse * .swt.widgets.Control) */ protected Item[] getSelection(Control control) { Item[] selection = ((Gallery) control).getSelection(); if (selection == null) { return new GalleryItem[0]; } List<GalleryItem> notDisposed = new ArrayList<>(selection.length); for (int i = 0; i < selection.length; i++) { if (!selection[i].isDisposed()) { notDisposed.add((GalleryItem) selection[i]); } else { System.out.println("GalleryItem was disposed (ignoring)"); } } selection = notDisposed.toArray(new GalleryItem[notDisposed.size()]); return selection; }
Example #7
Source File: Gallery.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Send SWT.PaintItem for one item. * * @param item * @param index * @param gc * @param x * @param y */ protected void sendPaintItemEvent(Item item, int index, GC gc, int x, int y, int width, int height) { Event e = new Event(); e.item = item; e.type = SWT.PaintItem; e.index = index; // TODO: Does clipping need to be set ? // gc.setClipping(x, y, width, height); e.gc = gc; e.x = x; e.y = y; e.width = width; e.height = height; this.notifyListeners(SWT.PaintItem, e); }
Example #8
Source File: UnitMappingPage.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override public void modify(Object element, String property, Object value) { if (value == null) return; if (element instanceof Item) element = ((Item) element).getData(); if (!(element instanceof UnitMappingEntry)) return; UnitMappingEntry entry = (UnitMappingEntry) element; if (property.equals(FLOW_PROPERTY)) { int val = Integer.parseInt(value.toString()); String[] candidates = getFlowPropertyCandidates(entry.unitName); updateEntry(entry, val, candidates); } else if (property.equals(CONVERSION_FACTOR)) { try { entry.factor = Double.parseDouble(value.toString()); } catch (Exception e) { // do nothing } } checkCompletion(); tableViewer.refresh(); }
Example #9
Source File: PTDirectoryEditor.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @see org.eclipse.nebula.widgets.opal.propertytable.editor.PTChooserEditor#openWindow(org.eclipse.nebula.widgets.opal.propertytable.PTWidget, * org.eclipse.swt.widgets.Item, org.eclipse.nebula.widgets.opal.propertytable.PTProperty) */ @Override protected void openWindow(final PTWidget widget, final Item item, final PTProperty property) { final DirectoryDialog dialog = new DirectoryDialog(widget.getWidget().getShell()); dialog.setMessage(ResourceManager.getLabel(ResourceManager.CHOOSE_DIRECTORY)); final String result = dialog.open(); if (result != null) { if (item instanceof TableItem) { ((TableItem) item).setText(1, result); } else { ((TreeItem) item).setText(1, result); } property.setValue(result); } }
Example #10
Source File: PTColorEditor.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void openWindow(final PTWidget widget, final Item item, final PTProperty property) { final ColorDialog dialog = new ColorDialog(widget.getWidget().getShell()); final RGB result = dialog.open(); if (result != null) { property.setValue(result); final Color bgColor = getBackgroundColor(property); if (bgColor != null) { if (item instanceof TableItem) { ((TableItem) item).setBackground(1, bgColor); } if (item instanceof TreeItem) { ((TreeItem) item).setBackground(1, bgColor); } SWTGraphicUtil.addDisposer(item, bgColor); } if (item instanceof TableItem) { ((TableItem) item).setText(1, getTextFor(property)); } else { ((TreeItem) item).setText(1, getTextFor(property)); } } }
Example #11
Source File: WebSearchPreferencePage.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
@Override public void modify(Object element, String property, Object value) { if (element instanceof Item) { Item item = (Item) element; SearchEntry data = (SearchEntry) item.getData(); if (NAME_PROP.equals(property)) { if (!((String) value).equals(data.getSearchName())) { data.setSearchName((String) value); checkboxTableViewer.update(data, null); setDirty(true); } } else if (URL_PROP.equals(property)) { if (!((String) value).equals(data.getSearchUrl())) { data.setSearchUrl((String) value); checkboxTableViewer.update(data, null); setDirty(true); } } } }
Example #12
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.jface.viewers.AbstractTreeViewer#getChild(org.eclipse.swt.widgets.Widget, int) */ protected Item getChild(Widget widget, int index) { if (widget instanceof CTreeComboItem) { return ((CTreeComboItem) widget).getItem(index); } if (widget instanceof CTreeCombo) { return ((CTreeCombo) widget).getItem(index); } return null; }
Example #13
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.jface.viewers.AbstractTreeViewer#newItem(org.eclipse.swt.widgets.Widget, int, int) */ protected Item newItem(Widget parent, int flags, int ix) { CTreeComboItem item; if (parent instanceof CTreeComboItem) { item = (CTreeComboItem) createNewRowPart(getViewerRowFromItem(parent), flags, ix).getItem(); } else { item = (CTreeComboItem) createNewRowPart(null, flags, ix).getItem(); } return item; }
Example #14
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.jface.viewers.AbstractTreeViewer#createChildren(org.eclipse.swt.widgets.Widget) */ protected void createChildren(Widget widget) { if (contentProviderIsLazy) { Object element = widget.getData(); if (element == null && widget instanceof CTreeComboItem) { // parent has not been materialized virtualMaterializeItem((CTreeComboItem) widget); // try getting the element now that updateElement was called element = widget.getData(); } if (element == null) { // give up because the parent is still not materialized return; } Item[] children = getChildren(widget); if (children.length == 1 && children[0].getData() == null) { // found a dummy node virtualLazyUpdateChildCount(widget, children.length); children = getChildren(widget); } // touch all children to make sure they are materialized for (int i = 0; i < children.length; i++) { if (children[i].getData() == null) { virtualLazyUpdateWidget(widget, i); } } return; } super.createChildren(widget); }
Example #15
Source File: GridTreeViewer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void doUpdateItem(final Item item, Object element) { super.doUpdateItem(item, element); updateRowHeader(item); if(autoPreferredHeight && !item.isDisposed()) ((GridItem)item).pack(); }
Example #16
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.jface.viewers.AbstractTreeViewer#getChildren(org.eclipse.swt.widgets.Widget) */ protected Item[] getChildren(Widget o) { if (o instanceof CTreeComboItem) { return ((CTreeComboItem) o).getItems(); } if (o instanceof CTreeCombo) { return ((CTreeCombo) o).getItems(); } return null; }
Example #17
Source File: PullUpMemberPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void modify(final Object element, final String property, final Object value) { if (!ACTION_PROPERTY.equals(property)) return; final int action= ((Integer) value).intValue(); MemberActionInfo info; if (element instanceof Item) { info= (MemberActionInfo) ((Item) element).getData(); } else info= (MemberActionInfo) element; if (!canModify(info, property)) return; Assert.isTrue(info.isMethodInfo()); info.setAction(action); updateWizardPage(null, true); }
Example #18
Source File: CubeGroupContent.java From birt with Eclipse Public License 1.0 | 5 votes |
public void treeExpanded( TreeEvent e ) { Item item = (Item) e.item; if ( dataBackup != null ) dataBackup.updateExpandedStatus( dataFieldsViewer, item.getData( ) ); }
Example #19
Source File: TableComboViewer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ protected void doResetItem(Item item) { TableItem tableItem = (TableItem) item; int columnCount = Math.max(1, tableCombo.getTable().getColumnCount()); for (int i = 0; i < columnCount; i++) { tableItem.setText(i, ""); //$NON-NLS-1$ if (tableItem.getImage(i) != null) { tableItem.setImage(i, null); } } }
Example #20
Source File: GridTableViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void doResetItem(Item item) { GridItem gridItem = (GridItem) item; int columnCount = Math.max(1, grid.getColumnCount()); for (int i = 0; i < columnCount; i++) { gridItem.setText(i, ""); //$NON-NLS-1$ gridItem.setImage(null); } }
Example #21
Source File: TableComboViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * {@inheritDoc} */ protected void doResetItem(Item item) { if (isWidgetDisposed()) { return; } TableItem tableItem = (TableItem) item; int columnCount = Math.max(1, tableCombo.getTable().getColumnCount()); for (int i = 0; i < columnCount; i++) { tableItem.setText(i, ""); //$NON-NLS-1$ if (tableItem.getImage(i) != null) { tableItem.setImage(i, null); } } }
Example #22
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 #23
Source File: GridViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
protected void internalSetSelection(Item[] items) { if (items != null) { grid.setSelection(new GridItem[0]); } else { GridItem[] tmp = new GridItem[items.length]; System.arraycopy(items, 0, tmp, 0, items.length); grid.setSelection(tmp); } }
Example #24
Source File: TableComboViewer.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void doResetItem(Item item) { TableItem tableItem = (TableItem) item; int columnCount = Math.max(1, tableCombo.getTable().getColumnCount()); for (int i = 0; i < columnCount; i++) { tableItem.setText(i, ""); //$NON-NLS-1$ if (tableItem.getImage(i) != null) { tableItem.setImage(i, null); } } }
Example #25
Source File: GridTreeViewer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void setSelection(List items) { Item[] current = getSelection(getGrid()); // Don't bother resetting the same selection if (isSameSelection(items, current)) { return; } GridItem[] newItems = new GridItem[items.size()]; items.toArray(newItems); getGrid().setSelection(newItems); getGrid().showSelection(); }
Example #26
Source File: GridTreeViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** {@inheritDoc} */ protected void setSelection(List items) { Item[] current = getSelection(getGrid()); // Don't bother resetting the same selection if (isSameSelection(items, current)) { return; } GridItem[] newItems = new GridItem[items.size()]; items.toArray(newItems); getGrid().setSelection(newItems); }
Example #27
Source File: JavaSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Object[] getRootElements(TreeViewer viewer) { Tree t= viewer.getTree(); Item[] roots= t.getItems(); Object[] elements= new Object[roots.length]; for (int i = 0; i < elements.length; i++) { elements[i]= roots[i].getData(); } return elements; }
Example #28
Source File: GridTableViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * {@inheritDoc} */ protected void doResetItem(Item item) { GridItem gridItem = (GridItem) item; int columnCount = Math.max(1, grid.getColumnCount()); for (int i = 0; i < columnCount; i++) { gridItem.setText(i, ""); //$NON-NLS-1$ gridItem.setImage(null); } }
Example #29
Source File: TableComboViewer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ protected void doSetSelection(Item[] items) { if (items != null && items.length > 0) { tableCombo.select(tableCombo.getTable().indexOf((TableItem) items[0])); } else { tableCombo.select(-1); } }
Example #30
Source File: JdtViewerDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the bounds of the given SWT tree or table item. * * @param item the SWT Item * @return the bounds, or <code>null</code> if it is not a known type of item */ protected Rectangle getBounds(Item item) { if (item instanceof TreeItem) { return ((TreeItem) item).getBounds(); } if (item instanceof TableItem) { return ((TableItem) item).getBounds(0); } return null; }