/*******************************************************************************
 * Copyright (c) 2005 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.designer.ui.cubebuilder.provider;

import org.eclipse.birt.report.designer.internal.ui.views.DefaultNodeProvider;
import org.eclipse.birt.report.designer.ui.ReportPlatformUIImages;
import org.eclipse.birt.report.designer.ui.cubebuilder.action.NewCubeAction;
import org.eclipse.birt.report.designer.ui.cubebuilder.nls.Messages;
import org.eclipse.birt.report.designer.ui.cubebuilder.util.BuilderConstants;
import org.eclipse.birt.report.designer.ui.cubebuilder.util.UIHelper;
import org.eclipse.birt.report.model.api.DesignElementHandle;
import org.eclipse.birt.report.model.api.SlotHandle;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;


public class CubesNodeProvider extends DefaultNodeProvider
{

	/**
	 * Creates the context menu for the given object. Gets the action from the
	 * actionRegistry and adds the action to the given menu.
	 * 
	 * @param menu
	 *            the menu
	 * @param object
	 *            the object
	 */
	public void createContextMenu( TreeViewer sourceViewer, Object object,
			IMenuManager menu )
	{
		String id = menu.getItems( )[0].getId( );

		NewCubeAction action = new NewCubeAction( Messages.getString( "cube.action.new" ) );//$NON-NLS-1$
		menu.insertAfter( id, action );
		super.createContextMenu( sourceViewer, object, menu );

	}

	public Object[] getChildren( Object model )
	{
		return ( (SlotHandle) model ).getElementHandle( )
				.getRoot( )
				.getVisibleCubes( )
				.toArray( );
	}

	/**
	 * Gets the display name of the node.
	 * 
	 * @param model
	 *            the object
	 */
	public String getNodeDisplayName( Object object )
	{
		return Messages.getString( "DefaultNodeProvider.Tree.Cubes" ); //$NON-NLS-1$
	}

	public Image getNodeIcon( Object model )
	{
		if ( model instanceof DesignElementHandle
				&& ( (DesignElementHandle) model ).getSemanticErrors( ).size( ) > 0 )
		{
			return ReportPlatformUIImages.getImage( ISharedImages.IMG_OBJS_ERROR_TSK );
		}
		return UIHelper.getImage( BuilderConstants.IMAGE_CUBES );
	}
}
@@ -1712,53 +1712,8 @@
 %0A%09%7B%0A
-%09%09String id = menu.getItems( )%5B0%5D.getId( );%0A%0A
 %09%09Ne
@@ -1819,24 +1819,12 @@
 enu.
-insertAfter( id,
+add(
  act

Revert last change.