Code Search for Developers
 
 
  

GanttSeriesAttributeComposite.java from BIRT at Krugle


Show GanttSeriesAttributeComposite.java syntax highlighted

/***********************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Actuate Corporation - initial API and implementation
 ***********************************************************************/

package org.eclipse.birt.chart.ui.swt.series;

import org.eclipse.birt.chart.exception.ChartException;
import org.eclipse.birt.chart.log.ILogger;
import org.eclipse.birt.chart.log.Logger;
import org.eclipse.birt.chart.model.attribute.ColorDefinition;
import org.eclipse.birt.chart.model.attribute.LineStyle;
import org.eclipse.birt.chart.model.attribute.Marker;
import org.eclipse.birt.chart.model.attribute.MarkerType;
import org.eclipse.birt.chart.model.attribute.impl.MarkerImpl;
import org.eclipse.birt.chart.model.component.Series;
import org.eclipse.birt.chart.model.type.GanttSeries;
import org.eclipse.birt.chart.ui.extension.i18n.Messages;
import org.eclipse.birt.chart.ui.plugin.ChartUIExtensionPlugin;
import org.eclipse.birt.chart.ui.swt.composites.FillChooserComposite;
import org.eclipse.birt.chart.ui.swt.composites.GanttLineAttributesComposite;
import org.eclipse.birt.chart.ui.swt.composites.LineAttributesComposite;
import org.eclipse.birt.chart.ui.swt.composites.MarkerEditorComposite;
import org.eclipse.birt.chart.ui.swt.wizard.ChartWizardContext;
import org.eclipse.birt.chart.ui.util.ChartHelpContextIds;
import org.eclipse.birt.chart.ui.util.ChartUIUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;

