Java Code Examples for org.eclipse.jface.viewers.TreeViewer#getInput()

The following examples show how to use org.eclipse.jface.viewers.TreeViewer#getInput() . 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: LibraryNodeProvider.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void createContextMenu( TreeViewer sourceViewer, Object object,
		IMenuManager menu )
{
	menu.add( new RefreshModuleHandleAction( object ) );
	if ( sourceViewer.getInput( ) instanceof Object[] )
	{
		Object[] inputs = (Object[]) sourceViewer.getInput( );
		if ( inputs.length == 1 )
		{
			if ( object instanceof LibraryHandle )
			{
				LibraryHandle handle = ( (LibraryHandle) object );

				if ( handle.getNamespace( ) == null )
				{
					menu.add( new PublishLibraryToResourceFolderAction( object ) );
				}

				if ( handle.getNamespace( ) != null )
				{
					menu.add( new RemoveLibraryAction( object ) );
				}
			}
		}
	}
}
 
Example 2
Source File: JSIndexViewActionProvider.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param view
 * @param typeNames
 * @return
 */
protected IAction createAction(final IndexView view, final List<String> typeNames)
{
	IAction action = new Action()
	{
		@Override
		public void run()
		{
			TreeViewer treeViewer = view.getTreeViewer();

			if (treeViewer != null)
			{
				Object input = treeViewer.getInput();

				if (input instanceof IProject)
				{
					IProject project = (IProject) input;

					JSIndexQueryHelper queryHelper = new JSIndexQueryHelper(project);
					Collection<TypeElement> types = queryHelper.getTypes(typeNames.get(0), true);
					List<ClassElement> classes = JSTypeUtil.typesToClasses(types);

					if (!CollectionsUtil.isEmpty(classes))
					{
						ClassElement c = classes.get(0);

						treeViewer.setSelection(new StructuredSelection(c), true);
					}
				}
			}
		}
	};

	action.setText(Messages.JSIndexViewActionProvider_JumpToType);

	return action;
}
 
Example 3
Source File: AbstractOutlineWorkbenchTest.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected void awaitForTreeViewer(TreeViewer treeViewer) {
	long waitTime = 0;
	while (treeViewer.getInput() == null && waitTime < EXPECTED_TIMEOUT) {
		waitTime += 10;
		if (Display.getCurrent() != null)
			Display.getCurrent().readAndDispatch();
	}
}
 
Example 4
Source File: XViewerCustomizeDialog.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private List<XViewerColumn> getTableXViewerColumns(TreeViewer xColTableViewer) {
   return (List<XViewerColumn>) xColTableViewer.getInput();
}
 
Example 5
Source File: ViewContextMenuProvider.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Builds the context menu. Single selection menu and multiple selection
 * menu are created while selecting just single element or multiple elements
 * 
 * 
 * @param menu
 *            the menu
 */
public void buildContextMenu( IMenuManager menu )
{
	menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
	TreeViewer treeViewer = (TreeViewer) getViewer( );

	IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection( );

	// temporary solution
	Object input = treeViewer.getInput( );
	if ( input instanceof Object[] )
	{
		Object[] inputs = (Object[]) input;
		if ( inputs.length == 1 && inputs[0] instanceof ReportDesignHandle )
		{
			for ( Iterator iter = selection.iterator( ); iter.hasNext( ); )
			{
				if ( isIncludedLibrary( iter.next( ) ) )
				{
					return;
				}
			}
		}
	}

	if ( selection.size( ) == 1 )
	{
		// Create Single Selection Menu
		Object obj = selection.getFirstElement( );
		if ( ProviderFactory.createProvider( obj ) != null )
		{
			ProviderFactory.createProvider( obj )
					.createContextMenu( treeViewer, obj, menu );
		}
		if ( Policy.TRACING_MENU_SHOW )
		{
			System.out.println( "Menu(for Views) >> Shows for " + ProviderFactory.createProvider( obj ).getNodeDisplayName( obj ) ); //$NON-NLS-1$
		}
	}
	else
	{
		// Added by ywang on 2004.9.15
		// Create Multiple Selection Menu
		if ( ProviderFactory.getDefaultProvider( ) != null)
		{
			ProviderFactory.getDefaultProvider( )
					.createContextMenu( treeViewer, selection, menu );
		}

		if ( Policy.TRACING_MENU_SHOW )
		{
			System.out.println( "Menu(for Views) >> Shows for multi-selcetion." ); //$NON-NLS-1$
		}
	}
}
 
Example 6
Source File: AbstractOutlineWorkbenchTest.java    From xsemantics with Eclipse Public License 1.0 4 votes vote down vote up
protected IOutlineNode getOutlineRootNode(TreeViewer treeViewer) {
	IOutlineNode rootNode = (IOutlineNode) treeViewer.getInput();
	return rootNode;
}