Java Code Examples for org.eclipse.swt.widgets.TreeItem#setChecked()
The following examples show how to use
org.eclipse.swt.widgets.TreeItem#setChecked() .
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: 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 2
Source File: ValidPreferenceCheckedTreeViewer.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Updates the check / gray state of all parent items. * * @param item * the item */ private void updateParentItems(final TreeItem item) { if (item != null) { final Item[] children = getChildren(item); boolean containsChecked = false; boolean containsUnchecked = false; for (final Item element : children) { final TreeItem curr = (TreeItem) element; containsChecked |= curr.getChecked(); containsUnchecked |= (!curr.getChecked() || curr.getGrayed()); } item.setChecked(containsChecked); item.setGrayed(containsChecked && containsUnchecked); updateParentItems(item.getParentItem()); } }
Example 3
Source File: AbstractValidPreferencePage.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Initializes a given TreeViewer "widget" item according to the tree viewer * content provider model. * * @param item * the item to initialize */ private void initialize(final TreeItem item) { boolean containsChecked = false; boolean containsUnchecked = false; if (item.getData() instanceof PreferenceRule) { if (((PreferenceRule) item.getData()).isOptional()) { item.setChecked(!getPreferenceStore().getBoolean(getPreferenceKey(((PreferenceRule) item.getData())))); } else { item.setGrayed(true); item.setChecked(true); } } else { for (final TreeItem child : item.getItems()) { initialize(child); containsChecked |= child.getChecked(); containsUnchecked |= (!child.getChecked() || child.getGrayed()); } item.setChecked(containsChecked); item.setGrayed(containsChecked && containsUnchecked); } }
Example 4
Source File: ContainerCheckedTreeViewer.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Updates the check / gray state of all parent items */ private void updateParentItems(TreeItem item) { if (item != null) { Item[] children= getChildren(item); boolean containsChecked= false; boolean containsUnchecked= false; for (int i= 0; i < children.length; i++) { TreeItem curr= (TreeItem) children[i]; containsChecked |= curr.getChecked(); containsUnchecked |= (!curr.getChecked() || curr.getGrayed()); } item.setChecked(containsChecked); item.setGrayed(containsChecked && containsUnchecked); updateParentItems(item.getParentItem()); } }
Example 5
Source File: VisualizeTxtUMLPage.java From txtUML with Eclipse Public License 1.0 | 6 votes |
private void checkItems(TreeItem item, boolean checked) { item.setGrayed(false); item.setChecked(checked); TreeItem[] items = item.getItems(); for (int i = 0; i < items.length; ++i) { TreeItem child = items[i]; child.setChecked(checked); IType childData = (IType) child.getData(); if (checked) { if (!txtUMLLayout.contains(childData)) { txtUMLLayout.add(childData); } } else { txtUMLLayout.remove(childData); } } }
Example 6
Source File: GroupDialog.java From birt with Eclipse Public License 1.0 | 6 votes |
private void checkItem( TreeItem item ) { if ( item != null ) { item.setChecked( !item.getChecked( ) ); levelViewer.getTree( ).setSelection( item ); if ( item.getChecked( ) ) { if ( !dateTypeSelectedList.contains( item.getData( ) ) ) { dateTypeSelectedList.add( item.getData( ) ); } } else { if ( dateTypeSelectedList.contains( item.getData( ) ) ) dateTypeSelectedList.remove( item.getData( ) ); } checkOKButtonStatus( ); } }
Example 7
Source File: FeedbackDialog.java From Rel with Apache License 2.0 | 6 votes |
protected void checkPath(TreeItem item, boolean checked, boolean grayed) { if (item == null) return; if (grayed) { checked = true; } else { int index = 0; TreeItem[] items = item.getItems(); while (index < items.length) { TreeItem child = items[index]; if (child.getGrayed() || checked != child.getChecked()) { checked = grayed = true; break; } index++; } } item.setChecked(checked); item.setGrayed(grayed); checkPath(item.getParentItem(), checked, grayed); }
Example 8
Source File: LevelViewDialog.java From birt with Eclipse Public License 1.0 | 6 votes |
private void init( ) { if ( dimension != null ) { levelViewer.setInput( dimension ); levelViewer.expandToLevel( dimension.getDefaultHierarchy( ) .getContentCount( IHierarchyModel.LEVELS_PROP ) ); } if ( showLevels == null || showLevels.size( ) == 0 ) return; TreeItem item = levelViewer.getTree( ).getItem( 0 ); while ( item != null ) { LevelHandle level = (LevelHandle) item.getData( ); if ( showLevels.contains( level ) ) { item.setChecked( true ); } if ( item.getItemCount( ) > 0 ) item = item.getItem( 0 ); else item = null; } }
Example 9
Source File: CommitDiffViewer.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void setChecked(Set<FileReference> ids, TreeItem[] items) { for (TreeItem item : items) { DiffNode node = (DiffNode) item.getData(); if (node != null && !node.isModelTypeNode()) { FileReference ref = node.getContent().getDataset().asFileReference(); // null is used as hack to select all if (ids == null || ids.contains(ref)) item.setChecked(true); } setChecked(ids, item.getItems()); } }
Example 10
Source File: XCheckedFilteredTree.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void restoreChecked(TreeItem treeItems[]) { for (TreeItem treeItem : treeItems) { if (treeItem.getChecked() && !checked.contains(treeItem.getData())) { treeItem.setChecked(false); } else if (!treeItem.getChecked() && checked.contains(treeItem.getData())) { treeItem.setChecked(true); } restoreChecked(treeItem.getItems()); } }
Example 11
Source File: IndentGuidePreferencePage.java From IndentGuide with MIT License | 5 votes |
private void checkItems(final TreeItem item, final boolean checked) { item.setChecked(checked); final TreeItem[] items = item.getItems(); for (final TreeItem item2 : items) { checkItems(item2, checked); } }
Example 12
Source File: IndentGuidePreferencePage.java From IndentGuide with MIT License | 5 votes |
private void checkContentType(final TreeItem item, final String[] types) { for (final TreeItem child : item.getItems()) { checkContentType(child, types); } final String id = (String) item.getData(); for (final String type : types) { if (id.equals(type)) { item.setChecked(true); break; } } }
Example 13
Source File: FeedbackDialog.java From Rel with Apache License 2.0 | 5 votes |
protected void checkItems(TreeItem item, boolean checked) { item.setGrayed(false); item.setChecked(checked); TreeItem[] items = item.getItems(); for (int i = 0; i < items.length; i++) { checkItems(items[i], checked); } }
Example 14
Source File: VisualizeTxtUMLPage.java From txtUML with Eclipse Public License 1.0 | 5 votes |
private void updateParentCheck(TreeItem parentItem) { boolean isAnyChecked = Stream.of(parentItem.getItems()).anyMatch(child -> child.getChecked()); boolean isAllChecked = Stream.of(parentItem.getItems()).allMatch(child -> child.getChecked()); if (isAllChecked) { parentItem.setGrayed(false); parentItem.setChecked(true); } else if (isAnyChecked) { parentItem.setChecked(true); parentItem.setGrayed(true); } else { parentItem.setGrayed(false); parentItem.setChecked(false); } }
Example 15
Source File: ContainerCheckedTreeViewer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Updates the check state of all created children */ private void updateChildrenItems(TreeItem parent) { Item[] children= getChildren(parent); boolean state= parent.getChecked(); for (int i= 0; i < children.length; i++) { TreeItem curr= (TreeItem) children[i]; if (curr.getData() != null && ((curr.getChecked() != state) || curr.getGrayed())) { curr.setChecked(state); curr.setGrayed(false); updateChildrenItems(curr); } } }
Example 16
Source File: SelectVisibleColumnDialog.java From logbook with MIT License | 5 votes |
/** * Create contents of the dialog. */ private void createContents() { this.shell = new Shell(this.getParent(), SWT.SHELL_TRIM | SWT.PRIMARY_MODAL); this.shell.setSize(300, 275); this.shell.setText("列の表示非表示"); this.shell.setLayout(new FillLayout(SWT.HORIZONTAL)); // ヘッダー String[] header = Stream.of(this.table.getColumns()).map(c -> c.getText()).toArray(String[]::new); // カラム設定を取得 boolean[] visibles = AppConfig.get().getVisibleColumnMap().get(this.clazz.getName()); if ((visibles == null) || (visibles.length != header.length)) { visibles = new boolean[header.length]; Arrays.fill(visibles, true); AppConfig.get().getVisibleColumnMap().put(this.clazz.getName(), visibles); } Tree tree = new Tree(this.shell, SWT.BORDER | SWT.CHECK); for (int i = 1; i < header.length; i++) { TreeItem column = new TreeItem(tree, SWT.CHECK); column.setText(header[i]); column.setChecked(visibles[i]); column.setExpanded(true); } this.shell.addShellListener(new TreeShellAdapter(tree, visibles)); }
Example 17
Source File: GroupDialog.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void initDialog( ) { if ( hierarchy != null ) { nameText.setText( hierarchy.getContainer( ).getName( ) ); } else { DimensionHandle dimension = DesignElementFactory.getInstance( ) .newTabularDimension( null ); nameText.setText( dimension.getName( ) ); } if ( dimension != null ) { if ( isTimeType( dimension ) ) { dateButton.setSelection( true ); handleButtonSelection( dateButton ); } else { regularButton.setSelection( true ); handleButtonSelection( regularButton ); } } else { dateButton.setSelection( true ); handleButtonSelection( dateButton ); } if ( dimension != null ) { WidgetUtil.setExcludeGridData( regularButton, true ); WidgetUtil.setExcludeGridData( dateButton, true ); } if ( dimension != null && !isTimeType( dimension ) ) levelViewer.getTree( ).setVisible( false ); levelViewer.setInput( getDateTypeNames( getLevelTypesByDateType( ) ) ); levelViewer.expandAll( ); if ( levelViewer.getTree( ).getItemCount( ) > 0 ) { TreeItem topNode = levelViewer.getTree( ).getItem( 0 ); do { if ( levelList.contains( topNode.getData( ) ) ) topNode.setChecked( true ); topNode = topNode.getItem( 0 ); } while ( topNode.getItemCount( ) > 0 ); if ( levelList.contains( topNode.getData( ) ) ) topNode.setChecked( true ); } checkOKButtonStatus( ); }
Example 18
Source File: FeedbackDialog.java From Rel with Apache License 2.0 | 4 votes |
private void setupTreeItem(TreeItem item, String text) { item.setText(text); item.setChecked(true); item.setExpanded(true); }