Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/05/10 10:31:40 (15 years ago)
Author:
gkronber
Message:

Copied refactored plugin infrastructure from branch and merged changeset r2586:2589 from branch into the trunk. #799

Location:
trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.2/AvailableOperatorsForm.cs

    r1529 r2591  
    6363      builtinOperatorsTreeView.TreeViewNodeSorter = nodeSorter;
    6464
    65       DiscoveryService discoveryService = new DiscoveryService();
    66       PluginInfo[] plugins = discoveryService.Plugins;
    67       foreach(PluginInfo plugin in plugins) {
     65      foreach(IPluginDescription plugin in ApplicationManager.Manager.Plugins) {
    6866        TreeNode pluginItem = new TreeNode();
    6967        pluginItem.Text = plugin.Name;
    7068        pluginItem.Tag = plugin;
    7169
    72         Type[] operators = discoveryService.GetTypes(typeof(IOperator), plugin);
    73         foreach(Type type in operators) {
     70        foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IOperator), plugin)) {
    7471          if(!type.IsAbstract) {
    7572            TreeNode operatorItem = new TreeNode();
  • trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.2/HeuristicLabAdvancedOptimizationFrontendApplication.cs

    r1529 r2591  
    3030  /// The HeuristicLab Advanced Optimization Frontend Application.
    3131  /// </summary>
    32   [ClassInfo(Name = "HeuristicLab 3.2 (dockable)", Description="Next generation heuristic optimization environment.")]
     32  [Application("HeuristicLab 3.2 (dockable)", "Next generation heuristic optimization environment.")]
    3333  class HeuristicLabAdvancedOptimizationFrontendApplication : ApplicationBase {
    3434    /// <summary>
     
    3737    public override void Run() {
    3838      Form mainForm = new MainForm();
    39       PluginManager.ControlManager = (IControlManager)mainForm;
     39      ControlManager.RegisterManager((IControlManager)mainForm);
    4040      Application.Run(mainForm);
    4141    }
  • trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.2/HeuristicLabAdvancedOptimizationFrontendPlugin.cs

    r2479 r2591  
    3030  /// Plugin class for HeuristicLab.AdvancedOptimizationFrontend plugin.
    3131  /// </summary>
    32   [ClassInfo(Name = "HeuristicLab.AdvancedOptimizationFrontend-3.2")]
    33   [PluginFile(Filename = "HeuristicLab.AdvancedOptimizationFrontend-3.2.dll", Filetype = PluginFileType.Assembly)]
    34   [Dependency(Dependency = "HeuristicLab.Core-3.2")]
    35   [Dependency(Dependency = "HeuristicLab.MainForm.WindowsForms-3.2")]
     32  [Plugin("HeuristicLab.AdvancedOptimizationFrontend-3.2")]
     33  [PluginFile("HeuristicLab.AdvancedOptimizationFrontend-3.2.dll", PluginFileType.Assembly)]
     34  [PluginDependency("HeuristicLab.Core-3.2")]
     35  [PluginDependency("HeuristicLab.MainForm.WindowsForms-3.2")]
    3636  public class HeuristicLabAdvancedOptimizationFrontendPlugin : PluginBase {
    3737  }
  • trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.2/MainForm.cs

    r2143 r2591  
    2626using System.Drawing;
    2727using System.Text;
     28using System.Linq;
    2829using System.Threading;
    2930using System.Windows.Forms;
     
    6869      form.Show(dockPanel);
    6970
    70       DiscoveryService discoveryService = new DiscoveryService();
    71 
    7271      // discover creatable items
    73       Type[] creatables = discoveryService.GetTypes(typeof(IEditable));
    74       string[] names = new string[creatables.Length];
    75       for (int i = 0; i < creatables.Length; i++)
    76         names[i] = creatables[i].Name;
    77       Array.Sort(names, creatables);
     72      var creatables = from x in ApplicationManager.Manager.GetTypes(typeof(IEditable))
     73                       orderby x.Name
     74                       select x;     
    7875      foreach (Type type in creatables) {
    7976        if (!type.IsAbstract) {
     
    10097    /// is neither a view nor an editor.</exception>
    10198    /// <param name="control">The control to display.</param>
    102     public void ShowControl(IControl control) {
    103       if (InvokeRequired) Invoke((Action<IControl>)ShowControl,control);
     99    public void ShowControl(object control) {
     100      if (InvokeRequired) Invoke((Action<object>)ShowControl, control);
    104101      else {
    105102        DockContent content;
     
    132129        saveAllToolStripButton.Enabled = true;
    133130        EditorForm form = ActiveMdiChild as EditorForm;
    134         if (form != null){
     131        if (form != null) {
    135132          if (((Control)form.Editor).Enabled) {
    136133            saveToolStripMenuItem.Enabled = true;
     
    158155      try {
    159156        task.storable = PersistenceManager.Load(task.filename);
    160       } catch(FileNotFoundException fileNotFoundEx) {
     157      }
     158      catch (FileNotFoundException fileNotFoundEx) {
    161159        MessageBox.Show("Sorry couldn't open file \"" + task.filename + "\".\nThe file or plugin \"" + fileNotFoundEx.FileName + "\" is not available.\nPlease make sure you have all necessary plugins installed.",
    162160          "Reader Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    163       } catch(TypeLoadException typeLoadEx) {
    164         MessageBox.Show("Sorry couldn't open file \"" + task.filename + "\".\nThe type \"" + typeLoadEx.TypeName+ "\" is not available.\nPlease make sure that you have the correct version the plugin installed.",
     161      }
     162      catch (TypeLoadException typeLoadEx) {
     163        MessageBox.Show("Sorry couldn't open file \"" + task.filename + "\".\nThe type \"" + typeLoadEx.TypeName + "\" is not available.\nPlease make sure that you have the correct version the plugin installed.",
    165164          "Reader Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    166165      }
    167       LoadFinished(task);
     166      finally {
     167        LoadFinished(task);
     168      }
    168169    }
    169170    private delegate void TaskFinishedDelegate(Task task);
     
    183184          editor.Filename = task.filename;
    184185          editor.SaveFinished += new EventHandler(SaveFinished);
    185           PluginManager.ControlManager.ShowControl(editor);
     186          ControlManager.Manager.ShowControl(editor);
    186187        }
    187188        lock (locker) {
     
    239240        } else {
    240241          editor.SaveFinished += new EventHandler(SaveFinished);
    241           PluginManager.ControlManager.ShowControl(editor);
     242          ControlManager.Manager.ShowControl(editor);
    242243          EnableDisableItems();
    243244        }
     
    298299      for (int i = 0; i < MdiChildren.Length; i++) {
    299300        EditorForm form = MdiChildren[i] as EditorForm;
    300         if (form!=null && ((Control)form.Editor).Enabled) Save(form);
     301        if (form != null && ((Control)form.Editor).Enabled) Save(form);
    301302      }
    302303    }
Note: See TracChangeset for help on using the changeset viewer.