Skip to content
This repository has been archived by the owner on Mar 4, 2018. It is now read-only.

Commit

Permalink
Ability to bind with readonly members
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Aug 11, 2017
1 parent 53d6c44 commit efe6436
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 19 deletions.
3 changes: 1 addition & 2 deletions Forms/openMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ private void button1_Click(object sender, EventArgs e)
{
//Open File
NppFunctions.OpenFile(resultFile, this.isReadonly);
if (!this.isReadonly)
OpenMembers.AddMember(textBox4.Text, resultFile, textBox1.Text, textBox2.Text, textBox3.Text);
OpenMembers.AddMember(textBox4.Text, resultFile, textBox1.Text, textBox2.Text, textBox3.Text, !this.isReadonly);

this.Close();
}
Expand Down
3 changes: 1 addition & 2 deletions Forms/selectMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ private void OpenMember(string Lib, string Obj, string Mbr, Boolean Editing)
if (resultFile != "")
{
NppFunctions.OpenFile(resultFile, !Editing);
if (Editing)
OpenMembers.AddMember(IBMi.GetConfig("system"), resultFile, Lib, Obj, Mbr);
OpenMembers.AddMember(IBMi.GetConfig("system"), resultFile, Lib, Obj, Mbr, Editing);
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions IBMiTools/IBMi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ private static void OutputHandler(object sendingProcess, DataReceivedEventArgs o
_getList = false;
_output.Add("> " + outLine.Data.Substring(4));
break;
case "150":
_output.Add("> " + outLine.Data.Substring(4));
break;
case "426":
case "530":
case "550":
Expand Down
2 changes: 1 addition & 1 deletion LanguageTools/Include.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static OpenMember HandleRPG(string Copy)
if (lib == "*CURLIB") lib = IBMi.GetConfig("curlib");

if (IBMiUtilities.IsValidQSYSObjectName(lib) && IBMiUtilities.IsValidQSYSObjectName(obj) && IBMiUtilities.IsValidQSYSObjectName(mbr)) {
return new OpenMember("", "", lib, obj, mbr);
return new OpenMember("", "", lib, obj, mbr, false);
}
else
{
Expand Down
23 changes: 13 additions & 10 deletions LanguageTools/NppFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,23 @@ public static void HandleTrigger(SCNotification Notification)
member = OpenMembers.GetMember(path);
if (member != null)
{
gothread = new Thread((ThreadStart)delegate {
if (member.GetSystemName() == IBMi.GetConfig("system"))
gothread = new Thread((ThreadStart)delegate {
if (member.IsEditable())
{
bool UploadResult = IBMiUtilities.UploadMember(member.GetLocalFile(), member.GetLibrary(), member.GetObject(), member.GetMember());
if (UploadResult == false)
if (member.GetSystemName() == IBMi.GetConfig("system"))
{
System.Windows.Forms.MessageBox.Show("Failed to upload to " + member.GetMember() + " on " + member.GetSystemName() + ".");
bool UploadResult = IBMiUtilities.UploadMember(member.GetLocalFile(), member.GetLibrary(), member.GetObject(), member.GetMember());
if (UploadResult == false)
{
System.Windows.Forms.MessageBox.Show("Failed to upload to " + member.GetMember() + " on " + member.GetSystemName() + ".");
}
}
else
{
System.Windows.Forms.MessageBox.Show("Unable to upload to " + member.GetMember() + ". You must be connected to " + member.GetSystemName() + " in order to save this file.");
}
if (Main.CommandWindow != null) Main.CommandWindow.loadNewOutput();
}
else
{
System.Windows.Forms.MessageBox.Show("Unable to upload to " + member.GetMember() + ". You must be connected to " + member.GetSystemName() + " in order to save this file.");
}
if (Main.CommandWindow != null) Main.CommandWindow.loadNewOutput();
});
gothread.Start();
}
Expand Down
13 changes: 10 additions & 3 deletions LanguageTools/OpenMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public static string[] GetLocals()
return _Members.Keys.ToArray();
}

public static void AddMember(string System, string Local, string Lib, string Obj, string Mbr)
public static void AddMember(string System, string Local, string Lib, string Obj, string Mbr, Boolean isEditable = true)
{
if (Contains(Local))
RemoveMember(Local);

_Members.Add(Local, new OpenMember(System, Local, Lib, Obj, Mbr));
_Members.Add(Local, new OpenMember(System, Local, Lib, Obj, Mbr, isEditable));
}

public static void RemoveMember(String Local)
Expand Down Expand Up @@ -56,14 +56,16 @@ class OpenMember
private string _Lib;
private string _Obj;
private string _Mbr;
private Boolean _isEditable;

public OpenMember(string System, string Local, string Lib, string Obj, string Mbr)
public OpenMember(string System, string Local, string Lib, string Obj, string Mbr, Boolean isEditable)
{
this._Sys = System;
this._Local = Local;
this._Lib = Lib;
this._Obj = Obj;
this._Mbr = Mbr;
this._isEditable = isEditable;
}

public string GetSystemName()
Expand All @@ -90,5 +92,10 @@ public string GetMember()
{
return this._Mbr;
}

public bool IsEditable()
{
return this._isEditable;
}
}
}
1 change: 0 additions & 1 deletion LanguageTools/RPGParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public static List<ListViewItem> ScanFile(string Path)
Free = Free.Trim();
if (Free == "")
Free = Line.Trim();
IBMi.AddOutput(Free);

Item = null;
if (Free != "")
Expand Down

0 comments on commit efe6436

Please sign in to comment.