/*******************************************************************************
 * Copyright (c) 2004 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.lib.explorer.action;

import org.eclipse.birt.report.designer.nls.Messages;
import org.eclipse.birt.report.designer.ui.lib.explorer.LibraryExplorerTreeViewPage;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.Display;

/**
 * 
 */

public class RefreshLibExplorerAction extends Action
{

	private LibraryExplorerTreeViewPage viewer;
	private Object element;
	private static final String ACTION_TEXT = Messages
			.getString( "RefreshLibExplorerAction.Text" ); //$NON-NLS-1$

	public RefreshLibExplorerAction( LibraryExplorerTreeViewPage page )
	{
		super( ACTION_TEXT );
		this.viewer = page;
	}

	/**
	 * Get selected element
	 * 
	 * @param element
	 */
	public void setSelectedElement( Object element )
	{
		this.element = element;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
	public void run( )
	{
		Display.getDefault( ).asyncExec( new Runnable( ) {

			public void run( )
			{
				viewer.refreshRoot( );
			}
		} );
	}

}
