Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16186 for trunk


Ignore:
Timestamp:
09/25/18 15:05:56 (6 years ago)
Author:
jzenisek
Message:

#2839 fixed lightweightUserInformationView

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Clients.Access.Views/3.3/UserViews/RefreshableLightweightUserInformationView.Designer.cs

    r15583 r16186  
    2020#endregion
    2121
    22 using System;
    2322namespace HeuristicLab.Clients.Access.Views {
    2423  partial class RefreshableLightweightUserInformationView {
     
    3433    protected override void Dispose(bool disposing) {
    3534      if (disposing && (components != null)) {
    36         lightweightUserInformationView.UserInformationChanged -= new EventHandler(lightweightUserInformationView_Changed);
    3735        components.Dispose();
    3836      }
     
    4745    /// </summary>
    4846    private void InitializeComponent() {
     47      components = new System.ComponentModel.Container();
    4948      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RefreshableLightweightUserInformationView));
    5049      this.lightweightUserInformationView = new HeuristicLab.Clients.Access.Views.LightweightUserInformationView();
    51       this.storeButton = new System.Windows.Forms.Button();
     50      this.refreshButton = new System.Windows.Forms.Button();
     51      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    5252      this.SuspendLayout();
    5353      //
    5454      // refreshButton
    5555      //
     56      this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;
    5657      this.refreshButton.Location = new System.Drawing.Point(4, 3);
     58      this.refreshButton.Name = "refreshButton";
     59      this.refreshButton.Size = new System.Drawing.Size(24, 24);
     60      this.refreshButton.TabIndex = 1;
     61      this.toolTip.SetToolTip(this.refreshButton, "Refresh data");
     62      this.refreshButton.UseVisualStyleBackColor = true;
     63      this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
    5764      //
    5865      // lightweightUserInformationView
     
    6976      this.lightweightUserInformationView.TabIndex = 2;
    7077      //
    71       // storeButton
    72       //
    73       this.storeButton.Enabled = false;
    74       this.storeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
    75       this.storeButton.Location = new System.Drawing.Point(34, 3);
    76       this.storeButton.Name = "storeButton";
    77       this.storeButton.Size = new System.Drawing.Size(24, 24);
    78       this.storeButton.TabIndex = 3;
    79       this.storeButton.UseVisualStyleBackColor = true;
    80       this.storeButton.Click += new System.EventHandler(this.storeButton_Click);
    81       //
    8278      // RefreshableLightweightUserInformationView
    8379      //
     
    8581      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    8682      this.Controls.Add(this.lightweightUserInformationView);
    87       this.Controls.Add(this.storeButton);
     83      this.Controls.Add(this.refreshButton);
    8884      this.Name = "RefreshableLightweightUserInformationView";
    8985      this.Size = new System.Drawing.Size(384, 281);
    90       this.Controls.SetChildIndex(this.storeButton, 0);
    9186      this.Controls.SetChildIndex(this.lightweightUserInformationView, 0);
    92       this.Controls.SetChildIndex(this.refreshButton, 0);
     87      this.Controls.SetChildIndex(this.refreshButton, 1);
    9388      this.ResumeLayout(false);
    9489
     
    9893
    9994    private LightweightUserInformationView lightweightUserInformationView;
    100     private System.Windows.Forms.Button storeButton;
    101 
     95    private System.Windows.Forms.ToolTip toolTip;
     96    private System.Windows.Forms.Button refreshButton;
    10297  }
    10398}
  • trunk/HeuristicLab.Clients.Access.Views/3.3/UserViews/RefreshableLightweightUserInformationView.cs

    r15583 r16186  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.MainForm;
     25using HeuristicLab.MainForm.WindowsForms;
    2426
    2527namespace HeuristicLab.Clients.Access.Views {
    26   public partial class RefreshableLightweightUserInformationView : RefreshableView {
     28  [View("RefreshableLightweightUserInformation View")]
     29  [Content(typeof(LightweightUser), false)]
     30  public partial class RefreshableLightweightUserInformationView : AsynchronousContentView {
     31    public new LightweightUser Content {
     32      get { return (LightweightUser)base.Content; }
     33      set { base.Content = value; }
     34    }
     35
    2736    public RefreshableLightweightUserInformationView() {
    2837      InitializeComponent();
     38    }
     39
     40    protected override void OnContentChanged() {
     41      base.OnContentChanged();
     42      lightweightUserInformationView.Content = Content;
     43    }
     44
     45    protected override void SetEnabledStateOfControls() {
     46      base.SetEnabledStateOfControls();
     47      refreshButton.Enabled = Content != null;
     48    }
     49
     50    protected override void DeregisterContentEvents() {
     51      Refreshing -= new EventHandler(Content_Refreshing);
     52      Refreshed -= new EventHandler(Content_Refreshed);
     53      base.DeregisterContentEvents();
     54    }
     55
     56    protected override void RegisterContentEvents() {
     57      base.RegisterContentEvents();
     58      Refreshing += new EventHandler(Content_Refreshing);
     59      Refreshed += new EventHandler(Content_Refreshed);
     60    }
     61
     62    protected void Content_Refreshing(object sender, EventArgs e) {
     63      if (InvokeRequired) {
     64        Invoke(new EventHandler(Content_Refreshing), sender, e);
     65      } else {
     66        Cursor = Cursors.AppStarting;
     67        refreshButton.Enabled = false;
     68
     69        lightweightUserInformationView.Enabled = false;
     70      }
     71    }
     72
     73    protected void Content_Refreshed(object sender, EventArgs e) {
     74      if (InvokeRequired) {
     75        Invoke(new EventHandler(Content_Refreshed), sender, e);
     76      } else {
     77        Cursor = Cursors.Default;
     78        refreshButton.Enabled = true;
     79
     80        lightweightUserInformationView.Enabled = true;
     81        if (!UserInformation.Instance.UserExists) {
     82          MessageBox.Show("Couldn't fetch user information from the server." + Environment.NewLine +
     83            "Please verify that you have an existing user and that your user name and password is correct. ", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
     84          lightweightUserInformationView.Content = null;
     85        } else {
     86          lightweightUserInformationView.Content = Content;
     87        }
     88      }
     89    }
     90
     91    void lightweightUserInformationView_Changed(object sender, EventArgs e) {
     92      // nothing to do
    2993    }
    3094
     
    3498    }
    3599
    36     void lightweightUserInformationView_Changed(object sender, EventArgs e) {
    37       if (!storeButton.Enabled) storeButton.Enabled = true;
     100    private void RefreshData() {
     101      ExecuteActionAsync(RefreshUserData, PluginInfrastructure.ErrorHandling.ShowErrorDialog);
    38102    }
    39103
    40     protected override void RefreshData() {
    41       Content.ExecuteActionAsync(RefreshUserData, PluginInfrastructure.ErrorHandling.ShowErrorDialog);
     104    public void ManualRefresh() {
     105      RefreshData();
    42106    }
    43107
    44     protected override void Content_Refreshing(object sender, EventArgs e) {
    45       if (InvokeRequired) {
    46         Invoke(new EventHandler(Content_Refreshing), sender, e);
    47       } else {
    48         base.Content_Refreshing(sender, e);
    49         lightweightUserInformationView.Enabled = false;
    50         storeButton.Enabled = false;
    51       }
     108    protected void refreshButton_Click(object sender, System.EventArgs e) {
     109      RefreshData();
    52110    }
    53111
    54     protected override void Content_Refreshed(object sender, EventArgs e) {
    55       if (InvokeRequired) {
    56         Invoke(new EventHandler(Content_Refreshed), sender, e);
    57       } else {
    58         base.Content_Refreshed(sender, e);
    59         lightweightUserInformationView.Enabled = true;
    60         if (!UserInformation.Instance.UserExists) {
    61           MessageBox.Show("Couldn't fetch user information from the server." + Environment.NewLine +
    62             "Please verify that you have an existing user and that your user name and password is correct. ", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
    63           lightweightUserInformationView.Content = null;
    64         } else {
    65           lightweightUserInformationView.Content = UserInformation.Instance.User;
     112    public void ExecuteActionAsync(Action action, Action<Exception> exceptionCallback) {
     113      var call = new Func<Exception>(delegate () {
     114        try {
     115          OnRefreshing();
     116          action();
     117        } catch (Exception ex) {
     118          return ex;
     119        } finally {
     120          OnRefreshed();
    66121        }
    67       }
     122        return null;
     123      });
     124      call.BeginInvoke(delegate (IAsyncResult result) {
     125        Exception ex = call.EndInvoke(result);
     126        if (ex != null) exceptionCallback(ex);
     127      }, null);
    68128    }
    69129
    70     private void storeButton_Click(object sender, EventArgs e) {
    71       AccessClient.Instance.ExecuteActionAsync(new Action(delegate {
    72         AccessClient.CallAccessService(x => x.UpdateLightweightUser(UserInformation.Instance.User));
    73       }), HeuristicLab.PluginInfrastructure.ErrorHandling.ShowErrorDialog);
     130    #region Events
     131    public event EventHandler Refreshing;
     132    private void OnRefreshing() {
     133      EventHandler handler = Refreshing;
     134      if (handler != null) handler(this, EventArgs.Empty);
    74135    }
     136    public event EventHandler Refreshed;
     137    private void OnRefreshed() {
     138      EventHandler handler = Refreshed;
     139      if (handler != null) handler(this, EventArgs.Empty);
     140    }
     141    #endregion
    75142  }
    76143}
  • trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.cs

    r16184 r16186  
    117117      var selectedPermission = (UserGroupBase)e.Node.Tag;
    118118      detailsViewHost.Content = selectedPermission;
     119      if (selectedPermission is LightweightUser)
     120        detailsViewHost.ViewType = typeof(Access.Views.RefreshableLightweightUserInformationView);
    119121    }
    120122
Note: See TracChangeset for help on using the changeset viewer.