Java Code Examples for org.eclipse.gef.Request#setExtendedData()

The following examples show how to use org.eclipse.gef.Request#setExtendedData() . 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: BaseInsertHandler.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected Request insertElement( ) throws Exception
{
	Request request = new Request( IRequestConstants.REQUEST_TYPE_INSERT );
	Map extendsData = new HashMap( );
	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_SLOT, slotHandle );

	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_TYPE, insertType );

	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_POSITION,
			InsertAction.BELOW );

	request.setExtendedData( extendsData );

	if ( ProviderFactory.createProvider( slotHandle.getElementHandle( ) )
			.performRequest( model, request ) )
	{
		return request;
	}
	return null;
}
 
Example 2
Source File: BaseInsertMenuAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Request insertElement( ) throws Exception
{
	Request request = new Request( IRequestConstants.REQUEST_TYPE_INSERT );
	Map extendsData = new HashMap( );
	if ( slotHandle != null )
	{
		extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_SLOT,
				slotHandle );
	}
	else if ( propertyHandle != null )
	{
		extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_PROPERTY,
				propertyHandle );
	}

	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_TYPE, insertType );

	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_POSITION,
			InsertAction.BELOW );

	request.setExtendedData( extendsData );

	//		if ( ProviderFactory.createProvider( slotHandle.getElementHandle( ) )
	//				.performRequest( model, request ) )
	Object obj = model;
	if ( slotHandle != null )
	{
		obj = slotHandle.getElementHandle( );
	}
	if ( ProviderFactory.createProvider( obj ).performRequest( model,
			request ) )
	{
		return request;
	}
	return null;
}
 
Example 3
Source File: InsertAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean doAction( ) throws Exception
{
	Request request = new Request( IRequestConstants.REQUEST_TYPE_INSERT );
	Map extendsData = new HashMap( );
	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_SLOT, slotHandle );

	if ( type != null )
	{
		extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_TYPE, type );
	}
	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_POSITION,
			position );
	request.setExtendedData( extendsData );
	isDone = ProviderFactory.createProvider( getSelection( ) )
			.performRequest( getSelection( ), request );
	createElement = request.getExtendedData( ).get( IRequestConstants.REQUEST_KEY_RESULT );

	return isDone;

	// CommandUtils.getHandlerService( )
	// .getCurrentState( )
	// .addVariable( "position", position );
	//
	// if ( type != null )
	// CommandUtils.getHandlerService( )
	// .getCurrentState( )
	// .addVariable( "type", type );
	//
	// Object returnVlaue = CommandUtils.executeCommand( "insert" );
	//
	// CommandUtils.getHandlerService( )
	// .getCurrentState( )
	// .removeVariable( "position" );
	// CommandUtils.getHandlerService( )
	// .getCurrentState( )
	// .removeVariable( "type" );
	//
	// return Boolean.TRUE.equals( returnVlaue );
}
 
Example 4
Source File: ExtendElementAction.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected boolean doAction( ) throws Exception
{
	Request request = new Request( IRequestConstants.REQUEST_TYPE_INSERT );
	Map extendsData = new HashMap( );

	if ( getPropertyHandle( ) != null )
	{
		extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_PROPERTY, getPropertyHandle( ) );
	}
	else if ( getSlotHandle( ) != null )
	{
		extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_SLOT,
				getSlotHandle( ) );
	}

	if ( getType( ) != null )
	{
		extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_TYPE,
				getType( ) );
	}
	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_POSITION,
			getPosition( ) );
	request.setExtendedData( extendsData );
	boolean bool = provider.performRequest( getSelection( ), request );
	if ( bool )
	{
		List list = new ArrayList( );

		list.add( request.getExtendedData( )
				.get( IRequestConstants.REQUEST_KEY_RESULT ) );
		ReportRequest r = new ReportRequest( );
		r.setType( ReportRequest.CREATE_ELEMENT );

		r.setSelectionObject( list );
		SessionHandleAdapter.getInstance( )
		.getMediator( )
		.notifyRequest( r );

	}
	return bool;
}
 
Example 5
Source File: InsertHandler.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Object execute( ExecutionEvent event ) throws ExecutionException
{
	IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
	// should not use getDefaultVariable( context ), but the selection
	// variable passed.
	// Object selection = getDefaultVariable( context );
	SlotHandle slotHandle = null;
	Object obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_SLOT_HANDLE );
	if ( obj != null && obj instanceof SlotHandle )
	{
		slotHandle = (SlotHandle) obj;
	}
	Request request = new Request( IRequestConstants.REQUEST_TYPE_INSERT );
	Map extendsData = new HashMap( );

	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_SLOT, slotHandle );

	if ( UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_ACTION_TYPE ) != null )
	{
		extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_TYPE,
				UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_ACTION_TYPE ) );
	}
	extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_POSITION,
			UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_ACTION_POSITION ) );
	request.setExtendedData( extendsData );
	Object selection = UIUtil.getVariableFromContext(context, ICommandParameterNameContants.INSERT_ACTION_SELECTION );
	boolean bool = false;
	try
	{
		INodeProvider provider = ProviderFactory.createProvider( selection );
		bool = provider.performRequest( selection, request );
	}
	catch ( Exception e )
	{
		ExceptionHandler.handle( e );
	}
	if ( bool )
	{
		List list = new ArrayList( );

		list.add( request.getExtendedData( )
				.get( IRequestConstants.REQUEST_KEY_RESULT ) );
		ReportRequest r = new ReportRequest( );
		r.setType( ReportRequest.CREATE_ELEMENT );

		r.setSelectionObject( list );
		SessionHandleAdapter.getInstance( )
				.getMediator( )
				.notifyRequest( r );

	}
	return Boolean.valueOf( bool );
}