Beispiel #1
0
 public override void Check(ICheckNotifier notifier)
 {
     if (!RemoteSource.Discover(DataAccessContext.DataLoad).Exists())
     {
         throw new Exception("Database " + RemoteSource.Database + " did not exist on the remote server");
     }
 }
Beispiel #2
0
        public SourceCompareSelect()
        {
            InitializeComponent();

            if (Editor.LastEditing != null)
            {
                RemoteSource src = Editor.LastEditing.Tag as RemoteSource;

                if (src != null)
                {
                    switch (src.GetFS())
                    {
                    case FileSystem.QSYS:
                        newSourceBox.SetSource(src.GetLibrary(), src.GetObject(), src.GetName());
                        oldSourceBox.SetSource("", src.GetObject(), src.GetName());
                        break;

                    case FileSystem.IFS:
                        newSourceBox.SetSource(src.GetRemoteFile());
                        newSourceBox.SetTab(src.GetFS());
                        break;
                    }
                }
            }
        }
Beispiel #3
0
        public static void OpenSource(RemoteSource Source)
        {
            SourceEditor sourcePanel;
            string       resultFile = "";
            string       text       = Source.GetName() + (Source.GetExtension() != "" ? '.' + Source.GetExtension().ToLower() : "");

            Editor.TheEditor.SetStatus("Fetching file " + text + "...");

            new Thread((ThreadStart) delegate
            {
                switch (Source.GetFS())
                {
                case FileSystem.QSYS:
                    resultFile = IBMiUtils.DownloadSourceMember(Source.GetLibrary(), Source.GetObject(), Source.GetName(), Source.GetExtension());
                    break;

                case FileSystem.IFS:
                    resultFile = IBMiUtils.DownloadFile(Source.GetRemoteFile());
                    break;
                }

                if (resultFile != "")
                {
                    TheEditor.SetStatus("Opening file " + text + "...");

                    Source._Local = resultFile;
                    Source.Lock();

                    sourcePanel = new SourceEditor(Source.GetLocalFile(), GetBoundLangType(Source.GetExtension()), Source.GetRecordLength(), !Source.IsEditable());

                    sourcePanel.Tag  = Source;
                    sourcePanel.Text = text;

                    switch (Source.GetFS())
                    {
                    case FileSystem.QSYS:
                        sourcePanel.ToolTipText = Source.GetLibrary() + "/" + Source.GetObject() + ":" + Source.GetName() + "." + Source.GetExtension().ToLower();
                        break;

                    case FileSystem.IFS:
                        sourcePanel.ToolTipText = Source.GetRemoteFile();
                        break;
                    }

                    TheEditor.Invoke((MethodInvoker) delegate
                    {
                        TheEditor.AddTool(sourcePanel, DockState.Document, false);
                    });
                }
                else
                {
                    switch (Source.GetFS())
                    {
                    case FileSystem.QSYS:
                        MessageBox.Show("Unable to download member " + Source.GetLibrary() + "/" + Source.GetObject() + "." + Source.GetName() + ". Please check it exists and that you have access to the remote system.");
                        break;
                    }
                }
            }).Start();
        }
Beispiel #4
0
        protected virtual void OnButtonTrackRemoteClicked(object sender, EventArgs e)
        {
            TreeIter it;

            if (!treeRemotes.Selection.GetSelected(out it))
            {
                return;
            }
            string branchName = (string)storeRemotes.GetValue(it, 3);

            if (branchName == null)
            {
                return;
            }

            storeRemotes.IterParent(out it, it);
            RemoteSource remote = (RemoteSource)storeRemotes.GetValue(it, 0);

            Branch b = new Branch();

            b.Name     = branchName;
            b.Tracking = remote.Name + "/" + branchName;

            var dlg = new EditBranchDialog(repo, b, true);

            try {
                if (MessageService.RunCustomDialog(dlg) == (int)ResponseType.Ok)
                {
                    repo.CreateBranch(dlg.BranchName, dlg.TrackSource);
                    FillBranches();
                }
            } finally {
                dlg.Destroy();
            }
        }
Beispiel #5
0
        private void compileToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            compileOptionsToolStripMenuItem.DropDownItems.Clear();
            List <ToolStripMenuItem> Compiles = new List <ToolStripMenuItem>();

            if (LastEditing != null)
            {
                RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag;
                if (SourceInfo != null)
                {
                    string[] Items = IBMi.CurrentSystem.GetValue("TYPE_" + SourceInfo.GetExtension().ToUpper()).Split('|');
                    foreach (string Item in Items)
                    {
                        if (Item.Trim() == "")
                        {
                            continue;
                        }
                        Compiles.Add(new ToolStripMenuItem(Item, null, compileAnyHandle));
                    }
                }
            }

            compileToolStripMenuItem1.Enabled       = (Compiles.Count > 0);
            compileOptionsToolStripMenuItem.Enabled = (Compiles.Count > 0);
            compileOptionsToolStripMenuItem.DropDownItems.AddRange(Compiles.ToArray());
        }
