public void widgetSelected(SelectionEvent e) { if (e.getSource().equals(fBtnBaseURL)) { try { if (fContext != null) { fsBaseURL = fContext .getUIServiceProvider() .invoke( getHyperlinkBuilderCommand(), fsBaseURL, fContext.getExtendedItem(), null); } } catch (ChartException ex) { WizardBase.displayException(ex); } } else if (e.getSource().equals(fBtnAdvanced)) { bAdvanced = !bAdvanced; fBtnAdvanced.setText(getAdvancedButtonText(bAdvanced)); fGrpParameters.setVisible(bAdvanced); ((Composite) this.getDialogArea()).layout(true, true); } }
/** * @param glURL * @param glParameter */ private void createURLComposite(Composite parent) { GridLayout gl = (GridLayout) parent.getLayout(); gl.numColumns = 2; Label lblTarget = new Label(parent, SWT.NONE); GridData gdLBLTarget = new GridData(); gdLBLTarget.horizontalIndent = 2; lblTarget.setLayoutData(gdLBLTarget); lblTarget.setText(Messages.getString("HyperlinkEditorDialog.Text.MenuLabel")); // $NON-NLS-1$ fTxtHyperlinkLabel = new Text(parent, SWT.BORDER); GridData gdTXTTarget = new GridData(GridData.FILL_HORIZONTAL); gdTXTTarget.widthHint = 80; fTxtHyperlinkLabel.setLayoutData(gdTXTTarget); AssistField af = new TextAssistField(fTxtHyperlinkLabel, null) { private boolean fIsDuplicate = false; /* (non-Javadoc) * @see org.eclipse.birt.chart.ui.swt.fieldassist.TextAssistField#isValid() */ public boolean isValid() { fIsDuplicate = false; String text = fTxtHyperlinkLabel.getText(); if (text == null || "".equals(text.trim())) { // $NON-NLS-1$ return false; } if (fExistingLabels != null && fExistingLabels.contains(fTxtHyperlinkLabel.getText())) { fIsDuplicate = true; return false; } return true; } /* (non-Javadoc) * @see org.eclipse.birt.chart.ui.swt.fieldassist.AssistField#isRequiredField() */ public boolean isRequiredField() { return true; } public String getErrorMessage() { if (fIsDuplicate) { return Messages.getString( "HyperlinkEditorDialog.ErrorMessage.ExistingText"); //$NON-NLS-1$ } return Messages.getString("HyperlinkEditorDialog.ErrorMessage.NullText"); // $NON-NLS-1$ } }; FieldAssistHelper.getInstance().addRequiredFieldIndicator(af, lblTarget); Label lblBaseURL = new Label(parent, SWT.NONE); GridData gdLBLBaseURL = new GridData(); gdLBLBaseURL.horizontalIndent = 2; lblBaseURL.setLayoutData(gdLBLBaseURL); lblBaseURL.setText(Messages.getString("TriggerDataComposite.Lbl.BaseURL")); // $NON-NLS-1$ fBtnBaseURL = new Button(parent, SWT.NONE); { GridData gd = new GridData(); fBtnBaseURL.setLayoutData(gd); fBtnBaseURL.setText( Messages.getString("TriggerDataComposite.Text.EditBaseURL")); // $NON-NLS-1$ fBtnBaseURL.setToolTipText( Messages.getString("TriggerDataComposite.Tooltip.InvokeURLBuilder")); // $NON-NLS-1$ fBtnBaseURL.addSelectionListener(this); fBtnBaseURL.setEnabled(fContext.getUIServiceProvider().isInvokingSupported()); } Label lblDefine = new Label(parent, SWT.WRAP); { GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 2; gd.horizontalSpan = 3; gd.widthHint = 200; lblDefine.setLayoutData(gd); lblDefine.setText( Messages.getString("TriggerDataComposite.Label.Description")); // $NON-NLS-1$ } fBtnAdvanced = new Button(parent, SWT.NONE); { GridData gd = new GridData(); gd.horizontalSpan = 2; fBtnAdvanced.setLayoutData(gd); fBtnAdvanced.setText(getAdvancedButtonText(bAdvanced)); fBtnAdvanced.setToolTipText( Messages.getString("TriggerDataComposite.Tooltip.Advanced")); // $NON-NLS-1$ fBtnAdvanced.addSelectionListener(this); fBtnAdvanced.setEnabled(fbEnableURLParameters); } fGrpParameters = new Group(parent, SWT.NONE); GridData gdGRPParameters = new GridData(GridData.FILL_HORIZONTAL); gdGRPParameters.horizontalSpan = 3; fGrpParameters.setLayoutData(gdGRPParameters); GridLayout glParameter = new GridLayout(); glParameter.marginWidth = 2; glParameter.marginHeight = 6; glParameter.horizontalSpacing = 6; glParameter.numColumns = 3; fGrpParameters.setLayout(glParameter); fGrpParameters.setText( Messages.getString("TriggerDataComposite.Lbl.ParameterNames")); // $NON-NLS-1$ fGrpParameters.setVisible(bAdvanced); StyledText stParameters = new StyledText(fGrpParameters, SWT.WRAP | SWT.READ_ONLY); { GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 2; gd.horizontalSpan = 3; gd.widthHint = 200; stParameters.setLayoutData(gd); stParameters.setText( Messages.getString("TriggerDataComposite.Label.OptionalURLParameters")); // $NON-NLS-1$ stParameters.setBackground(parent.getBackground()); } Label lblBaseParm = new Label(fGrpParameters, SWT.NONE); { GridData gdLBLBaseParm = new GridData(); gdLBLBaseParm.horizontalIndent = 2; lblBaseParm.setLayoutData(gdLBLBaseParm); lblBaseParm.setText( Messages.getString("TriggerDataComposite.Lbl.CategorySeries")); // $NON-NLS-1$ lblBaseParm.setToolTipText( Messages.getString("TriggerDataComposite.Tooltip.ParameterCategory")); // $NON-NLS-1$ } fTxtBaseParm = new Text(fGrpParameters, SWT.BORDER); GridData gdTXTBaseParm = new GridData(GridData.FILL_HORIZONTAL); gdTXTBaseParm.horizontalSpan = 2; fTxtBaseParm.setLayoutData(gdTXTBaseParm); fTxtBaseParm.setToolTipText( Messages.getString("TriggerDataComposite.Tooltip.ParameterCategory")); // $NON-NLS-1$ fTxtBaseParm.setEnabled( fbEnableURLParameters && ((fOptionalStyle & TriggerDataComposite.DISABLE_CATEGORY_SERIES) != TriggerDataComposite.DISABLE_CATEGORY_SERIES)); Label lblValueParm = new Label(fGrpParameters, SWT.NONE); { GridData gdLBLValueParm = new GridData(); gdLBLValueParm.horizontalIndent = 2; lblValueParm.setLayoutData(gdLBLValueParm); lblValueParm.setText( Messages.getString("TriggerDataComposite.Lbl.ValueSeries")); // $NON-NLS-1$ lblValueParm.setToolTipText( Messages.getString("TriggerDataComposite.Tooltip.ParameterValue")); // $NON-NLS-1$ } fTxtValueParm = new Text(fGrpParameters, SWT.BORDER); GridData gdTXTValueParm = new GridData(GridData.FILL_HORIZONTAL); gdTXTValueParm.horizontalSpan = 2; fTxtValueParm.setLayoutData(gdTXTValueParm); fTxtValueParm.setToolTipText( Messages.getString("TriggerDataComposite.Tooltip.ParameterValue")); // $NON-NLS-1$ fTxtValueParm.setEnabled( fbEnableURLParameters && ((fOptionalStyle & TriggerDataComposite.DISABLE_VALUE_SERIES) != TriggerDataComposite.DISABLE_VALUE_SERIES)); Label lblSeriesParm = new Label(fGrpParameters, SWT.NONE); { GridData gdLBLSeriesParm = new GridData(); gdLBLSeriesParm.horizontalIndent = 2; lblSeriesParm.setLayoutData(gdLBLSeriesParm); lblSeriesParm.setText( Messages.getString("TriggerDataComposite.Lbl.ValueSeriesName")); // $NON-NLS-1$ lblSeriesParm.setToolTipText( Messages.getString("TriggerDataComposite.Tooltip.ParameterSeries")); // $NON-NLS-1$ } fTxtSeriesParm = new Text(fGrpParameters, SWT.BORDER); GridData gdTXTSeriesParm = new GridData(GridData.FILL_HORIZONTAL); gdTXTSeriesParm.horizontalSpan = 2; fTxtSeriesParm.setLayoutData(gdTXTSeriesParm); fTxtSeriesParm.setToolTipText( Messages.getString("TriggerDataComposite.Tooltip.ParameterSeries")); // $NON-NLS-1$ fTxtSeriesParm.setEnabled( fbEnableURLParameters && ((fOptionalStyle & TriggerDataComposite.DISABLE_VALUE_SERIES_NAME) != TriggerDataComposite.DISABLE_VALUE_SERIES_NAME)); }
public void launch(String filePath) { try { // add radar type Class<?> claexten = Class.forName( "org.eclipse.birt.chart.ui.swt.wizard.ChartUIExtensionsImpl"); //$NON-NLS-1$ Field saTypes = claexten.getDeclaredField("saTypes"); // $NON-NLS-1$ saTypes.setAccessible(true); saTypes.set( null, new String[] { "org.eclipse.birt.chart.ui.swt.type.BarChart", "org.eclipse.birt.chart.ui.swt.type.LineChart", //$NON-NLS-1$ //$NON-NLS-2$ "org.eclipse.birt.chart.ui.swt.type.AreaChart", "org.eclipse.birt.chart.ui.swt.type.PieChart", //$NON-NLS-1$ //$NON-NLS-2$ "org.eclipse.birt.chart.ui.swt.type.MeterChart", "org.eclipse.birt.chart.ui.swt.type.ScatterChart", //$NON-NLS-1$ //$NON-NLS-2$ "org.eclipse.birt.chart.ui.swt.type.StockChart", "org.eclipse.birt.chart.ui.swt.type.GanttChart", //$NON-NLS-1$ //$NON-NLS-2$ "org.eclipse.birt.chart.ui.swt.type.BubbleChart", "org.eclipse.birt.chart.ui.swt.type.DifferenceChart", //$NON-NLS-1$ //$NON-NLS-2$ "org.eclipse.birt.chart.ui.swt.type.TubeChart", "org.eclipse.birt.chart.ui.swt.type.ConeChart", //$NON-NLS-1$ //$NON-NLS-2$ "org.eclipse.birt.chart.ui.swt.type.PyramidChart", //$NON-NLS-1$ "org.eclipse.birt.chart.examples.radar.ui.type.RadarChart" //$NON-NLS-1$ }); // add ui provider Field saSeriesUI = claexten.getDeclaredField("saSeriesUI"); // $NON-NLS-1$ saSeriesUI.setAccessible(true); saSeriesUI.set( null, new String[] { "org.eclipse.birt.chart.ui.swt.series.SeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.AreaSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.BarSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.LineSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.MeterSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.PieSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.ScatterSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.StockSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.GanttSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.BubbleSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.ui.swt.series.DifferenceSeriesUIProvider", //$NON-NLS-1$ "org.eclipse.birt.chart.examples.radar.ui.series.RadarSeriesUIProvider" //$NON-NLS-1$ }); // plugin settings Class<?> claps = Class.forName("org.eclipse.birt.chart.util.PluginSettings"); // $NON-NLS-1$ Field saDataSetProcessors = claps.getDeclaredField("saDataSetProcessors"); // $NON-NLS-1$ saDataSetProcessors.setAccessible(true); saDataSetProcessors.set( null, new String[] { "org.eclipse.birt.chart.extension.datafeed.DataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.DataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.DataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.DataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.DataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.DataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.StockDataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.DataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.BubbleDataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.GanttDataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.DifferenceDataSetProcessorImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.datafeed.DataSetProcessorImpl", //$NON-NLS-1$ }); Field saRenderers = claps.getDeclaredField("saRenderers"); // $NON-NLS-1$ saRenderers.setAccessible(true); saRenderers.set( null, new String[] { null, "org.eclipse.birt.chart.extension.render.Area", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Bar", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Dial", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Line", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Pie", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Stock", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Scatter", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Bubble", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Gantt", //$NON-NLS-1$ "org.eclipse.birt.chart.extension.render.Difference", //$NON-NLS-1$ "org.eclipse.birt.chart.examples.radar.render.Radar" //$NON-NLS-1$ }); Field saSeries = claps.getDeclaredField("saSeries"); // $NON-NLS-1$ saSeries.setAccessible(true); saSeries.set( null, new String[] { "org.eclipse.birt.chart.model.component.impl.SeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.AreaSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.BarSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.DialSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.LineSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.PieSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.StockSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.ScatterSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.BubbleSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.GanttSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.model.type.impl.DifferenceSeriesImpl", //$NON-NLS-1$ "org.eclipse.birt.chart.examples.radar.model.type.impl.RadarSeriesImpl" //$NON-NLS-1$ }); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } // Create display Display.getDefault(); // Set standalone mode rather than OSGI mode PlatformConfig config = new PlatformConfig(); config.setProperty("STANDALONE", "true"); // $NON-NLS-1$ //$NON-NLS-2$ ChartEngine.instance(config); final SampleStandardDataSheet ssd = new SampleStandardDataSheet(); if (!UIHelper.isEclipseMode()) { // Registers the wizard task and the chart wizard try { TasksManager.instance().registerTask(TaskSelectType.class.getName(), new TaskSelectType()); TasksManager.instance() .registerTask( TaskSelectData.class.getName(), new TaskSelectData() { @Override public void doPreview() { super.doPreview(); ssd.refreshSampleDataPreiview(); } }); TasksManager.instance() .registerTask(TaskFormatChart.class.getName(), new TaskFormatChart()); String sChartTasks = TaskSelectType.class.getName() + "," + TaskSelectData.class.getName() + "," + TaskFormatChart.class.getName(); // $NON-NLS-1$ //$NON-NLS-2$ TasksManager.instance() .registerWizard(ChartWizard.class.getName(), sChartTasks, ""); // $NON-NLS-1$ } catch (Exception e) { WizardBase.displayException(e); } } Chart chart = null; Serializer serializer = null; final File chartFile = new File(filePath); // Reads the chart model InputStream is = null; try { serializer = SerializerImpl.instance(); if (chartFile.exists()) { is = new FileInputStream(chartFile); chart = serializer.read(is); } } catch (Exception e) { // WizardBase.displayException( e ); } finally { if (is != null) { try { is.close(); } catch (IOException e) { } } } // Configures the chart wizard. final ChartWizard chartWizard = new ChartWizard(); // Customized data provider and data sheet as below IDataServiceProvider dataProvider = new DefaultDataServiceProviderImpl(); // Create context final ChartWizardContext context = new ChartWizardContext( chart, new SimpleUIServiceProviderImpl(), null, dataProvider, ssd, new ChartUIFactory()); ((SimpleUIServiceProviderImpl) context.getUIServiceProvider()) .setFormatSpecifierHandler(new FormatSpecifierHandler()); ssd.setContext(context); // Use these methods to disable the UI you want. context.setEnabled(SUBTASK_TITLE, false); context.setEnabled(SUBTASK_LEGEND + BUTTON_LAYOUT, false); context.setEnabled(SUBTASK_SERIES_Y + BUTTON_LABEL, false); context.setEnabled(SUBTASK_SERIES_Y + BUTTON_CURVE, false); // Add predefined queries to select in data sheet context.addPredefinedQuery( QUERY_CATEGORY, new String[] { "row[\"abc\"]", "abc" // $NON-NLS-1$ //$NON-NLS-2$ }); context.addPredefinedQuery(QUERY_VALUE, new String[] {}); context.setRtL(ChartUtil.isRightToLeftLocale(ULocale.getDefault())); // This array is for storing the latest chart data before pressing // apply button final Object[] applyData = new Object[1]; // Add Apply button chartWizard.addCustomButton( new ApplyButtonHandler(chartWizard) { public void run() { super.run(); // Save the data when applying applyData[0] = context.getModel().copyInstance(); } }); ChartLivePreviewThread livePreviewThread = new ChartLivePreviewThread(dataProvider); livePreviewThread.start(); context.setLivePreviewThread(livePreviewThread); // Opens the wizard ChartWizardContext contextResult = (ChartWizardContext) chartWizard.open(context); OutputStream os = null; try { if (contextResult != null) { os = new FileOutputStream(chartFile); // Pressing Finish serializer.write(contextResult.getModel(), os); } else if (applyData[0] != null) { os = new FileOutputStream(chartFile); // Pressing Cancel but Apply was pressed before, so revert to // the point pressing Apply serializer.write((Chart) applyData[0], os); } } catch (Exception e) { WizardBase.displayException(e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } } }