Java Code Examples for org.eclipse.swt.widgets.TreeItem#getItem()

The following examples show how to use org.eclipse.swt.widgets.TreeItem#getItem() . 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: GodClass.java    From JDeodorant with MIT License 6 votes vote down vote up
private void setSelectedLineWithinCandidateGroup(Tree tree, TreeItem candidateGroupTreeItem, CandidateRefactoring candidateRefactoring) {
	for(int i=0; i<candidateGroupTreeItem.getItemCount(); i++){
		TreeItem conceptTreeItem = candidateGroupTreeItem.getItem(i);
		ExtractedConcept concept = (ExtractedConcept)conceptTreeItem.getData();
		if(concept.getConceptClusters().contains(candidateRefactoring)) {
			conceptTreeItem.setExpanded(true);
			treeViewer.refresh();
			for(int j=0; j<conceptTreeItem.getItemCount(); j++) {
				TreeItem candidateTreeItem = conceptTreeItem.getItem(j);
				CandidateRefactoring candidate = (CandidateRefactoring)candidateTreeItem.getData();
				if(candidate.equals(candidateRefactoring)) {
					tree.setSelection(candidateTreeItem);
					treeViewer.refresh();
					break;
				}
			}
			break;
		}
	}
}
 
Example 2
Source File: LevelViewDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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 3
Source File: ReportPropertySheetPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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 4
Source File: ReportPropertySheetPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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 5
Source File: AdvancePropertyDescriptor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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 6
Source File: AdvancePropertyDescriptor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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 7
Source File: ResourcePickerDialog.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEvent(Event event) {
  if (event.widget == resourcesUI &&
      event.type == SWT.Expand) {
    TreeItem expandedNode = (TreeItem) event.item;
    TreeItem maybeDummy = expandedNode.getItem(0);
    if (null == maybeDummy.getData()) {
      maybeDummy.dispose();
      IResource parentResource = (IResource)expandedNode.getData();
      try {
        populate(expandedNode, ((IContainer)parentResource).members());
      } catch (CoreException e) {
        throw new InternalErrorCDE("unhandled exception", e);
      }
    }
  } else if (event.widget == resourcesUI && event.type == SWT.Selection) {
    copyValuesFromGUI();
  }
  super.handleEvent(event);
}
 
Example 8
Source File: GroupDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private TreeItem getItem( String text )
{
	TreeItem topNode = levelViewer.getTree( ).getItem( 0 );
	do
	{
		if ( text.equals( topNode.getData( ) ) )
			return topNode;
		topNode = topNode.getItem( 0 );
	} while ( topNode.getItemCount( ) > 0 );
	if ( text.equals( topNode.getData( ) ) )
		return topNode;
	else
		return null;
}
 
Example 9
Source File: ExpressionTreeSupport.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void restoreSelectedMemento( TreeItem root,
		MementoElement[] selectedPath )
{
	if ( selectedPath.length <= 0 )
		return;

	for ( int i = 0; i < selectedPath.length; i++ )
	{
		MementoElement element = selectedPath[i];
		if ( root.getText( ).equals( element.getValue( ) ) )
		{
			continue;
		}
		boolean flag = false;
		for ( int j = 0; j < root.getItemCount( ); j++ )
		{
			if ( root.getItem( j ).getText( ).equals( element.getValue( ) ) )
			{
				root = root.getItem( j );
				flag = true;
				break;
			}
		}
		if ( !flag )
			return;
	}
	tree.setSelection( root );
}
 
Example 10
Source File: ExpressionTreeSupport.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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: GroupDialog.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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( );
}