Beispiel #6
0
        protected virtual void OnButtonEditRemoteClicked(object sender, System.EventArgs e)
        {
            TreeIter it;

            if (!treeRemotes.Selection.GetSelected(out it))
            {
                return;
            }

            RemoteSource remote  = (RemoteSource)storeRemotes.GetValue(it, 0);
            string       oldName = remote.Name;

            var dlg = new EditRemoteDialog(remote, false);

            try
            {
                if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                {
                    if (remote.Name != oldName)
                    {
                        repo.RenameRemote(oldName, remote.Name);
                    }
                    repo.UpdateRemote(remote);
                    FillRemotes();
                }
            }
            finally
            {
                dlg.Destroy();
            }
        }
Beispiel #7
0
        private void memberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RemoteSource member;
            NewMember    newMemberForm = new NewMember();

            newMemberForm.ShowDialog();
            if (newMemberForm.created)
            {
                new Thread((ThreadStart) delegate {
                    string resultFile = IBMiUtils.DownloadMember(newMemberForm._lib, newMemberForm._spf, newMemberForm._mbr, (newMemberForm._type == "*NONE" ? "" : newMemberForm._type));

                    if (resultFile != "")
                    {
                        member = new RemoteSource(resultFile, newMemberForm._lib, newMemberForm._spf, newMemberForm._mbr, newMemberForm._type, true);
                        //LOCK HERE
                        member.Lock();
                        this.Invoke((MethodInvoker) delegate
                        {
                            Editor.TheEditor.AddSourceEditor(member, GetBoundLangType(newMemberForm._type));
                        });
                    }
                }).Start();
            }
            newMemberForm.Dispose();
        }
Beispiel #8
0
        private void compileToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            if (editortabsleft.SelectedTab == null)
            {
                return;
            }

            otherForTypeToolStripMenuItem.DropDownItems.Clear();
            List <ToolStripMenuItem> Compiles = new List <ToolStripMenuItem>();

            if (editortabsleft.SelectedTab.Tag != null)
            {
                RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag;
                string[]     Items      = IBMi.CurrentSystem.GetValue("TYPE_" + SourceInfo.GetExtension()).Split('|');
                foreach (string Item in Items)
                {
                    if (Item.Trim() == "")
                    {
                        continue;
                    }
                    Compiles.Add(new ToolStripMenuItem(Item, null, compileAnyHandle));
                }
            }

            compileCurrentToolStripMenuItem.Enabled = (Compiles.Count > 0);
            otherForTypeToolStripMenuItem.Enabled   = (Compiles.Count > 0);
            otherForTypeToolStripMenuItem.DropDownItems.AddRange(Compiles.ToArray());
        }
