Skip to content

Commit

Permalink
- Bugzilla Bug (s) Resolved:
Browse files Browse the repository at this point in the history
- Description:
(#45299)
Refactored auto title UI, added 'auto' label, make it more friendly.
  • Loading branch information
heli committed Nov 15, 2011
1 parent a1b7ca2 commit 3407a8d
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 78 deletions.
Expand Up @@ -153,7 +153,7 @@ public void createControl( Composite parent )

Composite cmpBasic = new Composite( cmpContent, SWT.NONE );
{
cmpBasic.setLayout( new GridLayout( 3, false ) );
cmpBasic.setLayout( new GridLayout( 4, false ) );
cmpBasic.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
}

Expand All @@ -173,6 +173,7 @@ public void createControl( Composite parent )
btnReverse = new TristateCheckbox( cmpBasic, SWT.NONE );
btnReverse.setText( Messages.getString( "AbstractAxisSubtask.Label.ReverseCategory" ) ); //$NON-NLS-1$
gd = new GridData( );
gd.horizontalSpan = 2;
btnReverse.setLayoutData( gd );
btnReverse.setSelectionState( ( (ChartWithAxes) getChart( ) ).isSetReverseCategory( ) ? ( ( (ChartWithAxes) getChart( ) ).isReverseCategory( ) ? TristateCheckbox.STATE_SELECTED
: TristateCheckbox.STATE_UNSELECTED )
Expand All @@ -184,27 +185,14 @@ public void createControl( Composite parent )
Label lblTitle = new Label( cmpBasic, SWT.NONE );
lblTitle.setText( Messages.getString( "AxisYSheetImpl.Label.Title" ) ); //$NON-NLS-1$

Composite titleComp = new Composite( cmpBasic, SWT.NONE );
GridLayout gl = new GridLayout();
gl.numColumns = 2;
gl.marginLeft = 0;
gl.marginRight = 0;
gl.marginTop = 0;
gl.marginBottom = 0;
titleComp.setLayout( gl );

btnTitleContentAuto = new Button( titleComp, SWT.CHECK );
btnTitleContentAuto.setSelection( getAxisForProcessing( ).getTitle( ).getCaption( ).getValue( ) == null );
btnTitleContentAuto.addSelectionListener( this );

List<String> keys = null;
IUIServiceProvider serviceprovider = getContext( ).getUIServiceProvider( );
if ( serviceprovider != null )
{
keys = serviceprovider.getRegisteredKeys( );
}

txtTitle = new ExternalizedTextEditorComposite( titleComp,
txtTitle = new ExternalizedTextEditorComposite( cmpBasic,
SWT.BORDER | SWT.SINGLE,
-1,
-1,
Expand All @@ -214,6 +202,7 @@ public void createControl( Composite parent )
{
GridData gd = new GridData( );
gd.widthHint = 230;
gd.horizontalIndent = 5;
txtTitle.setLayoutData( gd );
txtTitle.addListener( this );
}
Expand All @@ -227,6 +216,11 @@ public void createControl( Composite parent )
: TristateCheckbox.STATE_GRAYED );
btnTitleVisible.addSelectionListener( this );

btnTitleContentAuto = new Button( cmpBasic, SWT.CHECK );
btnTitleContentAuto.setText( ChartUIExtensionUtil.getAutoMessage( ) );
btnTitleContentAuto.setSelection( getAxisForProcessing( ).getTitle( ).getCaption( ).getValue( ) == null );
btnTitleContentAuto.addSelectionListener( this );

if ( getAxisAngleType( ) != AngleType.Z )
{
Label lblType = new Label( cmpBasic, SWT.NONE );
Expand All @@ -245,6 +239,7 @@ public void createControl( Composite parent )
{
GridData gdBTNFormatSpecifier = new GridData( );
gdBTNFormatSpecifier.horizontalIndent = -3;
gdBTNFormatSpecifier.horizontalSpan = 2;
btnFormatSpecifier.setLayoutData( gdBTNFormatSpecifier );
//btnFormatSpecifier.setImage( UIHelper.getImage( "icons/obj16/formatbuilder.gif" ) ); //$NON-NLS-1$
btnFormatSpecifier.setToolTipText( Messages.getString( "Shared.Tooltip.FormatSpecifier" ) ); //$NON-NLS-1$
Expand All @@ -264,7 +259,7 @@ public void createControl( Composite parent )
{
GridData gd = new GridData( );
gd.widthHint = 220;
gd.horizontalSpan = 2;
gd.horizontalSpan = 3;
gd.horizontalIndent = 5;
cmbOrigin.setLayoutData( gd );
cmbOrigin.addSelectionListener( this );
Expand Down Expand Up @@ -300,6 +295,9 @@ && getAxisForProcessing( ).getOrigin( )
}

btnTxtValueAuto = new Button( cmpBasic, SWT.CHECK );
GridData gd = new GridData();
gd.horizontalSpan = 2;
btnTxtValueAuto.setLayoutData( gd );
btnTxtValueAuto.setText( ChartUIExtensionUtil.getAutoMessage( ) );
btnTxtValueAuto.setSelection( !bValueOrigin
|| getAxisForProcessing( ).getOrigin( ).getValue( ) == null );
Expand Down Expand Up @@ -329,6 +327,9 @@ && getAxisForProcessing( ).getOrigin( )
}

Composite cmpLabel = new Composite( cmpBasic, SWT.NONE );
GridData gd = new GridData( );
gd.horizontalSpan = 2;
cmpLabel.setLayoutData( gd );
{
GridLayout layout = new GridLayout( 2, false );
layout.marginHeight = 0;
Expand All @@ -338,7 +339,7 @@ && getAxisForProcessing( ).getOrigin( )

btnLabelVisible = new TristateCheckbox( cmpLabel, SWT.NONE );
btnLabelVisible.setText( Messages.getString( "AbstractAxisSubtask.Label.Visible2" ) ); //$NON-NLS-1$
GridData gd = new GridData( GridData.FILL_HORIZONTAL );
gd = new GridData( GridData.FILL_HORIZONTAL );
btnLabelVisible.setLayoutData( gd );
btnLabelVisible.setSelectionState( getAxisForProcessing( ).getLabel( )
.isSetVisible( ) ? ( getAxisForProcessing( ).getLabel( )
Expand All @@ -348,6 +349,7 @@ && getAxisForProcessing( ).getOrigin( )
btnLabelVisible.addSelectionListener( this );

btnStaggered = new TristateCheckbox( cmpLabel, SWT.NONE );

btnStaggered.setText( Messages.getString( "AbstractAxisSubtask.Label.Stagger" ) ); //$NON-NLS-1$
{
Axis ax = getAxisForProcessing( );
Expand Down
Expand Up @@ -95,7 +95,7 @@ public void createControl( Composite parent )

Group cmpBasic = new Group( cmpContent, SWT.NONE );
{
GridLayout layout = new GridLayout( 3, false );
GridLayout layout = new GridLayout( 4, false );
layout.marginWidth = 10;
layout.marginHeight = 10;
cmpBasic.setLayout( layout );
Expand All @@ -107,36 +107,20 @@ public void createControl( Composite parent )
btnVisible = new TristateCheckbox( cmpBasic, SWT.NONE );
{
GridData gdBTNVisible = new GridData( );
gdBTNVisible.horizontalSpan = 3;
gdBTNVisible.horizontalSpan = 4;
btnVisible.setLayoutData( gdBTNVisible );
btnVisible.setText( Messages.getString( "Shared.mne.Visibile_v" ) );//$NON-NLS-1$
}

lblTitle = new Label( cmpBasic, SWT.NONE );
lblTitle.setText( Messages.getString( "ChartLegendSheetImpl.Label.Title" ) ); //$NON-NLS-1$

Composite titleComp = new Composite( cmpBasic, SWT.NONE );
GridLayout gl = new GridLayout( );
gl.numColumns = 2;
gl.marginLeft = 0;
gl.marginRight = 0;
gl.marginTop = 0;
gl.marginBottom = 0;
titleComp.setLayout( gl );

btnTitleContentAuto = new Button( titleComp, SWT.CHECK );
btnTitleContentAuto.setSelection( getChart( ).getLegend( )
.getTitle( )
.getCaption( )
.getValue( ) == null );
btnTitleContentAuto.addSelectionListener( this );

List<String> keys = null;
if ( getContext( ).getUIServiceProvider( ) != null )
{
keys = getContext( ).getUIServiceProvider( ).getRegisteredKeys( );
}
txtTitle = new ExternalizedTextEditorComposite( titleComp,
txtTitle = new ExternalizedTextEditorComposite( cmpBasic,
SWT.BORDER,
-1,
-1,
Expand All @@ -152,6 +136,14 @@ public void createControl( Composite parent )

btnTitleVisible = new TristateCheckbox( cmpBasic, SWT.NONE );
btnTitleVisible.setText( Messages.getString( "Shared.mne.Visibile_s" ) ); //$NON-NLS-1$

btnTitleContentAuto = new Button( cmpBasic, SWT.CHECK );
btnTitleContentAuto.setText( ChartUIExtensionUtil.getAutoMessage( ) );
btnTitleContentAuto.setSelection( getChart( ).getLegend( )
.getTitle( )
.getCaption( )
.getValue( ) == null );
btnTitleContentAuto.addSelectionListener( this );

lblLegendBehavior = new Label( cmpBasic, SWT.NONE );
{
Expand Down
Expand Up @@ -48,12 +48,11 @@ public class ChartTitleSheetImpl extends SubtaskSheetImpl implements
SelectionListener,
Listener
{

private Button btnTitleContentAuto = null;
private ExternalizedTextEditorComposite txtTitle = null;
private FontDefinitionComposite fdcFont;
private TristateCheckbox btnVisible;
private TristateCheckbox btnAutoTitle;
private Button btnTitleContentAuto;

public void createControl( Composite parent )
{
Expand All @@ -79,29 +78,13 @@ public void createControl( Composite parent )
{
lblTitle.setText( Messages.getString( "ChartTitleSheetImpl.Label.ChartTitle" ) ); //$NON-NLS-1$
}

Composite titleComp = new Composite( cmpBasic, SWT.NONE );
GridLayout gl = new GridLayout( );
gl.numColumns = 2;
gl.marginLeft = 0;
gl.marginRight = 0;
gl.marginTop = 0;
gl.marginBottom = 0;
titleComp.setLayout( gl );

btnTitleContentAuto = new Button( titleComp, SWT.CHECK );
btnTitleContentAuto.setSelection( getChart( ).getTitle( )
.getLabel( )
.getCaption( )
.getValue( ) == null );
btnTitleContentAuto.addSelectionListener( this );

List<String> keys = null;
if ( getContext( ).getUIServiceProvider( ) != null )
{
keys = getContext( ).getUIServiceProvider( ).getRegisteredKeys( );
}
txtTitle = new ExternalizedTextEditorComposite( titleComp,
txtTitle = new ExternalizedTextEditorComposite( cmpBasic,
SWT.BORDER,
-1,
-1,
Expand All @@ -125,20 +108,36 @@ public void createControl( Composite parent )
: TristateCheckbox.STATE_UNSELECTED )
: TristateCheckbox.STATE_GRAYED );
btnVisible.addSelectionListener( this );

btnAutoTitle = new TristateCheckbox( cmpBasic, SWT.NONE );
btnAutoTitle.setText( Messages.getString( "ChartTitleSheetImpl.Text.Auto" ) ); //$NON-NLS-1$
gd = new GridData( );
btnAutoTitle.setLayoutData( gd );
btnAutoTitle.setSelectionState( getChart( ).getTitle( ).isSetAuto( ) ? ( getChart( ).getTitle( )
.isAuto( ) ? TristateCheckbox.STATE_SELECTED : TristateCheckbox.STATE_UNSELECTED )
: TristateCheckbox.STATE_GRAYED );
btnAutoTitle.setEnabled( isAutoEnabled( ) );
boolean autoTitleVisible = getContext( ).getUIFactory( )

boolean dynamicTitleVisible = getContext( ).getUIFactory( )
.createUIHelper( )
.isDefaultTitleSupported( );
btnAutoTitle.setVisible( autoTitleVisible );
btnAutoTitle.addSelectionListener( this );

if ( dynamicTitleVisible )
{
btnAutoTitle = new TristateCheckbox( cmpBasic, SWT.NONE );
btnAutoTitle.setText( Messages.getString( "ChartTitleSheetImpl.Text.Auto" ) ); //$NON-NLS-1$
gd = new GridData( );
btnAutoTitle.setLayoutData( gd );
btnAutoTitle.setSelectionState( getChart( ).getTitle( ).isSetAuto( ) ? ( getChart( ).getTitle( )
.isAuto( ) ? TristateCheckbox.STATE_SELECTED
: TristateCheckbox.STATE_UNSELECTED )
: TristateCheckbox.STATE_GRAYED );
btnAutoTitle.setEnabled( isAutoEnabled( ) );

btnAutoTitle.setVisible( dynamicTitleVisible );
btnAutoTitle.addSelectionListener( this );
}
else
{
btnTitleContentAuto = new Button( cmpBasic, SWT.CHECK );
btnTitleContentAuto.setText( Messages.getString( "ChartTitleSheetImpl.Text.Auto" ) ); //$NON-NLS-1$
btnTitleContentAuto.setSelection( getChart( ).getTitle( )
.getLabel( )
.getCaption( )
.getValue( ) == null );
btnTitleContentAuto.addSelectionListener( this );
}

Label lblFont = new Label( cmpBasic, SWT.NONE );
lblFont.setText( Messages.getString( "LabelAttributesComposite.Lbl.Font" ) ); //$NON-NLS-1$
Expand Down Expand Up @@ -301,27 +300,34 @@ else if ( e.widget == btnTitleContentAuto )
}
else
{
String title = ChartUIUtil.getChartType( getChart().getType( ) ).getDefaultTitle( );
getChart( ).getTitle( ).getLabel( ).getCaption( ).setValue( title );
getChart( ).getTitle( )
.getLabel( )
.getCaption( )
.setValue( ChartUIUtil.getChartType( getChart( ).getType( ) )
.getDefaultTitle( ) );
}
updateTextTitleState( );
}
}

protected void updateTextTitleState( )
{
btnTitleContentAuto.setEnabled( getChart( ).getTitle( ).isSetVisible( )
&& getChart( ).getTitle( ).isVisible( )
&& !isAutoTitle( ) );
txtTitle.setEnabled( isTitleEnabled( ) );
txtTitle.setText( getTitleText( ) );
}

protected void updateUIState( boolean enabled )
{
btnTitleContentAuto.setEnabled( enabled && !isAutoTitle( ) );
if ( btnTitleContentAuto != null )
{
btnTitleContentAuto.setEnabled( !( getChart( ).getTitle( )
.isSetVisible( ) && !getChart( ).getTitle( ).isVisible( ) ) );
}
txtTitle.setEnabled( isTitleEnabled( ) );
btnAutoTitle.setEnabled( isAutoEnabled( ) );
if ( btnAutoTitle != null )
{
btnAutoTitle.setEnabled( isAutoEnabled( ) );
}
setToggleButtonEnabled( BUTTON_TEXT, enabled );
setToggleButtonEnabled( BUTTON_LAYOUT, enabled );
}
Expand All @@ -340,10 +346,19 @@ private boolean isAutoEnabled( )

private boolean isTitleEnabled( )
{
return getChart( ).getTitle( ).isSetVisible( )
&& getChart( ).getTitle( ).isVisible( )
&& getChart( ).getTitle( ).getLabel( ).getCaption( ).getValue( ) != null
&& !isAutoTitle( );
if ( btnAutoTitle != null )
{
return getChart( ).getTitle( ).isSetVisible( )
&& getChart( ).getTitle( ).isVisible( )
&& !isAutoTitle( );
}
else
{
return getChart( ).getTitle( ).isSetVisible( )
&& getChart( ).getTitle( ).isVisible( )
&& getChart( ).getTitle( ).getLabel( ).getCaption( ).getValue( ) != null
&& !isAutoTitle( );
}
}

protected boolean isAutoTitle( )
Expand Down

0 comments on commit 3407a8d

Please sign in to comment.