Browse Source

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
shortcuts
Peter Forstmeier 20 years ago
parent
commit
51b61792f5
  1. 2
      src/AddIns/Misc/SharpReport/SharpReport.sln
  2. 10
      src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/AbstractCommand/AbstractSharpReportCommand.cs
  3. 37
      src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/RunSharpReport.cs
  4. 55
      src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ViewCommands.cs
  5. 27
      src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs
  6. 2
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportAddin.csproj
  7. 17
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs
  8. 67
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs
  9. 37
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs

2
src/AddIns/Misc/SharpReport/SharpReport.sln

@ -1,5 +1,5 @@ @@ -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}"

10
src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/AbstractCommand/AbstractSharpReportCommand.cs

@ -29,9 +29,13 @@ namespace SharpReportAddin.Commands { @@ -29,9 +29,13 @@ namespace SharpReportAddin.Commands {
/// </summary>
///
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;
}
}

37
src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/RunSharpReport.cs

@ -1,37 +0,0 @@ @@ -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;
///<summary>
///Main Command to Run SharpReport Addin
///</summary>
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"));
}
}
}
}
}

55
src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ViewCommands.cs

@ -0,0 +1,55 @@ @@ -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{
/// <summary>
/// This command is used when starting the <see cref="SharpReportView"></see>
/// from MainMenu/Extras/ReportGenerator
/// </summary>
///
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"));
}
}
}
}
/// <summary>
/// Let the <see cref="SharpReportView"></see> update or fill
/// the <see cref="FieldsExplorer"></see>
/// </summary>
public class SetFieldsExplorer : AbstractSharpReportCommand{
public SetFieldsExplorer() {
}
public override void Run() {
try {
base.View.UpdateFieldsExplorer();
} catch (Exception) {
throw;
}
}
}
}

27
src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs

@ -70,6 +70,7 @@ namespace SharpReportAddin { @@ -70,6 +70,7 @@ namespace SharpReportAddin {
/// Clear the selected Section
/// </summary>
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 { @@ -82,6 +83,7 @@ namespace SharpReportAddin {
/// Remove the selected Node from Sorting or Grouping Collection
/// </summary>
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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -332,7 +327,7 @@ namespace SharpReportAddin {
this.nodeAvailableFields.Nodes.Add(n);
}
} catch (Exception) {
throw;
}
}

2
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportAddin.csproj

@ -56,7 +56,7 @@ @@ -56,7 +56,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="Resources\BitmapResources.resources" />
<Compile Include="Commands\RunSharpReport.cs" />
<Compile Include="Commands\ViewCommands.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Commands" />

17
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs

@ -42,6 +42,8 @@ namespace SharpReportAddin { @@ -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 { @@ -58,7 +60,11 @@ namespace SharpReportAddin {
return null;
}
/// <summary>
/// We allways have to check for an installed printer
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public virtual bool CanCreateContentForLanguage(string languageName) {
// .addin file already does the language name check
return GlobalValues.IsValidPrinter();
@ -70,6 +76,9 @@ namespace SharpReportAddin { @@ -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 { @@ -78,7 +87,11 @@ namespace SharpReportAddin {
return null;
}
}
/// <summary>
/// We allways have to check for an installed printer
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public virtual bool CanCreateContentForFile(string fileName) {
// .addin file already does the language name check
return GlobalValues.IsValidPrinter();

67
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs

@ -85,26 +85,7 @@ namespace SharpReportAddin{ @@ -85,26 +85,7 @@ namespace SharpReportAddin{
}
}
///<summary>
/// We have to tell the FieldsdsExplorer that we have loaded or created a new report
/// </summary>
///
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{ @@ -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{ @@ -385,10 +371,7 @@ namespace SharpReportAddin{
/// <summary>
/// Show's Report in PreviewControl
/// </summary>
public void OnPreviewClick () {
reportManager.NoData -= new SharpReportEventHandler (OnNoDataForReport);
reportManager.NoData += new SharpReportEventHandler (OnNoDataForReport);
@ -406,15 +389,35 @@ namespace SharpReportAddin{ @@ -406,15 +389,35 @@ namespace SharpReportAddin{
/// </summary>
/// <param name="setViewDirty">If true, set the DirtyFlag and Fire the PropertyChanged Event</param>
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"));
}
}
///<summary>
/// We have to tell the FieldsdsExplorer that we have loaded or created a new report
/// </summary>
///
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{ @@ -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{ @@ -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 ;

37
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs

@ -1,28 +1,14 @@ @@ -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)
//
/// <remarks>
/// created by - Forstmeier Peter
/// Peter Forstmeier (Peter.Forstmeier@t-online.de)
/// created on - 12.06.2005 18:17:46
/// </remarks>
using System;
/// <summary>
/// This Delegate is used to format the output from textBased items
/// This Delegate is used to format the output from TextBased Items
/// </summary>
namespace SharpReportCore {
public delegate void FormatOutputEventHandler (object sender,FormatOutputEventArgs e);
@ -52,25 +38,16 @@ namespace SharpReportCore { @@ -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 {

Loading…
Cancel
Save