Skip to content

Commit

Permalink
Change object cast method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xusong Yuan committed Oct 25, 2012
1 parent 0993650 commit 66bbb95
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.LabelEditPart;
import org.eclipse.birt.report.designer.internal.ui.util.ExceptionHandler;
import org.eclipse.birt.report.designer.internal.ui.util.Policy;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.designer.internal.ui.views.IRequestConstants;
import org.eclipse.birt.report.designer.internal.ui.views.actions.InsertAction;
import org.eclipse.birt.report.designer.nls.Messages;
Expand Down Expand Up @@ -101,7 +102,7 @@ public Object execute( ExecutionEvent event ) throws ExecutionException
protected boolean initializeVariable(ExecutionEvent event)
{
IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
Object obj = context.getVariable( ICommandParameterNameContants.BASE_INSERT_TYPE_NAME );
Object obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.BASE_INSERT_TYPE_NAME );
if(obj == null || (obj instanceof String))
{
insertType = (String)obj;
Expand All @@ -111,7 +112,7 @@ protected boolean initializeVariable(ExecutionEvent event)
return false;
}

obj = context.getVariable( ICommandParameterNameContants.BASE_INSERT_SLOT_HANDLE_NAME );
obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.BASE_INSERT_SLOT_HANDLE_NAME );
if(obj == null || (obj instanceof SlotHandle))
{
slotHandle = (SlotHandle)obj;
Expand All @@ -121,7 +122,7 @@ protected boolean initializeVariable(ExecutionEvent event)
return false;
}

obj = context.getVariable( ICommandParameterNameContants.BASE_INSERT_MODEL_NAME );
obj = UIUtil.getVariableFromContext( context,ICommandParameterNameContants.BASE_INSERT_MODEL_NAME );
if(obj == null)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.eclipse.birt.report.designer.core.model.SessionHandleAdapter;
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.ReportElementEditPart;
import org.eclipse.birt.report.designer.internal.ui.util.ExceptionHandler;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.designer.nls.Messages;
import org.eclipse.birt.report.model.api.CommandStack;
import org.eclipse.birt.report.model.api.GroupHandle;
Expand All @@ -27,14 +28,14 @@ public Object execute( ExecutionEvent event ) throws ExecutionException
ReportElementEditPart editPart = null;

IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
Object obj = context.getVariable( ICommandParameterNameContants.DELETE_GROUP_HANDLE );
Object obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.DELETE_GROUP_HANDLE );
if ( ( obj == null ) || ( !( obj instanceof GroupHandle ) ) )
{
return Boolean.FALSE;
}
handle = (GroupHandle) obj;

obj = context.getVariable( ICommandParameterNameContants.DELETE_GROUP_EDIT_PART );
obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.DELETE_GROUP_EDIT_PART );
if ( ( obj == null ) || ( !( obj instanceof ReportElementEditPart ) ) )
{
return Boolean.FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.eclipse.birt.report.designer.core.model.SessionHandleAdapter;
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.actions.EditGroupAction;
import org.eclipse.birt.report.designer.internal.ui.util.Policy;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.designer.nls.Messages;
import org.eclipse.birt.report.designer.ui.dialogs.GroupDialog;
import org.eclipse.birt.report.model.api.CommandStack;
Expand Down Expand Up @@ -44,7 +45,7 @@ public Object execute( ExecutionEvent event ) throws ExecutionException

GroupHandle handle = null;
IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
Object obj = context.getVariable( EditGroupAction.GROUP_HANDLE_NAME );
Object obj = UIUtil.getVariableFromContext( context, EditGroupAction.GROUP_HANDLE_NAME );
if ( obj != null && obj instanceof GroupHandle )
{
handle = (GroupHandle) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.eclipse.birt.report.designer.internal.ui.command;

import org.eclipse.birt.report.designer.internal.ui.util.Policy;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.designer.ui.dialogs.StyleBuilder;
import org.eclipse.birt.report.model.api.SharedStyleHandle;
import org.eclipse.core.commands.ExecutionEvent;
Expand All @@ -38,7 +39,7 @@ public Object execute( ExecutionEvent event ) throws ExecutionException
super.execute( event );

IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
Object obj = context.getVariable( ICommandParameterNameContants.EDIT_STYLE_SHARED_STYLE_HANDLE_NAME );
Object obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.EDIT_STYLE_SHARED_STYLE_HANDLE_NAME );
if ( obj != null && obj instanceof SharedStyleHandle )
{
handle = (SharedStyleHandle) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.birt.report.designer.core.model.schematic.HandleAdapterFactory;
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.DummyEditpart;
import org.eclipse.birt.report.designer.internal.ui.util.Policy;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.model.api.ColumnHandle;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
Expand All @@ -41,7 +42,7 @@ public Object execute( ExecutionEvent event ) throws ExecutionException
super.execute( event );

IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
Object position = context.getVariable( ICommandParameterNameContants.INSERT_COLUMN_POSITION );
Object position = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_COLUMN_POSITION );
int intPos = -1;
if ( position instanceof Integer )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Object execute( ExecutionEvent event ) throws ExecutionException
//currentModel = context.getVariable( ICommandParameterNameContants.INSERT_GROUP_CURRENT_MODEL_NAME );

int position = 0;
Object obj = context.getVariable(ICommandParameterNameContants.INSERT_GROUP_POSITION);
Object obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_GROUP_POSITION);
if ( obj != null && obj instanceof Integer )
{
position = ( (Integer) obj ).intValue( );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.birt.report.designer.core.model.SessionHandleAdapter;
import org.eclipse.birt.report.designer.core.util.mediator.request.ReportRequest;
import org.eclipse.birt.report.designer.internal.ui.util.ExceptionHandler;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.designer.internal.ui.views.IRequestConstants;
import org.eclipse.birt.report.designer.ui.views.INodeProvider;
import org.eclipse.birt.report.designer.ui.views.ProviderFactory;
Expand All @@ -43,7 +44,7 @@ public Object execute( ExecutionEvent event ) throws ExecutionException
// variable passed.
// Object selection = getDefaultVariable( context );
SlotHandle slotHandle = null;
Object obj = context.getVariable( ICommandParameterNameContants.INSERT_SLOT_HANDLE );
Object obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_SLOT_HANDLE );
if ( obj != null && obj instanceof SlotHandle )
{
slotHandle = (SlotHandle) obj;
Expand All @@ -53,13 +54,13 @@ public Object execute( ExecutionEvent event ) throws ExecutionException

extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_SLOT, slotHandle );

