Java Code Examples for org.eclipse.swt.widgets.TreeItem#getExpanded()
The following examples show how to use
org.eclipse.swt.widgets.TreeItem#getExpanded() .
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: NavTree.java From birt with Eclipse Public License 1.0 | 6 votes |
private TreeItem findAndAdd( String sValue, TreeItem tiRoot, String displayName ) { TreeItem tiTmp = findDirectChildren( tiRoot, sValue ); if ( tiTmp != null ) { return tiTmp; } if ( tiRoot != null ) { tiTmp = add( tiRoot, sValue, displayName ); if ( !tiRoot.getExpanded( ) ) { tiRoot.setExpanded( true ); } } else { tiTmp = add( null, sValue, displayName ); } return tiTmp; }
Example 2
Source File: AdvancePropertyDescriptor.java From birt with Eclipse Public License 1.0 | 6 votes |
private void restoreExpandedMemento( TreeItem root, MementoElement memento ) { if ( memento.getKey( ).equals( root.getText( ) ) ) { if ( !root.getExpanded( ) ) viewer.createChildren( root ); if ( root.getItemCount( ) > 0 ) { if ( !root.getExpanded( ) ) root.setExpanded( true ); MementoElement[] children = memento.getChildren( ); for ( int i = 0; i < children.length; i++ ) { MementoElement child = children[i]; int index = ( (Integer) child.getValue( ) ).intValue( ); if ( index >= 0 && index < root.getItemCount( ) ) { TreeItem item = root.getItem( index ); restoreExpandedMemento( item, child ); } } } } }
Example 3
Source File: XViewerTreeReport.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void addRow(TreeItem item, List<String[]> rowData, IXViewerLabelProvider labelProv, List<XViewerColumn> showCols, int level) throws XViewerException { List<String> cellData = new ArrayList<>(showCols.size()); boolean firstCell = true; for (XViewerColumn xCol : showCols) { StringBuilder str = new StringBuilder(); if (firstCell) { for (int y = 1; y < level; y++) { str.append("__INSERT_TAB_HERE__"); //$NON-NLS-1$ } firstCell = false; } str.append(labelProv.getColumnText(item.getData(), xColToColumnIndex.get(xCol))); String html = HtmlUtil.textToHtml(str.toString()); html = html.replaceAll("__INSERT_TAB_HERE__", " "); //$NON-NLS-1$ //$NON-NLS-2$ cellData.add(html); } rowData.add(cellData.toArray(new String[cellData.size()])); if (item.getExpanded()) { for (TreeItem i : item.getItems()) { addRow(i, rowData, labelProv, showCols, level + 1); } } }
Example 4
Source File: AdvancePropertyDescriptor.java From birt with Eclipse Public License 1.0 | 6 votes |
private void restoreSelectedMemento( TreeItem root, MementoElement[] selectedPath ) { if ( selectedPath.length <= 1 ) return; for ( int i = 1; i < selectedPath.length; i++ ) { MementoElement element = selectedPath[i]; if ( !root.getExpanded( ) ) { viewer.createChildren( root ); root.setExpanded( true ); } if ( root.getItemCount( ) > ( (Integer) element.getValue( ) ).intValue( ) ) { root = root.getItem( ( (Integer) element.getValue( ) ).intValue( ) ); } else return; } viewer.getTree( ).setSelection( root ); }
Example 5
Source File: ReportPropertySheetPage.java From birt with Eclipse Public License 1.0 | 6 votes |
private void restoreExpandedMemento( TreeItem root, MementoElement memento ) { if ( memento.getKey( ).equals( root.getText( ) ) ) { if ( !root.getExpanded( ) ) viewer.createChildren( root ); if ( root.getItemCount( ) > 0 ) { if ( !root.getExpanded( ) ) root.setExpanded( true ); MementoElement[] children = memento.getChildren( ); for ( int i = 0; i < children.length; i++ ) { MementoElement child = children[i]; int index = ( (Integer) child.getValue( ) ).intValue( ); if ( index >= 0 && index < root.getItemCount( ) ) { TreeItem item = root.getItem( index ); restoreExpandedMemento( item, child ); } } } } }
Example 6
Source File: ReportPropertySheetPage.java From birt with Eclipse Public License 1.0 | 6 votes |
private void restoreSelectedMemento( TreeItem root, MementoElement[] selectedPath ) { if ( selectedPath.length <= 1 ) return; for ( int i = 1; i < selectedPath.length; i++ ) { MementoElement element = selectedPath[i]; if ( !root.getExpanded( ) ) { viewer.createChildren( root ); root.setExpanded( true ); } if ( root.getItemCount( ) > ( (Integer) element.getValue( ) ).intValue( ) ) { root = root.getItem( ( (Integer) element.getValue( ) ).intValue( ) ); } else return; } viewer.getTree( ).setSelection( root ); }
Example 7
Source File: CopyCallHierarchyAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Adds the specified {@link TreeItem}'s text to the StringBuffer. * * @param item the tree item * @param indent the indent size * @param buf the string buffer */ private void addCalls(TreeItem item, int indent, StringBuffer buf) { for (int i= 0; i < indent; i++) { buf.append(INDENTATION); } buf.append(TextProcessor.deprocess(item.getText())); buf.append('\n'); if (item.getExpanded()) { TreeItem[] items= item.getItems(); for (int i= 0; i < items.length; i++) { addCalls(items[i], indent + 1, buf); } } }
Example 8
Source File: SelectAllAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void collectExpandedAndVisible(TreeItem[] items, List<TreeItem> result) { for (int i= 0; i < items.length; i++) { TreeItem item= items[i]; if (item.getData() != null) { result.add(item); if (item.getExpanded()) { collectExpandedAndVisible(item.getItems(), result); } } } }
Example 9
Source File: MainShell.java From RepDev with GNU General Public License v3.0 | 5 votes |
/** * Expands or Collapses the item passed to it on the tree * * @param item */ private void doTree(TreeItem item) { item.setExpanded(!item.getExpanded()); if (item.getExpanded()) { Event e = new Event(); e.item = item; tree.notifyListeners(SWT.Expand, e); } }
Example 10
Source File: ExpressionTreeSupport.java From birt with Eclipse Public License 1.0 | 5 votes |
private void restoreExpandedMemento( TreeItem root, MementoElement memento ) { if ( memento.getKey( ).equals( root.getText( ) ) ) { if ( root.getItemCount( ) > 0 ) { if ( !root.getExpanded( ) ) root.setExpanded( true ); MementoElement[] children = memento.getChildren( ); for ( int i = 0; i < children.length; i++ ) { MementoElement child = children[i]; String key = child.getValue( ).toString( ); for ( int j = 0; j < root.getItemCount( ); j++ ) { TreeItem item = root.getItem( j ); if ( item.getText( ).equals( key ) ) { restoreExpandedMemento( item, child ); break; } } } } } }
Example 11
Source File: LapseView.java From lapse-plus with GNU General Public License v3.0 | 5 votes |
private void addCalls(TreeItem item, int indent, StringBuffer buf) { for (int i= 0; i < indent; i++) { buf.append(INDENTATION); } buf.append(item.getText()); buf.append('\n'); if (item.getExpanded()) { TreeItem[] items= item.getItems(); for (int i= 0; i < items.length; i++) { addCalls(items[i], indent + 1, buf); } } }
Example 12
Source File: TreeThemer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected TreeItem getLastItemRecursively(TreeItem lastItem) { if (lastItem == null) { return null; } int itemCount = lastItem.getItemCount(); if (itemCount == 0 || !lastItem.getExpanded()) { return lastItem; } return getLastItemRecursively(lastItem.getItem(itemCount - 1)); }
Example 13
Source File: ListDialogSortableFiltered.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void getVisibleItems(List<TreeItem> toReturn, TreeItem items[]) { for (TreeItem item : items) { toReturn.add(item); if (item.getExpanded()) { getVisibleItems(toReturn, item.getItems()); } } }
Example 14
Source File: XViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void getVisibleItems(List<TreeItem> toReturn, TreeItem items[]) { for (TreeItem item : items) { toReturn.add(item); if (item.getExpanded()) { getVisibleItems(toReturn, item.getItems()); } } }
Example 15
Source File: XViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
public int getVisibleItemCount() { TreeItem[] items = getTree().getItems(); int cnt = items.length; for (TreeItem item : items) { if (item.getExpanded()) { cnt += getVisibleItemCount(item.getItems()); } } return cnt; }
Example 16
Source File: XViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
public int getVisibleItemCount(TreeItem items[]) { int cnt = items.length; for (TreeItem item : items) { if (item.getExpanded()) { cnt += getVisibleItemCount(item.getItems()); } } return cnt; }
Example 17
Source File: FilteredElementTreeSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected WorkbenchJob doCreateRefreshJob() { return new WorkbenchJob("Refresh Filter") {//$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { if (treeViewer.getControl().isDisposed()) { return Status.CANCEL_STATUS; } String text= getFilterString(); if (text == null) { return Status.OK_STATUS; } boolean initial= initialText != null && initialText.equals(text); if (initial) { getPatternFilter().setPattern(null); } else { getPatternFilter().setPattern(text); } Control redrawFalseControl= treeComposite != null ? treeComposite : treeViewer.getControl(); try { // don't want the user to see updates that will be made to // the tree // we are setting redraw(false) on the composite to avoid // dancing scrollbar redrawFalseControl.setRedraw(false); if (!narrowingDown) { // collapse all TreeItem[] is= treeViewer.getTree().getItems(); for (int i= 0; i < is.length; i++) { TreeItem item= is[i]; if (item.getExpanded()) { treeViewer.setExpandedState(item.getData(), false); } } } treeViewer.refresh(true); updateToolbar(text.length() > 0 && !initial); } finally { // done updating the tree - set redraw back to true TreeItem[] items= getViewer().getTree().getItems(); if (items.length > 0 && getViewer().getTree().getSelectionCount() == 0) { treeViewer.getTree().setTopItem(items[0]); } redrawFalseControl.setRedraw(true); } return Status.OK_STATUS; } }; }
Example 18
Source File: ViewerUnti.java From birt with Eclipse Public License 1.0 | 4 votes |
private static void viewTree( TreeItem item, TreeItem root ) { if ( item.getItemCount( ) != 0 ) { if ( item == root ) { System.err.println( ); } if ( item.getExpanded( ) ) { TreeItem[] ti = item.getItems( ); System.err.println( "-" //$NON-NLS-1$ + item.getText( ) + "(" + ti.length + ")" ); //$NON-NLS-1$ //$NON-NLS-2$ for ( int i = 0; i < ti.length; i++ ) { String out = ""; //$NON-NLS-1$ TreeItem parent = item; while ( parent != root ) { TreeItem[] tp = parent.getParentItem( ).getItems( ); if ( parent != tp[tp.length - 1] ) { out = " \u2502" + out; //$NON-NLS-1$ } else { out = " " + out; //$NON-NLS-1$ } parent = parent.getParentItem( ); } if ( i == item.getItemCount( ) - 1 ) { out += " \u2514"; //$NON-NLS-1$ } else { out += " \u251C"; //$NON-NLS-1$ } System.err.print( out ); viewTree( ti[i], root ); } } else System.err.println( "+" + item.getText( ) + "(?)" ); //$NON-NLS-1$ //$NON-NLS-2$ } else System.err.println( item.getText( ) ); }
Example 19
Source File: TreeThemer.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private void addCustomTreeControlDrawing() { // Hack to overdraw the native tree expand/collapse controls and use custom plus/minus box. if (isMacOSX || isUbuntu || controlIsDisposed()) { return; } // FIXME The native control/arrow still shows through on OpenSuSE 11.4 final Tree tree = getTree(); customDrawingListener = new Listener() { public void handleEvent(Event event) { if (!invasiveThemesEnabled()) { return; } GC gc = event.gc; Widget item = event.item; boolean isExpanded = false; boolean draw = false; if (item instanceof TreeItem) { TreeItem tItem = (TreeItem) item; isExpanded = tItem.getExpanded(); draw = tItem.getItemCount() > 0; } if (!draw) { return; } final int width = 10; final int height = 12; final int x = event.x - 16; final int y = event.y + 4; Color oldBackground = gc.getBackground(); gc.setBackground(getBackground()); // wipe out the native control gc.fillRectangle(x, y, width + 1, height - 1); // +1 and -1 because of hovering selecting on windows // vista // draw a plus/minus based on expansion! gc.setBackground(getForeground()); // draw surrounding box (with alpha so that it doesn't get too strong). gc.setAlpha(195); gc.drawRectangle(x + 1, y + 1, width - 2, width - 2); // make it smaller than the area erased gc.setAlpha(255); // draw '-' int halfWidth = width >> 1; gc.drawLine(x + 3, y + halfWidth, x + 7, y + halfWidth); if (!isExpanded) { // draw '|' to make it a plus gc.drawLine(x + halfWidth, y + 3, x + halfWidth, y + 7); } gc.setBackground(oldBackground); event.detail &= ~SWT.BACKGROUND; } }; tree.addListener(SWT.PaintItem, customDrawingListener); }