/** * Static constructor. * <p> * Using static constructor methods prevents unnecessarily nesting WidgetProcessorExceptions * within WidgetProcessorExceptions. */ public static WidgetProcessorException newException( Throwable cause ) { if ( cause instanceof WidgetProcessorException ) { return (WidgetProcessorException) cause; } return new WidgetProcessorException( cause ); }
@Override public void widgetSelected( SelectionEvent e ) { try { final Method parameterlessActionMethod = fireActionOnClass.getMethod( actionName, (Class[]) null ); parameterlessActionMethod.invoke( fireActionOn, (Object[]) null ); } catch ( Exception exception ) { throw WidgetProcessorException.newException( exception ); } } } );
/** * Process the built widget. */ protected W processWidget( W widget, String elementName, Map<String, String> attributes ) { W processedWidget = widget; if ( mWidgetProcessors != null ) { M pipelineOwner = getPipelineOwner(); for ( WidgetProcessor<W, M> widgetProcessor : mWidgetProcessors ) { processedWidget = widgetProcessor.processWidget( processedWidget, elementName, attributes, pipelineOwner ); // A WidgetProcessor could return null to cancel the widget if ( processedWidget == null ) { return null; } } } return processedWidget; }
protected void startBuild() { M pipelineOwner = getPipelineOwner(); if ( mWidgetBuilder instanceof AdvancedWidgetBuilder<?, ?> ) { ( (AdvancedWidgetBuilder<W, M>) mWidgetBuilder ).onStartBuild( pipelineOwner ); } if ( mWidgetProcessors != null ) { for ( WidgetProcessor<W, M> widgetProcessor : mWidgetProcessors ) { if ( widgetProcessor instanceof AdvancedWidgetProcessor<?, ?> ) { ( (AdvancedWidgetProcessor<W, M>) widgetProcessor ).onStartBuild( pipelineOwner ); } } } // (layout can be null if no path, in an IDE visual builder) if ( mLayout instanceof AdvancedLayout<?, ?, ?> ) { AdvancedLayout<W, C, M> advancedLayout = (AdvancedLayout<W, C, M>) mLayout; advancedLayout.onStartBuild( pipelineOwner ); advancedLayout.startContainerLayout( pipelineOwner, pipelineOwner ); } }
protected void endBuild() { M pipelineOwner = getPipelineOwner(); // (layout can be null if no path, in an IDE visual builder) if ( mLayout instanceof AdvancedLayout<?, ?, ?> ) { AdvancedLayout<W, C, M> advancedLayout = (AdvancedLayout<W, C, M>) mLayout; advancedLayout.endContainerLayout( pipelineOwner, pipelineOwner ); advancedLayout.onEndBuild( pipelineOwner ); } if ( mWidgetProcessors != null ) { for ( WidgetProcessor<W, M> widgetProcessor : mWidgetProcessors ) { if ( widgetProcessor instanceof AdvancedWidgetProcessor<?, ?> ) { ( (AdvancedWidgetProcessor<W, M>) widgetProcessor ).onEndBuild( pipelineOwner ); } } } if ( mWidgetBuilder instanceof AdvancedWidgetBuilder<?, ?> ) { ( (AdvancedWidgetBuilder<W, M>) mWidgetBuilder ).onEndBuild( pipelineOwner ); } } }
public void buttonClick( ClickEvent event ) { try { Method method = fireActionOnClass.getMethod( actionName, (Class[]) null ); method.invoke( fireActionOn, (Object[]) null ); } catch ( Exception e ) { throw WidgetProcessorException.newException( e ); } } } );
/** * Static constructor. * <p> * Using static constructor methods prevents unnecessarily nesting WidgetProcessorExceptions * within WidgetProcessorExceptions. */ public static WidgetProcessorException newException( Throwable cause ) { if ( cause instanceof WidgetProcessorException ) { return (WidgetProcessorException) cause; } return new WidgetProcessorException( cause ); }
/** * Process the built widget. */ protected W processWidget( W widget, String elementName, Map<String, String> attributes ) { W processedWidget = widget; if ( mWidgetProcessors != null ) { M pipelineOwner = getPipelineOwner(); for ( WidgetProcessor<W, M> widgetProcessor : mWidgetProcessors ) { processedWidget = widgetProcessor.processWidget( processedWidget, elementName, attributes, pipelineOwner ); // A WidgetProcessor could return null to cancel the widget if ( processedWidget == null ) { return null; } } } return processedWidget; }
protected void startBuild() { M pipelineOwner = getPipelineOwner(); if ( mWidgetBuilder instanceof AdvancedWidgetBuilder<?, ?> ) { ( (AdvancedWidgetBuilder<W, M>) mWidgetBuilder ).onStartBuild( pipelineOwner ); } if ( mWidgetProcessors != null ) { for ( WidgetProcessor<W, M> widgetProcessor : mWidgetProcessors ) { if ( widgetProcessor instanceof AdvancedWidgetProcessor<?, ?> ) { ( (AdvancedWidgetProcessor<W, M>) widgetProcessor ).onStartBuild( pipelineOwner ); } } } // (layout can be null if no path, in an IDE visual builder) if ( mLayout instanceof AdvancedLayout<?, ?, ?> ) { AdvancedLayout<W, C, M> advancedLayout = (AdvancedLayout<W, C, M>) mLayout; advancedLayout.onStartBuild( pipelineOwner ); advancedLayout.startContainerLayout( pipelineOwner, pipelineOwner ); } }
protected void endBuild() { M pipelineOwner = getPipelineOwner(); // (layout can be null if no path, in an IDE visual builder) if ( mLayout instanceof AdvancedLayout<?, ?, ?> ) { AdvancedLayout<W, C, M> advancedLayout = (AdvancedLayout<W, C, M>) mLayout; advancedLayout.endContainerLayout( pipelineOwner, pipelineOwner ); advancedLayout.onEndBuild( pipelineOwner ); } if ( mWidgetProcessors != null ) { for ( WidgetProcessor<W, M> widgetProcessor : mWidgetProcessors ) { if ( widgetProcessor instanceof AdvancedWidgetProcessor<?, ?> ) { ( (AdvancedWidgetProcessor<W, M>) widgetProcessor ).onEndBuild( pipelineOwner ); } } } if ( mWidgetBuilder instanceof AdvancedWidgetBuilder<?, ?> ) { ( (AdvancedWidgetBuilder<W, M>) mWidgetBuilder ).onEndBuild( pipelineOwner ); } } }
private CoreWidget getNumberConverter( CoreWidget existingConverter ) { if ( existingConverter != null ) { if ( !( existingConverter instanceof ConvertNumberWidget ) ) { throw WidgetProcessorException.newException( "Unable to set number attributes on a " + existingConverter ); } return existingConverter; } return new ConvertNumberWidget(); }
/** * Static constructor. * <p> * For consistency with <code>WidgetProcessorException.newException( Throwable )</code>. */ public static WidgetProcessorException newException( String message ) { return new WidgetProcessorException( message ); }
private CoreWidget getDateTimeConverter( CoreWidget existingConverter ) { if ( existingConverter != null ) { if ( !( existingConverter instanceof ConvertDateTimeWidget ) ) { throw WidgetProcessorException.newException( "Unable to set date/time attributes on a " + existingConverter ); } return existingConverter; } return new ConvertDateTimeWidget(); }
/** * Static constructor. * <p> * For consistency with <code>WidgetProcessorException.newException( Throwable )</code>. */ public static WidgetProcessorException newException( String message, Throwable cause ) { return new WidgetProcessorException( message, cause ); }
public void onClick( View viewClicked ) { Object traverse = mBindTo; for ( String name : mNames ) { if ( traverse == null ) { return; } traverse = ClassUtils.getProperty( traverse, name ); } try { mAction.invoke( traverse, (Object[]) null ); } catch ( Exception e ) { throw WidgetProcessorException.newException( e ); } } }
/** * Static constructor. * <p> * For consistency with <code>WidgetProcessorException.newException( Throwable )</code>. */ public static WidgetProcessorException newException( String message ) { return new WidgetProcessorException( message ); }
public void addWidgetProcessor( WidgetProcessor<W, M> widgetProcessor ) { configureOnce(); if ( mWidgetProcessors == null ) { mWidgetProcessors = new ArrayList<WidgetProcessor<W, M>>(); } else if ( mWidgetProcessors.contains( widgetProcessor ) ) { throw WidgetProcessorException.newException( "List of WidgetProcessors already contains " + widgetProcessor.getClass() ); } mWidgetProcessors.add( widgetProcessor ); }
/** * Static constructor. * <p> * For consistency with <code>WidgetProcessorException.newException( Throwable )</code>. */ public static WidgetProcessorException newException( String message, Throwable cause ) { return new WidgetProcessorException( message, cause ); }
public void addWidgetProcessor( WidgetProcessor<W, M> widgetProcessor ) { configureOnce(); if ( mWidgetProcessors == null ) { mWidgetProcessors = new ArrayList<WidgetProcessor<W, M>>(); } else if ( mWidgetProcessors.contains( widgetProcessor ) ) { throw WidgetProcessorException.newException( "List of WidgetProcessors already contains " + widgetProcessor.getClass() ); } mWidgetProcessors.add( widgetProcessor ); }
public void save( SwingMetawidget metawidget ) { State state = getState( metawidget ); // Our bindings if ( state.bindings != null ) { try { for ( SavedBinding binding : state.bindings ) { if ( !binding.isSettable() ) { continue; } Object componentValue = retrieveValueFromWidget( binding ); saveValueToObject( metawidget, binding.getNames(), componentValue ); } } catch ( Exception e ) { throw WidgetProcessorException.newException( e ); } } // Nested Metawidgets if ( state.nestedMetawidgets != null ) { for ( SwingMetawidget nestedMetawidget : state.nestedMetawidgets ) { save( nestedMetawidget ); } } }