if ( context.getVariable( ICommandParameterNameContants.INSERT_ACTION_TYPE ) != null )
if ( UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_ACTION_TYPE ) != null )
{
extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_TYPE,
context.getVariable( ICommandParameterNameContants.INSERT_ACTION_TYPE ) );
UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_ACTION_TYPE ) );
}
extendsData.put( IRequestConstants.REQUEST_KEY_INSERT_POSITION,
context.getVariable( ICommandParameterNameContants.INSERT_ACTION_POSITION ) );
UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_ACTION_POSITION ) );
request.setExtendedData( extendsData );
Object selection = context.getVariable( ICommandParameterNameContants.INSERT_ACTION_SELECTION );
boolean bool = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.birt.report.designer.core.model.schematic.HandleAdapterFactory;
import org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.DummyEditpart;
import org.eclipse.birt.report.designer.internal.ui.util.Policy;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.model.api.RowHandle;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
Expand All @@ -36,7 +37,7 @@ public Object execute( ExecutionEvent event ) throws ExecutionException

IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );

Object position = context.getVariable(ICommandParameterNameContants.INSERT_ROW_POSITION);
Object position = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.INSERT_ROW_POSITION);
int intPos = -1;
if(position != null && position instanceof Integer)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.birt.report.designer.core.model.SessionHandleAdapter;
import org.eclipse.birt.report.designer.internal.ui.util.ExceptionHandler;
import org.eclipse.birt.report.designer.internal.ui.util.Policy;
import org.eclipse.birt.report.designer.internal.ui.util.UIUtil;
import org.eclipse.birt.report.designer.nls.Messages;
import org.eclipse.birt.report.designer.ui.dialogs.StyleBuilder;
import org.eclipse.birt.report.designer.ui.newelement.DesignElementFactory;
Expand Down Expand Up @@ -66,7 +67,7 @@ public Object execute( ExecutionEvent event ) throws ExecutionException
stack.startTrans( STACK_MSG_ADD_STYLE );

IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
Object obj = context.getVariable( ICommandParameterNameContants.NEW_STYLE_THEME_HANDLE_NAME );
Object obj = UIUtil.getVariableFromContext( context, ICommandParameterNameContants.NEW_STYLE_THEME_HANDLE_NAME );
if ( obj instanceof AbstractThemeHandle )
{
themeHandle = (AbstractThemeHandle) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public Object execute( ExecutionEvent event ) throws ExecutionException
// String fileName = filePath.substring( filePath.lastIndexOf( File.separator ) + 1 );

IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
String fileName = (String)context.getVariable(ICommandParameterNameContants.PUBLISH_LIBRARY_FILENAME);
LibraryHandle libHandle = (LibraryHandle) context.getVariable(ICommandParameterNameContants.PUBLISH_LIBRARY_LIBRARY_HANDLE);
String fileName = (String)UIUtil.getVariableFromContext( context, ICommandParameterNameContants.PUBLISH_LIBRARY_FILENAME);
LibraryHandle libHandle = (LibraryHandle) UIUtil.getVariableFromContext( context, ICommandParameterNameContants.PUBLISH_LIBRARY_LIBRARY_HANDLE);

PublishLibraryWizard publishLibrary = new PublishLibraryWizard( libHandle,
fileName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected Object getFirstElement( List list )
protected Object getFirstSelectVariable( )
{
IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
Object selectVariable = context.getVariable( ISources.ACTIVE_CURRENT_SELECTION_NAME );
Object selectVariable = UIUtil.getVariableFromContext( context, ISources.ACTIVE_CURRENT_SELECTION_NAME );
Object selectList = selectVariable;
if ( selectVariable instanceof StructuredSelection )
{
Expand Down Expand Up @@ -229,7 +229,7 @@ protected List getSelectedObjects( )
protected IStructuredSelection getSelection( )
{
IEvaluationContext context = (IEvaluationContext) event.getApplicationContext( );
Object selectVariable = context.getVariable( ISources.ACTIVE_CURRENT_SELECTION_NAME );
Object selectVariable = UIUtil.getVariableFromContext( context, ISources.ACTIVE_CURRENT_SELECTION_NAME );
if ( selectVariable != null )
{
if ( selectVariable instanceof IStructuredSelection )
Expand Down

0 comments on commit 66bbb95

Please sign in to comment.