Beispiel #9
0
        public void SaveAs()
        {
            if (!GetParent().Text.EndsWith("*"))
            {
                RemoteSource MemberInfo = (RemoteSource)this.Tag;
                if (MemberInfo != null)
                {
                    switch (MemberInfo.GetFS())
                    {
                    case FileSystem.QSYS:
                        if (!MemberInfo._IsBeingSaved)
                        {
                            SaveAs SaveAsWindow = new SaveAs();
                            SaveAsWindow.ShowDialog();
                            if (SaveAsWindow.Success)
                            {
                                MemberInfo._IsBeingSaved = true;

                                Editor.TheEditor.SetStatus("Saving " + SaveAsWindow.Mbr + "..");
                                Thread gothread = new Thread((ThreadStart) delegate
                                {
                                    bool UploadResult = IBMiUtils.UploadMember(MemberInfo.GetLocalFile(), SaveAsWindow.Lib, SaveAsWindow.Spf, SaveAsWindow.Mbr);
                                    if (UploadResult == false)
                                    {
                                        MessageBox.Show("Failed to upload to " + SaveAsWindow.Mbr + ".");
                                    }

                                    this.Invoke((MethodInvoker) delegate
                                    {
                                        Editor.TheEditor.SetStatus(SaveAsWindow.Mbr + " " + (UploadResult ? "" : "not ") + "saved.");
                                    });

                                    MemberInfo._IsBeingSaved = false;
                                });

                                gothread.Start();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Save as is not available for local source.");
                        }
                        break;

                    case FileSystem.IFS:
                        MessageBox.Show("Save as is not available for stream files yet.");
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("You must save the source before you can Save-As.");
            }
        }
Beispiel #10
0
 private void memberList_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         if (memberList.FocusedItem.Bounds.Contains(e.Location) == true)
         {
             currentRightClick = (RemoteSource)memberList.FocusedItem.Tag;
             compileRightclick.Show(Cursor.Position);
         }
     }
 }
Beispiel #11
0
        public void AddSourceEditor(RemoteSource SourceInfo, Language Language = Language.None)
        {
            string pageName = "";

            switch (SourceInfo.GetFS())
            {
            case FileSystem.QSYS:
                pageName = SourceInfo.GetLibrary() + "/" + SourceInfo.GetObject() + "(" + SourceInfo.GetName() + ")";
                break;

            case FileSystem.IFS:
                pageName = SourceInfo.GetName() + "." + SourceInfo.GetExtension();
                break;
            }

            OpenTab currentTab = EditorContains(pageName);

            if (File.Exists(SourceInfo.GetLocalFile()))
            {
                //Close tab if it already exists.
                if (currentTab != null)
                {
                    switch (currentTab.getSide())
                    {
                    case OpenTab.TAB_SIDE.Left:
                        editortabsleft.TabPages.RemoveAt(currentTab.getIndex());
                        break;

                    case OpenTab.TAB_SIDE.Right:
                        editortabsright.TabPages.RemoveAt(currentTab.getIndex());
                        break;
                    }
                }

                TabPage tabPage = new TabPage(pageName);
                tabPage.ImageIndex  = 0;
                tabPage.ToolTipText = pageName;
                SourceEditor srcEdit = new SourceEditor(SourceInfo.GetLocalFile(), Language, SourceInfo.GetRecordLength());
                srcEdit.SetReadOnly(!SourceInfo.IsEditable());
                srcEdit.BringToFront();
                srcEdit.Dock = DockStyle.Fill;
                srcEdit.Tag  = SourceInfo;

                tabPage.Tag = SourceInfo;
                tabPage.Controls.Add(srcEdit);
                editortabsleft.TabPages.Add(tabPage);

                SwitchToTab(OpenTab.TAB_SIDE.Left, editortabsleft.TabPages.Count - 1);
            }
            else
            {
                MessageBox.Show("There was an error opening the local member. '" + SourceInfo.GetLocalFile() + "' does not exist");
            }
        }
Beispiel #12
0
 private void compileToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (LastEditing != null)
     {
         RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag;
         new Thread((ThreadStart) delegate
         {
             IBMiUtils.CompileSource(SourceInfo);
         }).Start();
     }
 }
Beispiel #13
0
        private void memberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RemoteSource member;
            NewMember    newMemberForm = new NewMember();

            newMemberForm.ShowDialog();
            if (newMemberForm.created)
            {
                member = new RemoteSource("", newMemberForm._lib, newMemberForm._spf, newMemberForm._mbr, newMemberForm._type, true);
                OpenSource(member);
            }
            newMemberForm.Dispose();
        }
Beispiel #14
0
 private void cLFormattingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (LastEditing != null)
     {
         RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag;
         Language     Language   = GetBoundLangType(SourceInfo.GetExtension());
         if (Language == Language.CL)
         {
             SetStatus("Formatting CL in " + SourceInfo.GetName());
             LastEditing.DoAction(EditorAction.Format_CL);
         }
     }
 }
Beispiel #15
0
        private void compareMembersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string lib = "", spf = "", mbr = "";

            if (this.LastEditing.Tag != null)
            {
                RemoteSource MemberInfo = (RemoteSource)this.LastEditing.Tag;
                lib = MemberInfo.GetLibrary();
                spf = MemberInfo.GetObject();
                mbr = MemberInfo.GetName();
            }
            new MemberCompareSelect(lib, spf, mbr).ShowDialog();
        }
Beispiel #16
0
        private void memberList_DoubleClick(object sender, EventArgs e)
        {
            if (memberList.SelectedItems.Count == 1)
            {
                ListViewItem selection = memberList.SelectedItems[0];
                if (selection.Tag != null)
                {
                    RemoteSource member = (RemoteSource)selection.Tag;

                    Editor.OpenSource(member);
                }
            }
        }
Beispiel #17
0
 private void rPGConversionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (LastEditing != null)
     {
         RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag;
         Language     Language   = GetBoundLangType(SourceInfo.GetExtension());
         if (Language == Language.RPG)
         {
             SetStatus("Converting RPG in " + SourceInfo.GetName());
             LastEditing.DoAction(EditorAction.Convert_Selected_RPG);
         }
     }
 }
