From 51b61792f5cac203c91a8de89d1d9f7eba918602 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Thu, 19 Jan 2006 14:19:07 +0000 Subject: [PATCH] Remove RunSharpReport.cs, Extract some Commands for SharpReportView and FieldsExplorer git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1008 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/AddIns/Misc/SharpReport/SharpReport.sln | 2 +- .../AbstractSharpReportCommand.cs | 10 ++- .../Commands/RunSharpReport.cs | 37 ---------- .../SharpReportAddin/Commands/ViewCommands.cs | 55 +++++++++++++++ .../FieldsExplorer/FieldsExplorer.cs | 27 +++----- .../SharpReportAddin/SharpReportAddin.csproj | 2 +- .../SharpReportDisplayBinding.cs | 17 ++++- .../SharpReportAddin/SharpReportView.cs | 67 +++++++++++-------- .../Printing/FormatOutputEventArgs.cs | 37 ++-------- 9 files changed, 137 insertions(+), 117 deletions(-) delete mode 100644 src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/RunSharpReport.cs create mode 100644 src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ViewCommands.cs diff --git a/src/AddIns/Misc/SharpReport/SharpReport.sln b/src/AddIns/Misc/SharpReport/SharpReport.sln index ac2b98f762..5918c97f8d 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport.sln +++ b/src/AddIns/Misc/SharpReport/SharpReport.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.0.0.1001 +# SharpDevelop 2.0.0.1004 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReportCore", "SharpReportCore\SharpReportCore.csproj", "{4B2239FF-8FD6-431D-9D22-1B8049BA6917}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReport", "SharpReport\SharpReport.csproj", "{F5563727-8309-4AC3-BACA-EB28EFD8A1D0}" diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/AbstractCommand/AbstractSharpReportCommand.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/AbstractCommand/AbstractSharpReportCommand.cs index 5d9e163162..fc20195f7e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/AbstractCommand/AbstractSharpReportCommand.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/AbstractCommand/AbstractSharpReportCommand.cs @@ -29,9 +29,13 @@ namespace SharpReportAddin.Commands { /// /// protected AbstractSharpReportCommand() : base() { - view = (SharpReportView)WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent; - if (view == null) { - throw new NullReferenceException ("AbstractSharpCommand : No view available"); + try { + view = (SharpReportView)WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent; + if (view == null) { + throw new NullReferenceException ("AbstractSharpCommand : No view available"); + } + } catch (Exception) { + throw; } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/RunSharpReport.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/RunSharpReport.cs deleted file mode 100644 index 6e6c81211d..0000000000 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/RunSharpReport.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Created by SharpDevelop. - * User: Forstmeier Peter - * Date: 14.11.2004 - * Time: 17:58 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ -using System; -using System.Windows.Forms; - -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Gui; - - -/// -///Main Command to Run SharpReport Addin -/// -namespace SharpReportAddin.Commands { - - public class RunSharpReport: AbstractMenuCommand - { - public override void Run() - { - SharpReportView view = new SharpReportView(); - if (view != null) { - if (SharpReportCore.GlobalValues.IsValidPrinter()) { - WorkbenchSingleton.Workbench.ShowView(view); - } else { - MessageService.ShowError(ResourceService.GetString("Sharpreport.Error.NoPrinter")); - } - - } - } - } -} - diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ViewCommands.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ViewCommands.cs new file mode 100644 index 0000000000..e0802df26e --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ViewCommands.cs @@ -0,0 +1,55 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 19.01.2006 + * Time: 10:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui; + +namespace SharpReportAddin.Commands{ + + /// + /// This command is used when starting the + /// from MainMenu/Extras/ReportGenerator + /// + /// + public class RunSharpReport: AbstractMenuCommand{ + + public override void Run(){ + SharpReportView view = new SharpReportView(); + if (view != null) { + if (SharpReportCore.GlobalValues.IsValidPrinter()) { + WorkbenchSingleton.Workbench.ShowView(view); + } else { + MessageService.ShowError(ResourceService.GetString("Sharpreport.Error.NoPrinter")); + } + + } + } + } + + /// + /// Let the update or fill + /// the + /// + + public class SetFieldsExplorer : AbstractSharpReportCommand{ + public SetFieldsExplorer() { + + } + public override void Run() { + try { + base.View.UpdateFieldsExplorer(); + } catch (Exception) { + throw; + } + } + + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs index 80616da1f9..3eefc10bd1 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs @@ -70,6 +70,7 @@ namespace SharpReportAddin { /// Clear the selected Section /// public void ClearNodeSection () { + System.Console.WriteLine("ClearNodeSection"); if (this.SelectedNode is SectionTreeNode) { if (this.SelectedNode.Nodes.Count > 0) { this.SelectedNode.Nodes.Clear(); @@ -82,6 +83,7 @@ namespace SharpReportAddin { /// Remove the selected Node from Sorting or Grouping Collection /// public void ClearSelectedNode() { + System.Console.WriteLine("ClearSelectedNode"); if (this.SelectedNode != null) { TreeNode parent = this.SelectedNode.Parent; this.SelectedNode.Remove(); @@ -146,7 +148,7 @@ namespace SharpReportAddin { void TreeViewDragDrop (object sender,DragEventArgs e) { - + System.Console.WriteLine("DragDrop"); if(e.Data.GetDataPresent("SharpReportAddin.ColumnsTreeNode", false)){ Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); @@ -224,9 +226,11 @@ namespace SharpReportAddin { #endregion private void NotifyReportView() { - if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent is SharpReportView) { - System.Console.WriteLine("\tNotify View"); - WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.IsDirty = true; + if (this.isFilled) { + if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent is SharpReportView) { + System.Console.WriteLine("NotifyReportView"); + WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.IsDirty = true; + } } } @@ -255,16 +259,12 @@ namespace SharpReportAddin { #endregion - void ActivatePad (IWorkbenchLayout layout,PadDescriptor pad) { - } - #region Build TreeControl private void UpdateSorting () { + this.reportSettings.SortColumnCollection.Clear(); if (this.nodeSorting.Nodes.Count > 0) { - this.reportSettings.SortColumnCollection.Clear(); - SortColumn sc; AbstractColumn af; for (int i = 0;i < this.nodeSorting.Nodes.Count ;i++ ) { @@ -279,24 +279,19 @@ namespace SharpReportAddin { cn.SortDirection, typeof(System.String)); } - reportSettings.SortColumnCollection.Add(sc); } } } - - private void UpdateGrouping () { + reportSettings.GroupColumnsCollection.Clear(); if (this.nodeGrouping.Nodes.Count > 0) { - reportSettings.GroupColumnsCollection.Clear(); GroupColumn gc; - for (int i = 0;i < this.nodeGrouping.Nodes.Count ;i++ ) { ColumnsTreeNode cn = (ColumnsTreeNode)this.nodeGrouping.Nodes[i]; gc = new GroupColumn (cn.Text,i,cn.SortDirection); - reportSettings.GroupColumnsCollection.Add(gc); } } @@ -332,7 +327,7 @@ namespace SharpReportAddin { this.nodeAvailableFields.Nodes.Add(n); } } catch (Exception) { - + throw; } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportAddin.csproj b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportAddin.csproj index 93f68d9968..94e7568de5 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportAddin.csproj +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportAddin.csproj @@ -56,7 +56,7 @@ Always - + diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs index 267b9bad13..2f31d728eb 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs @@ -42,6 +42,8 @@ namespace SharpReportAddin { cmd.Run(); view.FileName = view.DesignerControl.ReportModel.ReportSettings.FileName; view.UpdateView(true); + view.UpdateFieldsExplorer(); + view.Selected(); return view; } catch (SharpReportException) { if (view != null) { @@ -58,7 +60,11 @@ namespace SharpReportAddin { return null; } - + /// + /// We allways have to check for an installed printer + /// + /// + /// public virtual bool CanCreateContentForLanguage(string languageName) { // .addin file already does the language name check return GlobalValues.IsValidPrinter(); @@ -70,6 +76,9 @@ namespace SharpReportAddin { SharpReportView view = new SharpReportView(); try { view.Load (fileName); + view.UpdateView (false); + view.UpdateFieldsExplorer(); + view.Selected(); return view; } catch (Exception) { return new SharpReportView(); @@ -78,7 +87,11 @@ namespace SharpReportAddin { return null; } } - + /// + /// We allways have to check for an installed printer + /// + /// + /// public virtual bool CanCreateContentForFile(string fileName) { // .addin file already does the language name check return GlobalValues.IsValidPrinter(); diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs index 130dfb46a0..1b449810dd 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs @@ -85,26 +85,7 @@ namespace SharpReportAddin{ } } - /// - /// We have to tell the FieldsdsExplorer that we have loaded or created a new report - /// - /// - private void SetFieldsExplorer() { - try { - Type type = typeof(FieldsExplorer); - SharpReportAddin.FieldsExplorer fe = (SharpReportAddin.FieldsExplorer)WorkbenchSingleton.Workbench.GetPad(type).PadContent; - - if (fe != null) { - this.designerControl.ReportModel.ReportSettings.AvailableFieldsCollection = reportManager.AvailableFieldsCollection; - fe.Fill(this.designerControl.ReportModel.ReportSettings); - } else { - MessageService.ShowError ("SharpReportView:SetFieldExplorer Unable to create FieldsExplorer"); - } - - } catch (Exception e) { - MessageService.ShowError (e); - } - } + #endregion @@ -340,19 +321,24 @@ namespace SharpReportAddin{ //Something was dropped on the designer private void OnItemDragDrop (object sender,ItemDragDropEventArgs e) { + System.Console.WriteLine("View:DragDrop"); base.IsDirty = true; - this.SetFieldsExplorer(); + SharpReportAddin.Commands.SetFieldsExplorer uf = new SharpReportAddin.Commands.SetFieldsExplorer(); + uf.Run(); } public void OnPropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e) { + System.Console.WriteLine("View:PorpChange"); base.IsDirty = true; } private void OnSettingsChanged (object sender,EventArgs e) { + System.Console.WriteLine("View.SettingsChange"); base.IsDirty = true; } private void OnModelFileNameChanged (object sender,EventArgs e) { + System.Console.WriteLine("View:filenamechange"); base.FileName = designerControl.ReportModel.ReportSettings.FileName; base.IsDirty = true; this.OnFileNameChanged(e); @@ -385,10 +371,7 @@ namespace SharpReportAddin{ /// /// Show's Report in PreviewControl /// - - public void OnPreviewClick () { - reportManager.NoData -= new SharpReportEventHandler (OnNoDataForReport); reportManager.NoData += new SharpReportEventHandler (OnNoDataForReport); @@ -406,15 +389,35 @@ namespace SharpReportAddin{ /// /// If true, set the DirtyFlag and Fire the PropertyChanged Event public void UpdateView(bool setViewDirty) { + System.Console.WriteLine("UpdateView with {0}",setViewDirty); this.tabControl.SelectedIndex = 0; this.OnTabPageChanged(this,EventArgs.Empty); SetOnPropertyChangedEvents(); - this.SetFieldsExplorer(); if (setViewDirty) { this.OnPropertyChanged (this,new System.ComponentModel.PropertyChangedEventArgs("Fired from UpdateView")); } } - + + /// + /// We have to tell the FieldsdsExplorer that we have loaded or created a new report + /// + /// + public void UpdateFieldsExplorer() { + try { + Type type = typeof(FieldsExplorer); + SharpReportAddin.FieldsExplorer fe = (SharpReportAddin.FieldsExplorer)WorkbenchSingleton.Workbench.GetPad(type).PadContent; + + if (fe != null) { + this.designerControl.ReportModel.ReportSettings.AvailableFieldsCollection = reportManager.AvailableFieldsCollection; + fe.Fill(designerControl.ReportModel.ReportSettings); + } else { + MessageService.ShowError ("SharpReportView:SetFieldExplorer Unable to create FieldsExplorer"); + } + + } catch (Exception e) { + MessageService.ShowError (e); + } + } #endregion @@ -479,6 +482,17 @@ namespace SharpReportAddin{ } } + public override void Deselected(){ + base.Deselected(); + System.Console.WriteLine("Deselected"); + } + + public override void Selected(){ + base.Selected(); + System.Console.WriteLine("Selected"); + } + + public override void Save() { this.Save (designerControl.ReportModel.ReportSettings.FileName); } @@ -507,7 +521,6 @@ namespace SharpReportAddin{ designerControl.ReportControl.ObjectSelected += new SelectedEventHandler (OnObjectSelected); PropertyPad.Grid.SelectedObject = designerControl.ReportModel.ReportSettings; PropertyPad.Grid.Refresh(); - UpdateView(false); } catch (Exception e) { MessageService.ShowError(e.Message); throw ; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs index fc546418ee..95cca2cf79 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs @@ -1,28 +1,14 @@ -// -// SharpDevelop ReportEditor -// -// Copyright (C) 2005 Peter Forstmeier -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Peter Forstmeier (Peter.Forstmeier@t-online.de) +// +/// +/// created by - Forstmeier Peter +/// Peter Forstmeier (Peter.Forstmeier@t-online.de) +/// created on - 12.06.2005 18:17:46 +/// using System; /// - /// This Delegate is used to format the output from textBased items + /// This Delegate is used to format the output from TextBased Items /// namespace SharpReportCore { public delegate void FormatOutputEventHandler (object sender,FormatOutputEventArgs e); @@ -52,25 +38,16 @@ namespace SharpReportCore { get { return formatString; } - set { - formatString = value; - } } public string NullValue { get { return nullValue; } - set { - nullValue = value; - } } public string StringToFormat { get { return stringToFormat; } - set { - stringToFormat = value; - } } public string FormatedString {