public class GanttSeriesAttributeComposite extends Composite implements
		SelectionListener,
		Listener
{

	private transient Group grpMarkerStart = null;

	private transient Group grpMarkerEnd = null;

	private transient Button btnDecoration = null;

	private transient Button btnPalette = null;

	private transient FillChooserComposite fccFill = null;

	private transient Group grpLine = null;

	private transient GanttLineAttributesComposite gliacGantt = null;

	private transient Group grpOutline = null;

	private transient LineAttributesComposite oliacGantt = null;

	private transient GanttSeries series = null;

	private transient ChartWizardContext context;

	private static ILogger logger = Logger.getLogger( "org.eclipse.birt.chart.ui.extension/swt.series" ); //$NON-NLS-1$

	/**
	 * @param parent
	 * @param style
	 */
	public GanttSeriesAttributeComposite( Composite parent, int style,
			ChartWizardContext context, Series series )
	{
		super( parent, style );
		if ( !( series instanceof GanttSeries ) )
		{
			try
			{
				throw new ChartException( ChartUIExtensionPlugin.ID,
						ChartException.VALIDATION,
						"GanttSeriesAttributeComposite.Exception.IllegalArgument", new Object[]{series.getClass( ).getName( )}, Messages.getResourceBundle( ) ); //$NON-NLS-1$
			}
			catch ( ChartException e )
			{
				logger.log( e );
				e.printStackTrace( );
			}
		}
		this.series = (GanttSeries) series;
		this.context = context;
		init( );
		placeComponents( );
		ChartUIUtil.bindHelp( parent, ChartHelpContextIds.SUBTASK_YSERIES_BAR );
	}

	private void init( )
	{
		this.setSize( getParent( ).getClientArea( ).width,
				getParent( ).getClientArea( ).height );
	}

	private void placeComponents( )
	{
		// Layout for content composite
		GridLayout glContent = new GridLayout( );
		glContent.numColumns = 8;
		glContent.marginHeight = 2;
		glContent.marginWidth = 2;

		// Main content composite
		this.setLayout( glContent );

		// Layout for the Marker group
		GridLayout glMarker = new GridLayout( );
		glMarker.marginHeight = 4;
		glMarker.marginWidth = 4;
		glMarker.verticalSpacing = 4;
		glMarker.horizontalSpacing = 4;

		Composite cmpMarker = new Composite( this, SWT.NONE );
		cmpMarker.setLayout( new GridLayout( ) );
		GridData gdMarker = new GridData( GridData.FILL_BOTH );
		gdMarker.horizontalSpan = 2;
		cmpMarker.setLayoutData( gdMarker );

		// Layout for the Start Marker
		grpMarkerStart = new Group( cmpMarker, SWT.NONE );
		grpMarkerStart.setLayoutData( new GridData( GridData.FILL_BOTH ) );
		grpMarkerStart.setLayout( glMarker );
		grpMarkerStart.setText( Messages.getString( "GanttSeriesAttributeComposite.Lbl.StartMarker" ) ); //$NON-NLS-1$

		new MarkerEditorComposite( grpMarkerStart,
				createMarker( ( (GanttSeries) series ).getStartMarker( ) ) );

		// Layout for the End Marker
		grpMarkerEnd = new Group( cmpMarker, SWT.NONE );
		grpMarkerEnd.setLayoutData( new GridData( GridData.FILL_BOTH ) );
		grpMarkerEnd.setLayout( glMarker );
		grpMarkerEnd.setText( Messages.getString( "GanttSeriesAttributeComposite.Lbl.EndMarker" ) ); //$NON-NLS-1$

		new MarkerEditorComposite( grpMarkerEnd,
				createMarker( ( (GanttSeries) series ).getEndMarker( ) ) );

		// Layout for Connection Line
		grpLine = new Group( this, SWT.NONE );
		GridData gdGRPLine = new GridData( GridData.FILL_BOTH );
		gdGRPLine.horizontalSpan = 2;
		grpLine.setLayout( new FillLayout( ) );
		grpLine.setLayoutData( gdGRPLine );
		grpLine.setText( Messages.getString( "GanttSeriesAttributeComposite.Lbl.Line" ) ); //$NON-NLS-1$

		gliacGantt = new GanttLineAttributesComposite( grpLine,
				context,
				SWT.NONE,
				( (GanttSeries) series ).getConnectionLine( ),
				true,
				true,
				true );
		gliacGantt.addListener( this );

		// Layout for Outine
		grpOutline = new Group( this, SWT.NONE );
		GridData gdGRPOutline = new GridData( GridData.FILL_BOTH );
		gdGRPOutline.horizontalSpan = 2;
		grpOutline.setLayout( new FillLayout( ) );
		grpOutline.setLayoutData( gdGRPOutline );
		grpOutline.setText( Messages.getString( "GanttSeriesAttributeComposite.Lbl.Outline" ) ); //$NON-NLS-1$

		oliacGantt = new LineAttributesComposite( grpOutline,
				SWT.NONE,
				context,
				( (GanttSeries) series ).getOutline( ),
				true,
				true,
				true );
		oliacGantt.addListener( this );

		Composite cmpFill = new Composite( this, SWT.NONE );
		cmpFill.setLayout( new GridLayout( ) );
		GridData gdFill = new GridData( GridData.FILL_BOTH );
		gdFill.horizontalSpan = 2;
		cmpMarker.setLayoutData( gdFill );

		Label lblFill = new Label( cmpFill, SWT.NONE );
		GridData gdLBLFill = new GridData( );
		lblFill.setLayoutData( gdLBLFill );
		lblFill.setText( Messages.getString( "GanttSeriesAttributeComposite.Lbl.OutlineFill" ) ); //$NON-NLS-1$

		fccFill = new FillChooserComposite( cmpFill,
				SWT.NONE,
				context,
				( (GanttSeries) series ).getOutlineFill( ),
				false,
				false );
		fccFill.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
		fccFill.addListener( this );

		btnDecoration = new Button( cmpFill, SWT.CHECK );
		{
			btnDecoration.setText( Messages.getString( "GanttSeriesAttributeComposite.Lbl.UseDecoration" ) ); //$NON-NLS-1$
			btnDecoration.setSelection( ( (GanttSeries) series ).isUseDecorationLabelValue( ) );
			btnDecoration.addSelectionListener( this );
		}

		btnPalette = new Button( cmpFill, SWT.CHECK );
		{
			btnPalette.setText( Messages.getString( "GanttSeriesAttributeComposite.Lbl.LinePalette" ) ); //$NON-NLS-1$
			btnPalette.setSelection( ( (GanttSeries) series ).isPaletteLineColor( ) );
			btnPalette.addSelectionListener( this );
		}

	}

	public Point getPreferredSize( )
	{
		return new Point( 400, 200 );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
	 */
	public void widgetSelected( SelectionEvent e )
	{
		if ( e.getSource( ).equals( btnDecoration ) )
		{
			( (GanttSeries) series ).setUseDecorationLabelValue( btnDecoration.getSelection( ) );
		}
		else if ( e.getSource( ).equals( btnPalette ) )
		{
			( (GanttSeries) series ).setPaletteLineColor( btnPalette.getSelection( ) );
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
	 */
	public void widgetDefaultSelected( SelectionEvent e )
	{
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
	 */
	public void handleEvent( Event event )
	{
		if ( event.widget.equals( gliacGantt ) )
		{
			if ( event.type == GanttLineAttributesComposite.VISIBILITY_CHANGED_EVENT )
			{
				( (GanttSeries) series ).getConnectionLine( )
						.setVisible( ( (Boolean) event.data ).booleanValue( ) );
			}
			else if ( event.type == GanttLineAttributesComposite.STYLE_CHANGED_EVENT )
			{
				( (GanttSeries) series ).getConnectionLine( )
						.setStyle( (LineStyle) event.data );
			}
			else if ( event.type == GanttLineAttributesComposite.WIDTH_CHANGED_EVENT )
			{
				( (GanttSeries) series ).getConnectionLine( )
						.setThickness( ( (Integer) event.data ).intValue( ) );
			}
			else if ( event.type == GanttLineAttributesComposite.COLOR_CHANGED_EVENT )
			{
				( (GanttSeries) series ).getConnectionLine( )
						.setColor( (ColorDefinition) event.data );
			}
		}
		else if ( event.widget.equals( oliacGantt ) )
		{
			if ( event.type == LineAttributesComposite.VISIBILITY_CHANGED_EVENT )
			{
				( (GanttSeries) series ).getOutline( )
						.setVisible( ( (Boolean) event.data ).booleanValue( ) );
			}
			else if ( event.type == LineAttributesComposite.STYLE_CHANGED_EVENT )
			{
				( (GanttSeries) series ).getOutline( )
						.setStyle( (LineStyle) event.data );
			}
			else if ( event.type == LineAttributesComposite.WIDTH_CHANGED_EVENT )
			{
				( (GanttSeries) series ).getOutline( )
						.setThickness( ( (Integer) event.data ).intValue( ) );
			}
			else if ( event.type == LineAttributesComposite.COLOR_CHANGED_EVENT )
			{
				( (GanttSeries) series ).getOutline( )
						.setColor( (ColorDefinition) event.data );
			}
		}
	}

	private Marker createMarker( Marker marker )
	{
		if ( marker == null )
		{
			marker = MarkerImpl.create( MarkerType.NABLA_LITERAL, 4 );
			marker.eAdapters( ).addAll( series.eAdapters( ) );
		}
		return marker;
	}
}



See more files for this project here

BIRT

BIRT is an open source, Eclipse-based reporting system that integrates with your application to produce compelling reports for both web and PDF.

Project homepage: http://www.eclipse.org/birt/phoenix/
Programming language(s): Java,XML
License: gpl2

  AreaSeriesUIProvider.java
  BarSeriesAttributeComposite.java
  BarSeriesUIProvider.java
  BubbleDataDefinitionComponent.java
  BubbleSeriesAttributeComposite.java
  BubbleSeriesUIProvider.java
  DifferenceDataDefinitionComponent.java
  DifferenceSeriesAttributeComposite.java
  DifferenceSeriesUIProvider.java
  GanttDataDefinitionComponent.java
  GanttSeriesAttributeComposite.java
  GanttSeriesUIProvider.java
  LineSeriesAttributeComposite.java
  LineSeriesUIProvider.java
  MeterSeriesAttributeComposite.java
  MeterSeriesUIProvider.java
  PieSeriesAttributeComposite.java
  PieSeriesUIProvider.java
  ScatterSeriesUIProvider.java
  SeriesUIProvider.java
  StockDataDefinitionComponent.java
  StockSeriesAttributeComposite.java
  StockSeriesUIProvider.java