Beispiel #18
0
        private void compileAnyHandle(object sender, EventArgs e)
        {
            ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;

            if (LastEditing.Tag != null)
            {
                RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag;
                new Thread((ThreadStart) delegate
                {
                    IBMiUtils.CompileSource(SourceInfo, clickedItem.Text);
                }).Start();
            }
        }
		public EditRemoteDialog (RemoteSource remote, bool isNew)
		{
			this.Build ();
			this.remote = remote;
			
			updating = true;
			entryName.Text = remote.Name;
			entryUrl.Text = remote.FetchUrl ?? "";
			entryPushUrl.Text = string.IsNullOrEmpty (remote.PushUrl) ? remote.FetchUrl : remote.PushUrl;
			if (!isNew)
				checkImportTags.Visible = false;
			updating = false;
			UpdateButtons ();
		}
Beispiel #20
0
        void UpdateRemoteButtons()
        {
            TreeIter it;

            if (!treeRemotes.Selection.GetSelected(out it))
            {
                buttonAddRemote.Sensitive = buttonEditRemote.Sensitive = buttonRemoveRemote.Sensitive = buttonTrackRemote.Sensitive = false;
                return;
            }
            RemoteSource remote = (RemoteSource)storeRemotes.GetValue(it, 0);

            buttonTrackRemote.Sensitive = remote == null;
            buttonAddRemote.Sensitive   = buttonEditRemote.Sensitive = buttonRemoveRemote.Sensitive = remote != null;
        }
Beispiel #21
0
 private void objectList_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Node.Tag == null)
     {
     }
     else
     {
         if (e.Node.Tag is RemoteSource)
         {
             RemoteSource member = (RemoteSource)e.Node.Tag;
             Editor.OpenSource(member);
         }
     }
 }
Beispiel #22
0
        protected virtual void OnButtonAddRemoteClicked(object sender, EventArgs e)
        {
            var remote = new RemoteSource();
            var dlg    = new EditRemoteDialog(remote, true);

            try {
                if (MessageService.RunCustomDialog(dlg) == (int)ResponseType.Ok)
                {
                    repo.AddRemote(remote, dlg.ImportTags);
                    FillRemotes();
                }
            } finally {
                dlg.Destroy();
            }
        }
        public EditRemoteDialog(RemoteSource remote, bool isNew)
        {
            this.Build();
            this.remote = remote;

            updating          = true;
            entryName.Text    = remote.Name;
            entryUrl.Text     = remote.FetchUrl ?? "";
            entryPushUrl.Text = string.IsNullOrEmpty(remote.PushUrl) ? remote.FetchUrl : remote.PushUrl;
            if (!isNew)
            {
                checkImportTags.Visible = false;
            }
            updating = false;
            UpdateButtons();
        }
Beispiel #24
0
        protected virtual void OnButtonRemoveRemoteClicked(object sender, System.EventArgs e)
        {
            TreeIter it;

            if (!treeRemotes.Selection.GetSelected(out it))
            {
                return;
            }
            RemoteSource remote = (RemoteSource)storeRemotes.GetValue(it, 0);

            if (MessageService.Confirm(GettextCatalog.GetString("Are you sure you want to delete the remote '{0}'?", remote.Name), AlertButton.Delete))
            {
                repo.RemoveRemote(remote.Name);
                FillRemotes();
            }
        }
Beispiel #25
0
        public SaveAs(RemoteSource MemberInfo = null)
        {
            InitializeComponent();

            if (MemberInfo != null)
            {
                switch (MemberInfo.GetFS())
                {
                case FileSystem.IFS:
                    sourceSelectBox.SetSource(MemberInfo.GetRemoteFile());
                    sourceSelectBox.SetSource("", "", MemberInfo.GetName());
                    break;

                case FileSystem.QSYS:
                    sourceSelectBox.SetSource("", MemberInfo.GetObject(), MemberInfo.GetName());
                    break;
                }
            }
        }
Beispiel #26
0
        public static void OpenExistingSource(RemoteSource Source)
        {
            string text = Path.GetFileName(Source.GetName() + "." + Source.GetExtension().ToLower());

            if (File.Exists(Source.GetLocalFile()))
            {
                SourceEditor sourcePanel = new SourceEditor(Source.GetLocalFile(), GetBoundLangType(Source.GetExtension()), Source.GetRecordLength(), !Source.IsEditable());

                sourcePanel.Tag  = Source;
                sourcePanel.Text = text;

                Source.Lock();
                TheEditor.AddTool(sourcePanel, DockState.Document);
            }
            else
            {
                MessageBox.Show("There was an error opening the local file. '" + Source.GetLocalFile() + "' does not exist");
            }
        }
