Java Code Examples for org.eclipse.swt.SWT#VIRTUAL
The following examples show how to use
org.eclipse.swt.SWT#VIRTUAL .
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: CheckNodeTreeView.java From depan with Apache License 2.0 | 6 votes |
@Override protected CheckboxTreeViewer createTreeViewer(Composite parent) { int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL; CheckboxTreeViewer result = new CheckboxTreeViewer(parent, style); result.setLabelProvider(new WorkbenchLabelProvider()); result.setContentProvider(new BaseWorkbenchContentProvider()); result.setComparator(new NodeWrapperTreeSorter()); result.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { if (recursiveTreeSelect) { tree.setSubtreeChecked(event.getElement(), event.getChecked()); } } }); tree = result; return result; }
Example 2
Source File: Trees.java From olca-app with Mozilla Public License 2.0 | 6 votes |
public static TreeViewer createViewer( Composite parent, String[] headers, IBaseLabelProvider label) { TreeViewer viewer = new TreeViewer(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI); Tree tree = viewer.getTree(); boolean hasColumns = headers != null && headers.length > 0; tree.setLinesVisible(hasColumns); tree.setHeaderVisible(hasColumns); if (hasColumns) { createColumns(viewer, headers, label); } if (label != null) { viewer.setLabelProvider(label); } GridData data = UI.gridData(tree, true, true); data.minimumHeight = 120; Point p = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT); data.heightHint = p.y < 120 ? 120 : p.y; return viewer; }
Example 3
Source File: AbstractComboViewer.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override protected TableComboViewer createViewer(Composite parent) { TableCombo combo = new TableCombo(parent, SWT.READ_ONLY | SWT.BORDER | SWT.VIRTUAL); UI.gridData(combo, true, false).widthHint = 350; if (useColumnHeaders()) { if (useColumnBounds()) combo.defineColumns(getColumnHeaders(), getColumnBounds()); else combo.defineColumns(getColumnHeaders()); combo.setShowTableHeader(true); combo.setShowTableLines(true); } combo.setDisplayColumnIndex(getDisplayColumn()); TableComboViewer viewer = new TableComboViewer(combo); viewer.setContentProvider(ArrayContentProvider.getInstance()); viewer.setLabelProvider(getLabelProvider()); viewer.setComparator(getComparator()); return viewer; }
Example 4
Source File: SimpleWidgetProvider.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public StructuredViewer createViewer(Composite parent){ switch (type) { case TYPE_TREE: return new TreeViewer(parent, style); case TYPE_LIST: return new ListViewer(parent, style); case TYPE_TABLE: return new TableViewer(parent, style); case TYPE_LAZYLIST: TableViewer ret = new TableViewer(parent, style | SWT.VIRTUAL); // ret.getTable().setItemCount(0); return ret; } return null; }
Example 5
Source File: Tables.java From olca-app with Mozilla Public License 2.0 | 6 votes |
/** * Creates a default table viewer with the given properties. The properties are * also used to create columns where each column label is the respective * property of this column. The viewer is configured in the following way: * <ul> * <li>content provider = {@link ArrayContentProvider} * <li>lines and header are visible * <li>grid data with horizontal and vertical fill * */ public static TableViewer createViewer(Composite parent, String[] properties, IBaseLabelProvider labelProvider) { TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI); viewer.setContentProvider(new ArrayContentProvider()); boolean hasColumns = properties != null && properties.length > 0; Table table = viewer.getTable(); table.setLinesVisible(hasColumns); table.setHeaderVisible(hasColumns); if (hasColumns) { createColumns(viewer, properties, labelProvider); } if (labelProvider != null) { viewer.setLabelProvider(labelProvider); } GridData data = UI.gridData(table, true, true); data.minimumHeight = 120; // workaround for this bug: // https://bugs.eclipse.org/bugs/show_bug.cgi?id=215997 Point p = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT); data.heightHint = p.y < 120 ? 120 : p.y; return viewer; }
Example 6
Source File: GridItem_Test.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Test public void testGridItemCreation_onVirtual_doesNotResolveItem() { grid = new Grid( shell, SWT.VIRTUAL ); grid.setItemCount( 1 ); GridItem item = grid.getItem( 0 ); assertFalse( /* item.isResolved() */ true ); }
Example 7
Source File: MOOSETreeCompositeView.java From ice with Eclipse Public License 1.0 | 5 votes |
/** * Overrides the default viewer to add an additional feature: When a parent * node is unchecked, all of its child nodes are unchecked. */ @Override protected TreeViewer createViewer(Composite parent) { TreeViewer treeViewer = null; if (parent != null) { // Initialize the TreeViewer. Note: We create a CheckboxTreeViewer! final CheckboxTreeViewer checkboxTreeViewer = new CheckboxTreeViewer( parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); treeViewer = checkboxTreeViewer; // Set and configure the content and label providers treeViewer.setContentProvider(new TreeCompositeContentProvider( this, parentMap)); treeViewer.setLabelProvider(new TreeCompositeLabelProvider()); // Add a provider to tell the viewer when elements should be // checked. This is NOT default behavior. MOOSETreeCheckStateManager checkManager; checkManager = new MOOSETreeCheckStateManager(); checkboxTreeViewer.setCheckStateProvider(checkManager); checkboxTreeViewer.addCheckStateListener(checkManager); } return treeViewer; }
Example 8
Source File: InterfacesComponentProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new interfaces component inside the parent composite using the given model. * * @param interfacesContainingModel * A interface containing model * @param container * The component container */ public InterfacesComponent(InterfacesContainingModel interfacesContainingModel, WizardComponentContainer container) { super(container); this.model = interfacesContainingModel; Composite parent = getParentComposite(); Label interfacesLabel = new Label(parent, SWT.NONE); GridData interfacesLabelGridData = fillLabelDefaults(); interfacesLabelGridData.verticalAlignment = SWT.TOP; interfacesLabel.setLayoutData(interfacesLabelGridData); interfacesLabel.setText("Interfaces:"); interfacesTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL); interfacesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite interfacesButtonsComposite = new Composite(parent, SWT.NONE); interfacesButtonsComposite.setLayoutData(GridDataFactory.fillDefaults().create()); interfacesButtonsComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).create()); interfacesAddButton = new Button(interfacesButtonsComposite, SWT.NONE); interfacesAddButton.setText("Add..."); interfacesAddButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); interfacesRemoveButton = new Button(interfacesButtonsComposite, SWT.NONE); interfacesRemoveButton.setText("Remove"); interfacesRemoveButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); setupBindings(); }
Example 9
Source File: GridItem_Test.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Test public void testHandleVirtual_Twice() { grid = new Grid( shell, SWT.VIRTUAL ); GridItem[] items = createGridItems( grid, 3, 3 ); grid.clearAll( true ); grid.addListener( SWT.SetData, new LoggingListener() ); items[ 2 ].getText(); items[ 2 ].getText(); assertEquals( 1, eventLog.size() ); }
Example 10
Source File: GridItem_Test.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Test public void testHandleVirtual_RootItem() { grid = new Grid( shell, SWT.VIRTUAL ); GridItem[] items = createGridItems( grid, 3, 3 ); grid.clearAll( true ); grid.addListener( SWT.SetData, new LoggingListener() ); items[ 4 ].getText(); assertEquals( 1, eventLog.size() ); Event event = eventLog.get( 0 ); assertSame( grid, event.widget ); assertSame( items[ 4 ], event.item ); assertEquals( 1, event.index ); }
Example 11
Source File: GridItem_Test.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Test public void testSetText_marksItemCached() { grid = new Grid( shell, SWT.VIRTUAL ); GridItem item = new GridItem( grid, SWT.NONE ); item.setText( "foo" ); assertTrue( /* item.isCached() */ false ); }
Example 12
Source File: ModelSelectionPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void createViewer(Composite composite) { viewer = new CheckboxTreeViewer(composite, SWT.VIRTUAL | SWT.MULTI | SWT.BORDER); viewer.setUseHashlookup(true); viewer.getTree().setLayoutData( new GridData(SWT.FILL, SWT.FILL, true, true)); viewer.setContentProvider(new NavigationContentProvider()); viewer.setLabelProvider(new NavigationLabelProvider(false)); viewer.setComparator(new NavigationComparator()); viewer.addFilter(new ModelTypeFilter(types)); viewer.addCheckStateListener(new ModelSelectionState(this, viewer)); registerInputHandler(composite); ColumnViewerToolTipSupport.enableFor(viewer); }
Example 13
Source File: GridItem.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void handleVirtual() { if ((getParent().getStyle() & SWT.VIRTUAL) != 0 && !hasSetData) { hasSetData = true; Event event = new Event(); event.item = this; if (parentItem == null) { event.index = getRowIndex(); } else { event.index = parentItem.indexOf(this); } getParent().notifyListeners(SWT.SetData, event); } }
Example 14
Source File: GalleryItem.java From nebula with Eclipse Public License 2.0 | 5 votes |
protected GalleryItem(Gallery parent, int style, int index, boolean create) { super(parent, style); this.parent = parent; this.parentItem = null; if ((parent.getStyle() & SWT.VIRTUAL) > 0) { virtualGallery = true; } if (create) parent.addItem(this, index); }
Example 15
Source File: GalleryItem.java From nebula with Eclipse Public License 2.0 | 5 votes |
protected GalleryItem(GalleryItem parent, int style, int index, boolean create) { super(parent, style); this.parent = parent.parent; this.parentItem = parent; if ((parent.getStyle() & SWT.VIRTUAL) > 0) { virtualGallery = true; } if (create) parent.addItem(this, index); }
Example 16
Source File: ModelCheckBoxTree.java From olca-app with Mozilla Public License 2.0 | 5 votes |
public void drawOn(Composite comp, FormToolkit tk) { tree = new CheckboxTreeViewer(comp, SWT.VIRTUAL | SWT.MULTI | SWT.BORDER); tree.setUseHashlookup(true); tree.setContentProvider(new NavigationContentProvider()); tree.setLabelProvider(new NavigationLabelProvider(false)); tree.setComparator(new NavigationComparator()); tree.addFilter(new ModelTypeFilter(types)); tree.addCheckStateListener(this); ColumnViewerToolTipSupport.enableFor(tree); if (tk != null) { tk.adapt(tree.getTree()); } // compute a height hint GridData data = UI.gridData(tree.getTree(), true, true); data.minimumHeight = 120; Point p = comp.computeSize(SWT.DEFAULT, SWT.DEFAULT); data.heightHint = p.y < 120 ? 120 : p.y; if (types == null || types.length == 0) return; if (types.length == 1) { tree.setInput(Navigator.findElement(types[0])); } else { List<INavigationElement<?>> elems = Arrays.stream(types) .map(type -> Navigator.findElement(type)) .filter(elem -> !elem.getChildren().isEmpty()) .collect(Collectors.toList()); tree.setInput(elems); } tree.expandToLevel(2); }
Example 17
Source File: SnippetVirtual.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Gallery gallery = new Gallery(shell, SWT.V_SCROLL | SWT.VIRTUAL); // Renderers DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer(); gr.setItemSize(64, 64); gr.setMinMargin(3); DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer(); gallery.setGroupRenderer(gr); gallery.setItemRenderer(ir); gallery.setVirtualGroups(true); gallery.addListener(SWT.SetData, new Listener() { public void handleEvent(Event event) { GalleryItem item = (GalleryItem) event.item; int index; if (item.getParentItem() != null) { index = item.getParentItem().indexOf(item); item.setItemCount(0); } else { index = gallery.indexOf(item); item.setItemCount(100); } System.out.println( "setData index " + index); //$NON-NLS-1$ // Your image here // item.setImage(eclipseImage); item.setText("Item " + index); //$NON-NLS-1$ } }); gallery.setItemCount(100); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example 18
Source File: FlowRefDialog.java From olca-app with Mozilla Public License 2.0 | 4 votes |
@Override protected void createFormContent(IManagedForm mform) { FormToolkit tk = mform.getToolkit(); Composite body = UI.formBody(mform.getForm(), tk); UI.gridLayout(body, 1, 10, 10); Composite filterComp = tk.createComposite(body); UI.gridLayout(filterComp, 2, 10, 0); UI.gridData(filterComp, true, false); Label filterLabel = UI.formLabel(filterComp, tk, M.Filter); filterLabel.setFont(UI.boldFont()); Text filterText = UI.formText(filterComp, SWT.SEARCH); UI.gridData(filterText, true, false); TreeViewer viewer = new TreeViewer(body, SWT.BORDER | SWT.SINGLE | SWT.VIRTUAL); UI.gridData(viewer.getControl(), true, true); viewer.setContentProvider(tree); viewer.setLabelProvider(tree); viewer.setFilters(new Filter(filterText, viewer)); viewer.setInput(tree); viewer.addSelectionChangedListener(e -> { Object obj = Viewers.getFirst(e.getSelection()); if (obj instanceof FlowRef) { selected = (FlowRef) obj; } else { selected = null; } Button ok = getButton(IDialogConstants.OK_ID); ok.setEnabled(selected != null); }); // handle double clicks viewer.addDoubleClickListener(e -> { IStructuredSelection s = viewer.getStructuredSelection(); if (s == null || s.isEmpty()) return; Object elem = s.getFirstElement(); // double click on a flow if (elem instanceof FlowRef) { selected = (FlowRef) elem; okPressed(); return; } // double click on a category if (!tree.hasChildren(elem)) return; selected = null; getButton(IDialogConstants.OK_ID).setEnabled(false); if (viewer.getExpandedState(elem)) { viewer.collapseToLevel(elem, AbstractTreeViewer.ALL_LEVELS); } else { viewer.expandToLevel(elem, 1); } }); }
Example 19
Source File: CheckboxRepositoryTreeViewer.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public CheckboxRepositoryTreeViewer(final Composite parent) { super(parent, SWT.VIRTUAL | SWT.BORDER | SWT.V_SCROLL); initialize(); }
Example 20
Source File: CollapsibleButtons.java From nebula with Eclipse Public License 2.0 | 4 votes |
private static int checkStyle(int style) { int mask = SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.MULTI | SWT.NO_FOCUS | SWT.CHECK | SWT.VIRTUAL; int newStyle = style & mask; newStyle |= SWT.NO_BACKGROUND; return newStyle; }