Exemplo n.º 1
0
        public static void OpenSource(RemoteSource Source)
        {
            SourceEditor sourcePanel;
            string       resultFile = "";
            string       text       = "";

            text = Path.GetFileName(Source.GetName() + "." + Source.GetExtension().ToLower());
            Editor.TheEditor.SetStatus("Fetching file " + text + "...");

            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 != "")
                {
                    Editor.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;

                    Editor.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();
        }
Exemplo n.º 2
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");
            }
        }
Exemplo n.º 3
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");
            }
        }