Beispiel #27
0
        public MemberCompareDisplay(RemoteSource MemberA, RemoteSource MemberB)
        {
            InitializeComponent();

            this.Text = MemberA.GetLibrary() + "/" + MemberA.GetObject() + "." + MemberA.GetName() + " -> " + MemberB.GetLibrary() + "/" + MemberB.GetObject() + "." + MemberB.GetName();

            var    dmp   = new diff_match_patch();
            var    res   = dmp.diff_main(File.ReadAllText(MemberA.GetLocalFile()), File.ReadAllText(MemberB.GetLocalFile()), false);
            string html  = dmp.diff_prettyHtml(res);
            string style = @"<head>
    <meta charset=" + '"' + "utf-8" + '"' + @" />
      <style>
          body {
                font-family: " + '"' + "Lucida Console" + '"' + @", Monaco, monospace
            }
    </style>
</head> ";

            webBrowser1.DocumentText = style + html;
        }
Beispiel #28
0
        private void SelectFile(string SourcePath)
        {
            if (SourcePath != "")
            {
                RemoteSource SourceFile;
                if (SourcePath.StartsWith("/"))
                {
                    SourceFile = new RemoteSource("", SourcePath);
                }
                else
                {
                    string   type = FileCache.GetType(SourcePath);
                    string[] data = SourcePath.Split(new char[] { '/', '.' }, StringSplitOptions.RemoveEmptyEntries);

                    SourceFile = new RemoteSource("", data[0], data[1], data[2], type);
                }

                Editor.OpenSource(SourceFile);

                this.Close();
            }
        }
Beispiel #29
0
        public static void OpenSource(RemoteSource source)
        {
            string resultFile = "";
            Thread gothread   = new Thread((ThreadStart) delegate {
                switch (source.GetFS())
                {
                case FileSystem.QSYS:
                    resultFile = IBMiUtils.DownloadMember(source.GetLibrary(), source.GetObject(), source.GetName(), source.GetExtension());
                    break;

                case FileSystem.IFS:
                    resultFile = IBMiUtils.DownloadFile(source.GetRemoteFile());
                    break;
                }

                if (resultFile != "")
                {
                    source._Local = resultFile;
                    //LOCK HERE
                    source.Lock();
                    TheEditor.Invoke((MethodInvoker) delegate
                    {
                        TheEditor.AddSourceEditor(source, GetBoundLangType(source.GetExtension()));
                    });
                }
                else
                {
                    switch (source.GetFS())
                    {
                    case FileSystem.QSYS:
                        MessageBox.Show("Unable to download member " + source.GetLibrary() + "/" + source.GetObject() + "." + source.GetName() + ". Please check it exists and that you have access to the remote system.");
                        break;
                    }
                }
            });

            gothread.Start();
        }
Beispiel #30
0
        private void compileRightclick_Opening(object sender, CancelEventArgs e)
        {
            compileOtherToolStripMenuItem.DropDownItems.Clear();
            List <ToolStripMenuItem> Compiles = new List <ToolStripMenuItem>();

            if (currentRightClick != null)
            {
                RemoteSource MemberInfo = currentRightClick;
                string[]     Items      = IBMi.CurrentSystem.GetValue("TYPE_" + MemberInfo.GetExtension()).Split('|');
                foreach (string Item in Items)
                {
                    if (Item.Trim() == "")
                    {
                        continue;
                    }
                    Compiles.Add(new ToolStripMenuItem(Item, null, compileAnyHandle));
                }
            }

            compileToolStripMenuItem.Enabled      = (Compiles.Count > 0);
            compileOtherToolStripMenuItem.Enabled = (Compiles.Count > 0);
            compileOtherToolStripMenuItem.DropDownItems.AddRange(Compiles.ToArray());
        }
Beispiel #31
0
        private void open_Click(object sender, EventArgs e)
        {
            stmfPath.Text = stmfPath.Text.Trim();

            if (stmfPath.Text == "")
            {
                MessageBox.Show("Path cannot be blank");
            }
            else
            {
                if (!IBMi.FileExists(stmfPath.Text))
                {
                    string filetemp = Path.Combine(IBMiUtils.GetLocalDir("IFS"), Path.GetFileName(stmfPath.Text));
                    File.Create(filetemp).Close();
                    result = new RemoteSource(filetemp, stmfPath.Text);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Chosen path already exists.");
                }
            }
        }