Added ability to order the execution of dictionary adapter behaviors.
[castle.git] / Experiments / Attic / Generator / Castle.ActiveRecord.Generator / ARGeneratorLayout.cs
blobc3b8ffbe1d2b2f65e0ae68076137d81f9c200e3c
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.ActiveRecord.Generator
17 using System;
18 using System.IO;
19 using System.Windows.Forms;
21 using WeifenLuo.WinFormsUI;
23 using Castle.ActiveRecord.Generator.Actions;
24 using Castle.ActiveRecord.Generator.Parts;
27 public class ARGeneratorLayout : IApplicationLayout
29 private Model _model;
30 private ActiveRecordGraphView arGraph;
31 private OutputView outView;
32 private ProjectExplorer projExplorer;
33 private AvailableShapes avaShapes;
35 public ARGeneratorLayout(Model model)
37 _model = model;
40 #region IApplicationLayout Members
42 public void Install(IWorkspace workspace)
44 // Add parts
46 arGraph = new ActiveRecordGraphView(_model);
47 arGraph.ParentWorkspace = workspace;
49 outView = new OutputView(_model);
50 outView.ParentWorkspace = workspace;
52 projExplorer = new ProjectExplorer(_model);
53 projExplorer.ParentWorkspace = workspace;
55 avaShapes = new AvailableShapes(_model);
56 avaShapes.ParentWorkspace = workspace;
58 // Register Actions
60 FileActionGroup group1 = new FileActionGroup();
61 group1.Init(_model);
62 group1.Install(workspace);
64 ViewActionSet group2 = new ViewActionSet(arGraph, outView, projExplorer, avaShapes);
65 group2.Init(_model);
66 group2.Install(workspace);
68 HelpActionSet group3 = new HelpActionSet();
69 group3.Init(_model);
70 group3.Install(workspace);
74 public void Persist(IWorkspace workspace)
76 String dirName = Path.GetDirectoryName(Application.ExecutablePath);
77 String configFile = Path.Combine(dirName, "Layout.config");
79 workspace.MainDockManager.SaveAsXml(configFile);
82 public void Restore(IWorkspace workspace)
84 String configFile = Path.Combine(
85 Path.GetDirectoryName(Application.ExecutablePath), "Layout.config");
87 if (File.Exists(configFile))
89 workspace.MainDockManager.LoadFromXml(configFile,
90 new DeserializeDockContent(GetContentFromPersistString));
92 else
94 arGraph.Show(workspace.MainDockManager, DockState.Document);
95 outView.Show(workspace.MainDockManager, DockState.DockBottomAutoHide);
96 projExplorer.Show(workspace.MainDockManager, DockState.DockRight);
97 avaShapes.Show(workspace.MainDockManager, DockState.DockRight);
101 #endregion
103 private DockContent GetContentFromPersistString(String persistString)
105 if (persistString == typeof(ActiveRecordGraphView).ToString())
106 return arGraph;
107 else if (persistString == typeof(OutputView).ToString())
108 return outView;
109 else if (persistString == typeof(ProjectExplorer).ToString())
110 return projExplorer;
111 else if (persistString == typeof(AvailableShapes).ToString())
112 return avaShapes;
113 else
115 return null;