1 11 12 package org.eclipse.birt.chart.examples.builder; 13 14 import java.io.File ; 15 import java.io.FileInputStream ; 16 import java.io.FileOutputStream ; 17 18 import org.eclipse.birt.chart.model.Chart; 19 import org.eclipse.birt.chart.model.Serializer; 20 import org.eclipse.birt.chart.model.impl.SerializerImpl; 21 import org.eclipse.birt.chart.ui.swt.DefaultUIServiceProviderImpl; 22 import org.eclipse.birt.chart.ui.swt.wizard.ChartWizard; 23 import org.eclipse.birt.chart.ui.swt.wizard.ChartWizardContext; 24 import org.eclipse.birt.chart.ui.swt.wizard.TaskFormatChart; 25 import org.eclipse.birt.chart.ui.swt.wizard.TaskSelectData; 26 import org.eclipse.birt.chart.ui.swt.wizard.TaskSelectType; 27 import org.eclipse.birt.core.ui.frameworks.taskwizard.TasksManager; 28 import org.eclipse.birt.core.ui.frameworks.taskwizard.WizardBase; 29 import org.eclipse.birt.core.ui.utils.UIHelper; 30 import org.eclipse.swt.widgets.Display; 31 32 45 public class ChartWizardLauncher 46 { 47 48 public static void main( String [] args ) 49 { 50 init( ); 51 52 Chart chart = null; 53 Serializer serializer = null; 54 File chartFile = new File ( "testChart.chart" ); 56 try 58 { 59 serializer = SerializerImpl.instance( ); 60 if ( chartFile.exists( ) ) 61 { 62 63 chart = serializer.read( new FileInputStream ( chartFile ) ); 64 } 65 } 66 catch ( Exception e ) 67 { 68 WizardBase.displayException( e ); 69 } 70 71 ChartWizard chartWizard = new ChartWizard( ); 73 ChartWizardContext context = new ChartWizardContext( chart ); 74 75 81 context.setDataServiceProvider( new DefaultDataServiceProviderImpl( ) ); 82 89 context.setUIServiceProvider( new DefaultUIServiceProviderImpl( ) ); 90 91 context = (ChartWizardContext) chartWizard.open( context ); 93 94 if ( context != null ) 96 { 97 chart = context.getModel( ); 98 try 99 { 100 serializer.write( chart, new FileOutputStream ( chartFile ) ); 101 } 102 catch ( Exception e ) 103 { 104 WizardBase.displayException( e ); 105 } 106 } 107 else 108 { 109 System.out.println( "Wizard was cancelled!" ); } 111 } 112 113 static void init( ) 114 { 115 Display.getDefault( ); 117 118 if ( !UIHelper.isEclipseMode( ) ) 119 { 120 try 122 { 123 TasksManager.instance( ) 124 .registerTask( "org.eclipse.birt.chart.ui.swt.wizard.TaskSelectType", new TaskSelectType( ) ); 126 TasksManager.instance( ) 127 .registerTask( "org.eclipse.birt.chart.ui.swt.wizard.TaskSelectData", new TaskSelectData( ) ); 129 TasksManager.instance( ) 130 .registerTask( "org.eclipse.birt.chart.ui.swt.wizard.TaskFormatChart", new TaskFormatChart( ) ); 132 String sChartTasks = "org.eclipse.birt.chart.ui.swt.wizard.TaskSelectType,org.eclipse.birt.chart.ui.swt.wizard.TaskSelectData,org.eclipse.birt.chart.ui.swt.wizard.TaskFormatChart"; TasksManager.instance( ) 134 .registerWizard( "org.eclipse.birt.chart.ui.ChartWizard", sChartTasks, 136 "" ); } 138 catch ( Exception e ) 139 { 140 WizardBase.displayException( e ); 141 } 142 } 143 } 144 } 145 | Popular Tags |