Skip to content

Commit

Permalink
DOC/PPT, emitter updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Charling Huang committed Mar 21, 2017
1 parent 70a9abe commit ec296d9
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 42 deletions.
Expand Up @@ -964,6 +964,7 @@ designer.preview.previewaction.ErrorMessage=PDF generation is not enabled since
designer.preview.previewaction.ErrorMessage.title=Warning
designer.preview.run.webviewer=In Web Viewer
designer.preview.run=As {0}
designer.preview.deprecated.label=(Deprecated)

###########################################################
#DesignerActionBarContributor properties
Expand Down
Expand Up @@ -85,17 +85,33 @@ protected Menu getPreviewMenu( Object parent, boolean fullLabel )
}

TreeMap<String, List<EmitterInfo>> supportedFormats = new TreeMap<String, List<EmitterInfo>>( );
TreeMap<String, List<EmitterInfo>> deprecatedFormats = new TreeMap<String, List<EmitterInfo>>( );

for ( EmitterInfo ei : emitters )
{
if ( !ei.isHidden( ) )
{
List<EmitterInfo> list = supportedFormats.get( ei.getFormat( ) );

if ( list == null )
List<EmitterInfo> list = null;

if ( !ei.isFormatDeprecated( ) )
{
list = supportedFormats.get( ei.getFormat( ) );

if ( list == null )
{
list = new ArrayList<EmitterInfo>( );
supportedFormats.put( ei.getFormat( ), list );
}
}
else
{
list = new ArrayList<EmitterInfo>( );
supportedFormats.put( ei.getFormat( ), list );
list = deprecatedFormats.get( ei.getFormat( ) );

if ( list == null )
{
list = new ArrayList<EmitterInfo>( );
deprecatedFormats.put( ei.getFormat( ), list );
}
}

list.add( ei );
Expand Down Expand Up @@ -154,48 +170,61 @@ public void widgetSelected( SelectionEvent e )

previewOption.setImage( getFormatIcon( format, emits ) );

if ( emits.size( ) > 1 )
{
Menu subMenu = new Menu( previewOption );
previewOption.setMenu( subMenu );
processEmits( previewOption, emits, configManager );
}

for ( Entry<String, List<EmitterInfo>> ent : deprecatedFormats.entrySet( ) )
{
final String format = ent.getKey( );
final List<EmitterInfo> emits = ent.getValue( );

int j = 1;
for ( final EmitterInfo ei : emits )
{
MenuItem sub1 = new MenuItem( subMenu, SWT.PUSH );
MenuItem previewOption = new MenuItem( menu,
emits.size( ) > 1 ? SWT.CASCADE : SWT.PUSH );

final IEmitterDescriptor emitterDescriptor = configManager.getEmitterDescriptor( ei.getID( ) );
previewOption.setText( Messages.getFormattedString( fullLabel ? "designer.preview.previewaction.label" //$NON-NLS-1$
: "designer.preview.run", //$NON-NLS-1$
new Object[]{
format.toUpperCase( ) + Messages.getString( "designer.preview.deprecated.label" )
} ) );

String label = null;
previewOption.setImage( getFormatIcon( format, emits ) );

if ( emitterDescriptor != null
&& emitterDescriptor.getDisplayName( ) != null )
{
label = emitterDescriptor.getDisplayName( );
}
processEmits( previewOption, emits, configManager );
}

if ( label == null )
{
label = getDefaultLabel( ei );
}
return menu;
}

private void processEmits( MenuItem previewOption, List<EmitterInfo> emits, EmitterConfigurationManager configManager )
{
if ( emits.size( ) > 1 )
{
Menu subMenu = new Menu( previewOption );
previewOption.setMenu( subMenu );

int j = 1;
for ( final EmitterInfo ei : emits )
{
MenuItem sub1 = new MenuItem( subMenu, SWT.PUSH );

sub1.setText( "&" + ( j++ ) + " " + label ); //$NON-NLS-1$ //$NON-NLS-2$
final IEmitterDescriptor emitterDescriptor = configManager.getEmitterDescriptor( ei.getID( ) );

sub1.addSelectionListener( new SelectionAdapter( ) {
String label = null;

public void widgetSelected( SelectionEvent e )
{
preview( ei, emitterDescriptor );
}
} );
if ( emitterDescriptor != null
&& emitterDescriptor.getDisplayName( ) != null )
{
label = emitterDescriptor.getDisplayName( );
}
}
else
{
final EmitterInfo ei = emits.get( 0 );
final IEmitterDescriptor emitterDescriptor = configManager.getEmitterDescriptor( ei.getID( ) );

previewOption.addSelectionListener( new SelectionAdapter( ) {
if ( label == null )
{
label = getDefaultLabel( ei );
}

sub1.setText( "&" + ( j++ ) + " " + label ); //$NON-NLS-1$ //$NON-NLS-2$

sub1.addSelectionListener( new SelectionAdapter( ) {

public void widgetSelected( SelectionEvent e )
{
Expand All @@ -204,8 +233,19 @@ public void widgetSelected( SelectionEvent e )
} );
}
}
else
{
final EmitterInfo ei = emits.get( 0 );
final IEmitterDescriptor emitterDescriptor = configManager.getEmitterDescriptor( ei.getID( ) );

return menu;
previewOption.addSelectionListener( new SelectionAdapter( ) {

public void widgetSelected( SelectionEvent e )
{
preview( ei, emitterDescriptor );
}
} );
}
}

private String getDefaultLabel( EmitterInfo ei )
Expand Down
3 changes: 2 additions & 1 deletion engine/org.eclipse.birt.report.engine.emitter.ppt/plugin.xml
Expand Up @@ -11,6 +11,7 @@
format="ppt"
pagination="paper-size-pagination"
id="org.eclipse.birt.report.engine.emitter.ppt"
mimeType="application/vnd.ms-powerpoint"/>
mimeType="application/vnd.ms-powerpoint"
isFormatDeprecated="true"/>
</extension>
</plugin>
Expand Up @@ -10,6 +10,7 @@
format="doc"
id="org.eclipse.birt.report.engine.emitter.word"
pagination="page-break-pagination"
mimeType="application/msword"/>
mimeType="application/msword"
isFormatDeprecated="true"/>
</extension>
</plugin>
12 changes: 11 additions & 1 deletion engine/org.eclipse.birt.report.engine/schema/emitters.exsd
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.birt.report.engine">
<schema targetNamespace="org.eclipse.birt.report.engine" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.birt.report.engine" id="emitters" name="Emitters that Support Report Rendering"/>
Expand All @@ -12,6 +12,9 @@

<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
<documentation>
root element for the emitters extension
</documentation>
Expand Down Expand Up @@ -137,6 +140,13 @@
</documentation>
</annotation>
</attribute>
<attribute name="isFormatDeprecated" type="boolean">
<annotation>
<documentation>
Indicates if format is deprecated
</documentation>
</annotation>
</attribute>
</complexType>
</element>

Expand Down
Expand Up @@ -32,6 +32,7 @@ public class EmitterInfo
private String supportedImageFormats;
private boolean needOutputResultSet;
private int overridePriority;
private boolean isFormatDeprecated;

/**
* whether emitter need to output the display:none or process it in layout
Expand Down Expand Up @@ -200,5 +201,24 @@ public void setOverridePriority( int overridePriority )
{
this.overridePriority = overridePriority;
}


/**
* Get if the emitter format is deprecated
*
* @return
*/
public boolean isFormatDeprecated( )
{
return isFormatDeprecated;
}

/**
* Set if the emitter format is deprecated
*
* @param isFormatDeprecated
*/
public void setFormatDeprecated( boolean isFormatDeprecated )
{
this.isFormatDeprecated = isFormatDeprecated;
}
}
Expand Up @@ -612,6 +612,11 @@ protected void loadEmitterExtensionDefns( )
.getAttribute( "isHidden" ) );
boolean needOutputResultSet = Boolean.valueOf( configs[j]
.getAttribute( "needOutputResultSet" ) );
String isFormatDeprecated = configs[j].getAttribute( "isFormatDeprecated" );
boolean deprecated = false;
if ( null != isFormatDeprecated ) {
deprecated = Boolean.valueOf( isFormatDeprecated ).booleanValue( );
}
if ( !Pattern.matches( emitterFormatPattern, format ) )
{
logger.log(
Expand All @@ -628,6 +633,7 @@ protected void loadEmitterExtensionDefns( )
supportedImageFormats, needOutputResultSet,
configs[j] );
emitterInfo.setOverridePriority( priority );
emitterInfo.setFormatDeprecated( deprecated );

EmitterInfo existedInfo = (EmitterInfo) emitters.get( id );
if ( existedInfo != null )
Expand Down

0 comments on commit ec296d9

Please sign in to comment.